From 1de5483432a34a6a0d6ad769f9eb1d3e005f2658 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sat, 6 Aug 2022 18:00:23 +0800 Subject: [PATCH] finish env_export.cpp refactor. add new features (1/2) --- Documents/DevDocument_ZH.md | 4 +- .../SuperScriptMaterializer.vcxproj | 6 +- .../SuperScriptMaterializer.vcxproj.filters | 10 +- SuperScriptMaterializer/data_export.cpp | 2 - SuperScriptMaterializer/data_export.h | 9 - SuperScriptMaterializer/database.hpp | 2 +- SuperScriptMaterializer/doc_export.cpp | 151 ++++++++++- SuperScriptMaterializer/doc_export.hpp | 8 +- SuperScriptMaterializer/env_export.cpp | 246 +++++++++--------- SuperScriptMaterializer/env_export.h | 14 - SuperScriptMaterializer/env_export.hpp | 19 ++ SuperScriptMaterializer/string_helper.hpp | 4 +- ...s_compatible.h => virtools_compatible.hpp} | 5 +- 13 files changed, 306 insertions(+), 174 deletions(-) delete mode 100644 SuperScriptMaterializer/data_export.cpp delete mode 100644 SuperScriptMaterializer/data_export.h delete mode 100644 SuperScriptMaterializer/env_export.h create mode 100644 SuperScriptMaterializer/env_export.hpp rename SuperScriptMaterializer/{virtools_compatible.h => virtools_compatible.hpp} (72%) diff --git a/Documents/DevDocument_ZH.md b/Documents/DevDocument_ZH.md index 0f9fd16..188cede 100644 --- a/Documents/DevDocument_ZH.md +++ b/Documents/DevDocument_ZH.md @@ -253,7 +253,7 @@ doc.db导出的是当前Virtools文档内的脚本及其它重要数据。 |param_type_guid|TEXT|列的类型的GUID| |parent|INTEGER|表头所属表的`CK_ID`| -当列类型为Parameter时,`param_type`和`param_type_guid`为其所属CKParameterType的类型文本和GUID,当列类型为Object时,`param_type`为其对应的Class id,`param_type_guid`无效。列类型为其它类型时,`param_type`和`param_type_guid`均无效。 +当列类型为Parameter时,`param_type`和`param_type_guid`为其所属CKParameterType的类型文本和GUID,当列类型为Object时,`param_type`和`param_type_guid`均无效,因为无法确认对应CKObject的类型。列类型为其它类型时,`param_type`和`param_type_guid`也均无效。 ### array_cell @@ -340,7 +340,7 @@ env.db导出的是当前Virtools环境的数据,与文档无关,这部分如 |字段|类型|含义| |:---|:---|:---| |dll_index|INTEGER|`CKPluginEntry::m_PluginDllIndex`| -|dll_name|TEXT|`CKPluginEntry::m_PluginInfo`的`CKPluginInfo::m_DllFileName`| +|dll_name|TEXT|以`CKPluginEntry::m_PluginDllIndex`为参,使用`CKPluginManager::GetPluginDllInfo()`,获得的`CKPluginDll::m_DllFileName`| |plugin_index|INTEGER|`CKPluginEntry::m_PositionInDll`| |active|INTEGER|`CKPluginEntry::m_Active`| |guid|TEXT|`CKPluginEntry::m_PluginInfo`的`CKPluginInfo::m_GUID`| diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj index 3c08b68..6244eab 100644 --- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj +++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj @@ -109,18 +109,16 @@ - - + - + - diff --git a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters index 45bed75..5c2d901 100644 --- a/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters +++ b/SuperScriptMaterializer/SuperScriptMaterializer.vcxproj.filters @@ -18,7 +18,7 @@ 头文件 - + 头文件 @@ -33,10 +33,7 @@ 头文件 - - 头文件 - - + 头文件 @@ -65,9 +62,6 @@ 源文件 - - 源文件 - 源文件 diff --git a/SuperScriptMaterializer/data_export.cpp b/SuperScriptMaterializer/data_export.cpp deleted file mode 100644 index e6f9e9f..0000000 --- a/SuperScriptMaterializer/data_export.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "data_export.h" - diff --git a/SuperScriptMaterializer/data_export.h b/SuperScriptMaterializer/data_export.h deleted file mode 100644 index a876c96..0000000 --- a/SuperScriptMaterializer/data_export.h +++ /dev/null @@ -1,9 +0,0 @@ -#if !defined(_YYCDLL_DATA_EXPORT_H__IMPORTED_) -#define _YYCDLL_DATA_EXPORT_H__IMPORTED_ - -#include "stdafx.h" -#include "database.h" - -void DigCKObjectData(CKObject* cko, DocumentDatabase* mDb, dbdoc_data* helper, EXPAND_CK_ID parents); - -#endif \ No newline at end of file diff --git a/SuperScriptMaterializer/database.hpp b/SuperScriptMaterializer/database.hpp index a3d9126..89a6502 100644 --- a/SuperScriptMaterializer/database.hpp +++ b/SuperScriptMaterializer/database.hpp @@ -2,7 +2,7 @@ #include #include "stdafx.h" -#include "virtools_compatible.h" +#include "virtools_compatible.hpp" #include #include #include diff --git a/SuperScriptMaterializer/doc_export.cpp b/SuperScriptMaterializer/doc_export.cpp index 527e27c..51fd8bb 100644 --- a/SuperScriptMaterializer/doc_export.cpp +++ b/SuperScriptMaterializer/doc_export.cpp @@ -435,13 +435,160 @@ namespace SSMaterializer { #pragma endregion +#pragma region message + + void IterateMessage(CKContext* ctx, Database::DocumentDatabase* mDb) { + CKMessageManager* msgManager = ctx->GetMessageManager(); + int count = msgManager->GetMessageTypeCount(); + for (int i = 0; i < count; i++) { + mDb->mDbHelper.msg.index = i; + CopyCKString(mDb->mDbHelper.msg.name, msgManager->GetMessageTypeName(i)); + + mDb->write_msg(mDb->mDbHelper.msg); + } + } + +#pragma endregion + #pragma region array + void IterateArray(CKContext* ctx, Database::DocumentDatabase* mDb) { + // get all array + XObjectPointerArray objArray = ctx->GetObjectListByType(CKCID_DATAARRAY, TRUE); + CKDataArray* darray = NULL; + int len = objArray.Size(); + for (int i = 0; i < len; i++) { + darray = (CKDataArray*)objArray.GetObjectA(i); + + // dump self data first + mDb->mDbHelper._array.thisobj = darray->GetID(); + CopyCKString(mDb->mDbHelper._array.name, darray->GetName()); + mDb->mDbHelper._array.columns = darray->GetColumnCount(); + mDb->mDbHelper._array.rows = darray->GetRowCount(); + + mDb->write_array(mDb->mDbHelper._array); + + // dump column and row data + Proc_ArrayColumnRow(darray, mDb, darray->GetID()); + } + } + + void Proc_ArrayColumnRow(CKDataArray* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) { + int columns = cache->GetColumnCount(), rows = cache->GetRowCount(); + + // we iterate columns to get data + // because the value type of one column is not changed, + // it is benefit to our export. + for (int col = 0; col < columns; ++col) { + // dump column self first + mDb->mDbHelper.array_header.index = col; + CopyCKString(mDb->mDbHelper.array_header.name, cache->GetColumnName(col)); + + CK_ARRAYTYPE coltype = cache->GetColumnType(col); + mDb->mDbHelper.array_header.type = coltype; + if (coltype == CKARRAYTYPE_PARAMETER) { + CKGUID guid = cache->GetColumnParameterGuid(col); + CopyGuid(mDb->mDbHelper.array_header.param_type_guid, guid); + CKSTRING pname = mDb->mDbHelper.param_manager->ParameterGuidToName(guid); + CopyCKString(mDb->mDbHelper.array_header.param_type, pname); + } else { + mDb->mDbHelper.array_header.param_type = ""; + mDb->mDbHelper.array_header.param_type_guid = ""; + } + + mDb->mDbHelper.array_header.parent = parents; + mDb->write_array_header(mDb->mDbHelper.array_header); + + // write row data + switch (coltype) { + case CKARRAYTYPE_INT: + for (int row = 0; row < rows; ++row) { + mDb->mDbHelper.array_cell.column = col; + mDb->mDbHelper.array_cell.row = row; + mDb->mDbHelper.array_cell.parent = parents; + + Utils::StdstringPrintf(mDb->mDbHelper.array_cell.showcase, "%d", &((int*)cache->GetElement(row, col))); + mDb->mDbHelper.array_cell.inner_param = -1; + + mDb->write_array_cell(mDb->mDbHelper.array_cell); + } + break; + case CKARRAYTYPE_FLOAT: + for (int row = 0; row < rows; ++row) { + mDb->mDbHelper.array_cell.column = col; + mDb->mDbHelper.array_cell.row = row; + mDb->mDbHelper.array_cell.parent = parents; + + Utils::StdstringPrintf(mDb->mDbHelper.array_cell.showcase, "%f", &((float*)cache->GetElement(row, col))); + mDb->mDbHelper.array_cell.inner_param = -1; + + mDb->write_array_cell(mDb->mDbHelper.array_cell); + } + break; + case CKARRAYTYPE_STRING: + for (int row = 0; row < rows; ++row) { + mDb->mDbHelper.array_cell.column = col; + mDb->mDbHelper.array_cell.row = row; + mDb->mDbHelper.array_cell.parent = parents; + + int count = cache->GetElementStringValue(row, col, NULL); + mDb->mDbHelper.array_cell.showcase.resize(count); + cache->GetElementStringValue(row, col, (char*)mDb->mDbHelper.array_cell.showcase.data()); + mDb->mDbHelper.array_cell.inner_param = -1; + + mDb->write_array_cell(mDb->mDbHelper.array_cell); + } + break; + case CKARRAYTYPE_OBJECT: + for (int row = 0; row < rows; ++row) { + mDb->mDbHelper.array_cell.column = col; + mDb->mDbHelper.array_cell.row = row; + mDb->mDbHelper.array_cell.parent = parents; + + CKObject* obj = cache->GetElementObject(row, col); + if (obj == NULL) continue; // fail to get obj + CopyCKString(mDb->mDbHelper.array_cell.showcase, obj->GetName()); + mDb->mDbHelper.array_cell.inner_param = obj->GetID(); + + mDb->write_array_cell(mDb->mDbHelper.array_cell); + + // dig more data for it + DigObjectData(obj, mDb, obj->GetID()); + } + break; + case CKARRAYTYPE_PARAMETER: + for (int row = 0; row < rows; ++row) { + mDb->mDbHelper.array_cell.column = col; + mDb->mDbHelper.array_cell.row = row; + mDb->mDbHelper.array_cell.parent = parents; + + CKParameter* p = (CKParameter*)cache->GetElementObject(row, col); + if (p == NULL) continue; // fail to get obj + int count = p->GetStringValue(NULL, FALSE); + mDb->mDbHelper.array_cell.showcase.resize(count); + p->GetStringValue((char*)mDb->mDbHelper.array_cell.showcase.data(), FALSE); + mDb->mDbHelper.array_cell.inner_param = p->GetID(); + + mDb->write_array_cell(mDb->mDbHelper.array_cell); + + // dig more data for it. + DigParameterData(p, mDb, p->GetID()); + } + break; + } + + } + } + #pragma endregion #pragma region data process - void DigParameterData(CKParameterLocal* p, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) { + void DigObjectData(CKObject* o, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) { + + } + + void DigParameterData(CKParameter* p, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents) { CKGUID t = p->GetGUID(); CKParameterType pt = p->GetType(); BOOL unknowType = FALSE; @@ -614,7 +761,7 @@ namespace SSMaterializer { Utils::StdstringGetBase64(str_raw, cptr, ds); DataDictWritter("raw.data", str_raw.c_str(), mDb, parents); } - + //dump data length DataDictWritter("dump.length", (long)ds, mDb, parents); return; diff --git a/SuperScriptMaterializer/doc_export.hpp b/SuperScriptMaterializer/doc_export.hpp index 8914ed0..b60ff92 100644 --- a/SuperScriptMaterializer/doc_export.hpp +++ b/SuperScriptMaterializer/doc_export.hpp @@ -22,9 +22,13 @@ namespace SSMaterializer { void Proc_Behavior(CKContext* ctx, CKBehavior* bhv, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); void IterateScript(CKContext* ctx, Database::DocumentDatabase* mDb); - void IterateArray(CKContext* ctx, Database::DocumentDatabase* mDb); + void IterateMessage(CKContext* ctx, Database::DocumentDatabase* mDb); - void DigParameterData(CKParameterLocal* pl, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); + void IterateArray(CKContext* ctx, Database::DocumentDatabase* mDb); + void Proc_ArrayColumnRow(CKDataArray* cache, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); + + void DigObjectData(CKObject* o, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); + void DigParameterData(CKParameter* pl, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); void DataDictWritter(const char* field, long data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); void DataDictWritter(const char* field, float data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); void DataDictWritter(const char* field, const char* data, Database::DocumentDatabase* mDb, DataStruct::EXPAND_CK_ID parents); diff --git a/SuperScriptMaterializer/env_export.cpp b/SuperScriptMaterializer/env_export.cpp index c209d79..af32a06 100644 --- a/SuperScriptMaterializer/env_export.cpp +++ b/SuperScriptMaterializer/env_export.cpp @@ -1,147 +1,145 @@ -#include "env_export.h" +#include "env_export.hpp" +#include "string_helper.hpp" + //disable shit tip #pragma warning(disable:26812) -#define CopyGuid(guid,str) sprintf(helper->_stringCache,"%d,%d",guid.d1,guid.d2);str=helper->_stringCache; -#define CopyCKString(storage,str) storage=(str)?(str):""; +namespace SSMaterializer { + namespace EnvironmentExporter { -void IterateParameterOperation(CKParameterManager* parameterManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) { - int count = parameterManager->GetParameterOperationCount(); - CKOperationDesc* opList = NULL; - int listCount = 0, cacheListCount = 0; - CKGUID _guid; - for (int i = 0; i < count; i++) { - //fill basic data - helper->_db_op->op_code = i; - _guid = parameterManager->OperationCodeToGuid(i); - CopyGuid(_guid,helper->_db_op->op_guid); - helper->_db_op->op_name = parameterManager->OperationCodeToName(i); + void IterateParameterOperation(CKParameterManager* parameterManager, Database::EnvironmentDatabase* mDb) { + int count = parameterManager->GetParameterOperationCount(); + CKOperationDesc* opList = NULL; + CKGUID _guid; + int listCount = 0, cacheListCount = 0; + for (int i = 0; i < count; i++) { + //fill basic data + mDb->mDbHelper.op.op_code = i; + _guid = parameterManager->OperationCodeToGuid(i); + CopyGuid(mDb->mDbHelper.op.op_guid, _guid); + mDb->mDbHelper.op.op_name = parameterManager->OperationCodeToName(i); + + //allocate mem + cacheListCount = parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, NULL); + if (cacheListCount > listCount) { + listCount = cacheListCount; + opList = (CKOperationDesc*)realloc(opList, listCount * sizeof(CKOperationDesc)); + if (opList == NULL) return; + } + + parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, opList); + for (int j = 0; j < cacheListCount; j++) { + CopyGuid(mDb->mDbHelper.op.in1_guid, opList[j].P1Guid); + CopyGuid(mDb->mDbHelper.op.in2_guid, opList[j].P2Guid); + CopyGuid(mDb->mDbHelper.op.out_guid, opList[j].ResGuid); + mDb->mDbHelper.op.funcPtr = opList[j].Fct; + + mDb->write_op(mDb->mDbHelper.op); + } + } + if (opList != NULL) free(opList); - //allocate mem - cacheListCount = parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, NULL); - if (cacheListCount > listCount) { - listCount = cacheListCount; - opList = (CKOperationDesc*)realloc(opList, listCount * sizeof(CKOperationDesc)); - assert(opList != NULL); } - parameterManager->GetAvailableOperationsDesc(_guid, NULL, NULL, NULL, opList); - for (int j = 0; j < cacheListCount; j++) { - CopyGuid(opList[j].P1Guid, helper->_db_op->in1_guid); - CopyGuid(opList[j].P2Guid, helper->_db_op->in2_guid); - CopyGuid(opList[j].ResGuid, helper->_db_op->out_guid); - helper->_db_op->funcPtr = opList[j].Fct; + void IterateParameter(CKParameterManager* parameterManager, Database::EnvironmentDatabase* mDb) { + int count = parameterManager->GetParameterTypesCount(); + CKParameterTypeDesc* desc = NULL; + for (int i = 0; i < count; i++) { + desc = parameterManager->GetParameterTypeDescription(i); - mDb->write_op(helper->_db_op); + mDb->mDbHelper.param.index = desc->Index; + CopyGuid(mDb->mDbHelper.param.guid, desc->Guid); + CopyGuid(mDb->mDbHelper.param.derived_from, desc->DerivedFrom); + mDb->mDbHelper.param.type_name = desc->TypeName.CStr(); + mDb->mDbHelper.param.default_size = desc->DefaultSize; + mDb->mDbHelper.param.func_CreateDefault = desc->CreateDefaultFunction; + mDb->mDbHelper.param.func_Delete = desc->DeleteFunction; + mDb->mDbHelper.param.func_SaveLoad = desc->SaveLoadFunction; + mDb->mDbHelper.param.func_Check = desc->CheckFunction; + mDb->mDbHelper.param.func_Copy = desc->CopyFunction; + mDb->mDbHelper.param.func_String = desc->StringFunction; + mDb->mDbHelper.param.func_UICreator = desc->UICreatorFunction; + CKPluginEntry* plgEntry = desc->CreatorDll; + if (plgEntry != NULL) { + mDb->mDbHelper.param.creator_dll_index = plgEntry->m_PluginDllIndex; + mDb->mDbHelper.param.creator_plugin_index = plgEntry->m_PositionInDll; + } else { + mDb->mDbHelper.param.creator_dll_index = -1; + mDb->mDbHelper.param.creator_plugin_index = -1; + } + mDb->mDbHelper.param.dw_param = desc->dwParam; + mDb->mDbHelper.param.dw_flags = desc->dwFlags; + mDb->mDbHelper.param.cid = desc->Cid; + CopyGuid(mDb->mDbHelper.param.saver_manager, desc->Saver_Manager); + + mDb->write_param(mDb->mDbHelper.param); + } } - } - if (opList != NULL) free(opList); -} + void IterateAttribute(CKAttributeManager* attrManager, Database::EnvironmentDatabase* mDb) { + int count = attrManager->GetAttributeCount(); + for (int i = 0; i < count; i++) { + mDb->mDbHelper.attr.index = i; + mDb->mDbHelper.attr.name = attrManager->GetAttributeNameByType(i); + mDb->mDbHelper.attr.category_index = attrManager->GetAttributeCategoryIndex(i); + CopyCKString(mDb->mDbHelper.attr.category_name, attrManager->GetAttributeCategory(i)); + mDb->mDbHelper.attr.flags = attrManager->GetAttributeFlags(i); + mDb->mDbHelper.attr.param_index = attrManager->GetAttributeParameterType(i); + mDb->mDbHelper.attr.compatible_classid = attrManager->GetAttributeCompatibleClassId(i); + CopyCKString(mDb->mDbHelper.attr.default_value, attrManager->GetAttributeDefaultValue(i)); -void IterateParameter(CKParameterManager* parameterManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) { - int count = parameterManager->GetParameterTypesCount(); - CKParameterTypeDesc* desc = NULL; - for (int i = 0; i < count; i++) { - desc = parameterManager->GetParameterTypeDescription(i); - - helper->_db_param->index = desc->Index; - CopyGuid(desc->Guid, helper->_db_param->guid); - CopyGuid(desc->DerivedFrom, helper->_db_param->derived_from); - helper->_db_param->type_name = desc->TypeName.CStr(); - helper->_db_param->default_size = desc->DefaultSize; - helper->_db_param->func_CreateDefault = desc->CreateDefaultFunction; - helper->_db_param->func_Delete = desc->DeleteFunction; - helper->_db_param->func_SaveLoad = desc->SaveLoadFunction; - helper->_db_param->func_Check = desc->CheckFunction; - helper->_db_param->func_Copy = desc->CopyFunction; - helper->_db_param->func_String = desc->StringFunction; - helper->_db_param->func_UICreator = desc->UICreatorFunction; - CKPluginEntry* plgEntry = desc->CreatorDll; - if (plgEntry != NULL) { - helper->_db_param->creator_dll_index = plgEntry->m_PluginDllIndex; - helper->_db_param->creator_plugin_index = plgEntry->m_PositionInDll; - } else { - helper->_db_param->creator_dll_index =-1; - helper->_db_param->creator_plugin_index =-1; + mDb->write_attr(mDb->mDbHelper.attr); + } } - helper->_db_param->dw_param = desc->dwParam; - helper->_db_param->dw_flags = desc->dwFlags; - helper->_db_param->cid = desc->Cid; - CopyGuid(desc->Saver_Manager, helper->_db_param->saver_manager); - mDb->write_param(helper->_db_param); - } -} + void IteratePlugin(CKPluginManager* plgManager, Database::EnvironmentDatabase* mDb) { + for (int i = 0; i <= 7; i++) { + int catCount = plgManager->GetPluginCount(i); + mDb->mDbHelper.plugin.category = plgManager->GetCategoryName(i); + for (int j = 0; j < catCount; j++) { + CKPluginEntry* plgEntry = plgManager->GetPluginInfo(i, j); + CKPluginInfo* plgInfo = &(plgEntry->m_PluginInfo); + CKPluginDll* plgDll = plgManager->GetPluginDllInfo(plgEntry->m_PluginDllIndex); -void IterateMessage(CKMessageManager* msgManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) { - int count = msgManager->GetMessageTypeCount(); - for (int i = 0; i < count; i++) { - helper->_db_envMsg->index = i; - helper->_db_envMsg->name = msgManager->GetMessageTypeName(i); + mDb->mDbHelper.plugin.dll_index = plgEntry->m_PluginDllIndex; - mDb->write_msg(helper->_db_envMsg); - } -} + mDb->mDbHelper.plugin.dll_name = plgDll->m_DllFileName.CStr(); -void IterateAttribute(CKAttributeManager* attrManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) { - int count = attrManager->GetAttributeCount(); - for (int i = 0; i < count; i++) { - helper->_db_attr->index = i; - helper->_db_attr->name = attrManager->GetAttributeNameByType(i); - helper->_db_attr->category_index = attrManager->GetAttributeCategoryIndex(i); - helper->_db_attr->category_name = attrManager->GetAttributeCategory(i) != NULL ? attrManager->GetAttributeCategory(i) : ""; - helper->_db_attr->flags = attrManager->GetAttributeFlags(i); - helper->_db_attr->param_index = attrManager->GetAttributeParameterType(i); - helper->_db_attr->compatible_classid = attrManager->GetAttributeCompatibleClassId(i); - helper->_db_attr->default_value = attrManager->GetAttributeDefaultValue(i) != NULL ? attrManager->GetAttributeDefaultValue(i) : ""; + mDb->mDbHelper.plugin.plugin_index = plgEntry->m_PositionInDll; + mDb->mDbHelper.plugin.active = plgEntry->m_Active; - mDb->write_attr(helper->_db_attr); - } -} + CopyGuid(mDb->mDbHelper.plugin.guid, plgInfo->m_GUID); + mDb->mDbHelper.plugin.desc = plgInfo->m_Description.CStr(); + mDb->mDbHelper.plugin.author = plgInfo->m_Author.CStr(); + mDb->mDbHelper.plugin.summary = plgInfo->m_Summary.CStr(); + mDb->mDbHelper.plugin.version = plgInfo->m_Version; + mDb->mDbHelper.plugin.func_init = plgInfo->m_InitInstanceFct; + mDb->mDbHelper.plugin.func_exit = plgInfo->m_ExitInstanceFct; -void IteratePlugin(CKPluginManager* plgManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) { - for (int i = 0; i <= 7; i++) { - int catCount = plgManager->GetPluginCount(i); - helper->_db_plugin->category = plgManager->GetCategoryName(i); - for (int j = 0; j < catCount; j++) { - CKPluginEntry* plgEntry = plgManager->GetPluginInfo(i, j); - - helper->_db_plugin->dll_index = plgEntry->m_PluginDllIndex; - helper->_db_plugin->dll_name = plgManager->GetPluginDllInfo(plgEntry->m_PluginDllIndex)->m_DllFileName.CStr(); - helper->_db_plugin->plugin_index = plgEntry->m_PositionInDll; - helper->_db_plugin->active = plgEntry->m_Active; - helper->_db_plugin->needed_by_file = plgEntry->m_NeededByFile; - CKPluginInfo* plgInfo = &(plgEntry->m_PluginInfo); - CopyGuid(plgInfo->m_GUID, helper->_db_plugin->guid); - helper->_db_plugin->desc = plgInfo->m_Description.CStr(); - helper->_db_plugin->author = plgInfo->m_Author.CStr(); - helper->_db_plugin->summary = plgInfo->m_Summary.CStr(); - helper->_db_plugin->version = plgInfo->m_Version; - helper->_db_plugin->func_init = plgInfo->m_InitInstanceFct; - helper->_db_plugin->func_exit = plgInfo->m_ExitInstanceFct; - - mDb->write_plugin(helper->_db_plugin); + mDb->write_plugin(mDb->mDbHelper.plugin); + } + } } - } -} #if !defined(VIRTOOLS_21) -void IterateVariable(CKVariableManager* varManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper) { - CKVariableManager::Iterator it = varManager->GetVariableIterator(); - CKVariableManager::Variable* varobj = NULL; - XString dataCopyCache; - for (; !it.End(); it++) { - varobj = it.GetVariable(); - helper->_db_variable->name = it.GetName(); - CopyCKString(helper->_db_variable->desciption, varobj->GetDescription()); - helper->_db_variable->flags = varobj->GetFlags(); - helper->_db_variable->type = varobj->GetType(); - CopyCKString(helper->_db_variable->representation, varobj->GetRepresentation()); - varobj->GetStringValue(dataCopyCache); - helper->_db_variable->data = dataCopyCache.CStr(); + void IterateVariable(CKVariableManager* varManager, Database::EnvironmentDatabase* mDb) { + CKVariableManager::Iterator it = varManager->GetVariableIterator(); + CKVariableManager::Variable* varobj = NULL; + XString dataCopyCache; + for (; !it.End(); it++) { + varobj = it.GetVariable(); + mDb->mDbHelper.variable.name = it.GetName(); + CopyCKString(mDb->mDbHelper.variable.desciption, varobj->GetDescription()); + mDb->mDbHelper.variable.flags = varobj->GetFlags(); + mDb->mDbHelper.variable.type = varobj->GetType(); + CopyCKString(mDb->mDbHelper.variable.representation, varobj->GetRepresentation()); + varobj->GetStringValue(dataCopyCache); + mDb->mDbHelper.variable.data = dataCopyCache.CStr(); + + mDb->write_variable(mDb->mDbHelper.variable); + } + } +#endif - mDb->write_variable(helper->_db_variable); } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/SuperScriptMaterializer/env_export.h b/SuperScriptMaterializer/env_export.h deleted file mode 100644 index e3a1fcd..0000000 --- a/SuperScriptMaterializer/env_export.h +++ /dev/null @@ -1,14 +0,0 @@ -#if !defined(_YYCDLL_ENV_EXPORT_H__IMPORTED_) -#define _YYCDLL_ENV_EXPORT_H__IMPORTED_ - -#include "stdafx.h" -#include "database.h" - -void IterateParameterOperation(CKParameterManager* parameterManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper); -void IterateParameter(CKParameterManager* parameterManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper); -void IterateMessage(CKMessageManager* msgManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper); -void IterateAttribute(CKAttributeManager* attrManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper); -void IteratePlugin(CKPluginManager* plgManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper); -void IterateVariable(CKVariableManager* varManager, EnvironmentDatabase* mDb, dbEnvDataStructHelper* helper); - -#endif \ No newline at end of file diff --git a/SuperScriptMaterializer/env_export.hpp b/SuperScriptMaterializer/env_export.hpp new file mode 100644 index 0000000..642bd55 --- /dev/null +++ b/SuperScriptMaterializer/env_export.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include "stdafx.h" +#include "database.hpp" + +namespace SSMaterializer { + namespace EnvironmentExporter { + + void IterateParameterOperation(CKParameterManager* parameterManager, Database::EnvironmentDatabase* mDb); + void IterateParameter(CKParameterManager* parameterManager, Database::EnvironmentDatabase* mDb); + void IterateAttribute(CKAttributeManager* attrManager, Database::EnvironmentDatabase* mDb); + void IteratePlugin(CKPluginManager* plgManager, Database::EnvironmentDatabase* mDb); + +#if !defined(VIRTOOLS_21) + void IterateVariable(CKVariableManager* varManager, Database::EnvironmentDatabase* mDb); +#endif + + } +} \ No newline at end of file diff --git a/SuperScriptMaterializer/string_helper.hpp b/SuperScriptMaterializer/string_helper.hpp index f2fd0a0..2de0ccc 100644 --- a/SuperScriptMaterializer/string_helper.hpp +++ b/SuperScriptMaterializer/string_helper.hpp @@ -4,9 +4,9 @@ #include #define CopyGuid(str, guid) SSMaterializer::Utils::StdstringPrintf((str), "0x%08X, 0x%08X", (guid).d1, (guid).d2); -#define CopyCKString(storage, str) storage = (str) ? (str) : ""; +#define CopyCKString(storage, str) storage = (str) ? (str) : "!!UNKNOW!!"; #define CopyCKParamTypeStr(strl, ckpt, pm) if ((ckpt) != -1) (strl) = (pm)->ParameterTypeToName(ckpt);\ -else (strl) = "!!UNKNOW TYPE!!"; +else (strl) = "!!UNKNOW!!"; namespace SSMaterializer { namespace Utils { diff --git a/SuperScriptMaterializer/virtools_compatible.h b/SuperScriptMaterializer/virtools_compatible.hpp similarity index 72% rename from SuperScriptMaterializer/virtools_compatible.h rename to SuperScriptMaterializer/virtools_compatible.hpp index 0f63880..32a2750 100644 --- a/SuperScriptMaterializer/virtools_compatible.h +++ b/SuperScriptMaterializer/virtools_compatible.hpp @@ -1,5 +1,4 @@ -#if !defined(_YYCDLL_VIRTOOLS_COMPATIBLE_H__IMPORTED_) -#define _YYCDLL_VIRTOOLS_COMPATIBLE_H__IMPORTED_ +#pragma once #include "stdafx.h" @@ -10,5 +9,3 @@ #elif defined(VIRTOOLS_25) || defined(VIRTOOLS_35) || defined(VIRTOOLS_40) || defined(VIRTOOLS_50) #define UNIVERSAL_VAR_TYPE CKVariableManager::Variable::Type #endif - -#endif \ No newline at end of file