diff --git a/CodeGen/src/CKMISC.txt b/CodeGen/src/CKMISC.txt index 03725d2..a4d45d8 100644 --- a/CodeGen/src/CKMISC.txt +++ b/CodeGen/src/CKMISC.txt @@ -68,3 +68,45 @@ enum CK_STATECHUNK_CHUNKOPTIONS CHNK_DONTDELETE_PTR = 0x40, // Data buffer stored in m_Buffer is not owned by CKStateChunk , it must not be deleted... CHNK_DONTDELETE_PARSER = 0x80, // m_Parser Ptr is not owned by CKStateChunk , it must not be deleted... +enum !CK_OBJECT_FLAGS + CK_OBJECT_INTERFACEOBJ = 0x00000001, // Reserved for Inteface Use + CK_OBJECT_PRIVATE = 0x00000002, // The object must not be displayed in interface (Lists,Level view,etc...),nor should it be saved. (CKObject::IsPrivate() + CK_OBJECT_INTERFACEMARK = 0x00000004, + CK_OBJECT_FREEID = 0x00000008, // ID of this object can be released safely and is free to be reused by future CKobjects. + CK_OBJECT_TOBEDELETED = 0x00000010, // This object is being deleted + CK_OBJECT_NOTTOBESAVED = 0x00000020, // This object must not be saved + CK_OBJECT_VISIBLE = 0x00000040, // This object is visible (CKObject::Show) + CK_OBJECT_NAMESHARED = 0x00000080, // This object has its name from another entity + CK_OBJECT_DYNAMIC = 0x00000108, // This object may be created or deleted at run-time, it also contails CK_OBJECT_FREEID. (CKObject::IsDynamic,CKContext::CreateObject) + CK_OBJECT_HIERACHICALHIDE = 0x00000200, // This object hides all its hierarchy (CKObject::Show) + CK_OBJECT_UPTODATE = 0x00000400, // (Camera,etc..) + CK_OBJECT_TEMPMARKER = 0x00000800, + CK_OBJECT_ONLYFORFILEREFERENCE = 0x00001000, + CK_OBJECT_NOTTOBEDELETED = 0x00002000, // This object must not be deleted in a clear all + CK_OBJECT_APPDATA = 0x00004000, // This object has app data + CK_OBJECT_SINGLEACTIVITY = 0x00008000, // this object has an information of single activity + CK_OBJECT_LOADSKIPBEOBJECT = 0x00010000, // When loading this object the CKBeObject part should be skipped + + CK_OBJECT_NOTTOBELISTEDANDSAVED = 0x00000023, // Combination of Private and Not To Be Saved + + +// The following flags are specific to parameters (they are stored here for object's size purposes ) + CK_PARAMETEROUT_SETTINGS = 0x00400000, + CK_PARAMETEROUT_PARAMOP = 0x00800000, // This parameter is the output of a CKParameterOperation (Automatically set by Engine) + CK_PARAMETERIN_DISABLED = 0x01000000, // Parameter In or Out is disabled (CKBehavior::EnableInputParameter,CKBehavior::DisableInputParameter) + CK_PARAMETERIN_THIS = 0x02000000, // Special parameter type : its value and type are always equal to its owner (CKParameter::SetAsMyselfParameter) + CK_PARAMETERIN_SHARED = 0x04000000, + CK_PARAMETEROUT_DELETEAFTERUSE = 0x08000000, // When adding parameters to CKMessage, they can be automatically deleted when message is released (CKMessage::AddParameter) + CK_OBJECT_PARAMMASK = 0x0FC00000, // Mask for options specific to parameters + +// The Following flags are specific for Behavior ios (CKBehaviorIO) + CK_BEHAVIORIO_IN = 0x10000000, // This BehaviorIO is a behavior input (CKBehaviorIO::SetType} + CK_BEHAVIORIO_OUT = 0x20000000, // This BehaviorIO is a behavior output (CKBehaviorIO::SetType) + CK_BEHAVIORIO_ACTIVE = 0x40000000, // This BehaviorIO is a currently active (CKBehaviorIO::Activate} + CK_OBJECT_IOTYPEMASK = 0x30000000, + CK_OBJECT_IOMASK = 0xF0000000, + + // The Following flags are specific for Behavior ios (CKBehaviorIO) + CKBEHAVIORLINK_RESERVED = 0x10000000, // This BehaviorIO is a behavior input (CKBehaviorIO::SetType} + CKBEHAVIORLINK_ACTIVATEDLASTFRAME = 0x20000000, // This link had been activated last frame + CK_OBJECT_BEHAVIORLINKMASK = 0x30000000, diff --git a/LibCmo/CKDefines.hpp b/LibCmo/CKDefines.hpp index bbe13ee..3d688a4 100644 --- a/LibCmo/CKDefines.hpp +++ b/LibCmo/CKDefines.hpp @@ -4,34 +4,133 @@ #include namespace LibCmo { + namespace CK2 { - using CKINT = int32_t; - using CK_ID = uint32_t; - using CKDWORD = uint32_t; - using CKWORD = uint16_t; - using CKBYTE = uint8_t; - using CKBOOL = int32_t; - using CKMUTSTRING = char*; - using CKSTRING = const char*; + // some important type define - using XString = std::string; - using XBitArray = std::vector; - template - using XArray = std::vector; - using XIntArray = std::vector; - template - using XClassArray = std::vector; - //using CKObjectArray = std::vector; + using CK_ID = uint32_t; - struct CKGUID { - union { - struct { - CKDWORD d1, d2; - }; - CKDWORD d[2]; - }; - CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) { d[0] = gd1; d[1] = gd2; } - }; + using CKDWORD = uint32_t; + using CKWORD = uint16_t; + using CKBYTE = uint8_t; + using CKBOOL = int32_t; + using CKINT = int32_t; + using CKMUTSTRING = char*; + using CKSTRING = const char*; + + using XString = std::string; + using XBitArray = std::vector; + template + using XArray = std::vector; + using XIntArray = std::vector; + template + using XClassArray = std::vector; + //using CKObjectArray = std::vector; + + + // forward decl for some CKObjects + namespace CKObjectImplements { + class CKObject; + class CKParameterIn; + class CKParameter; + class CKParameterOut; + class CKParameterLocal; + class CKParameterOperation; + class CKBehaviorLink; + class CKBehaviorIO; + + class CKSceneObject; + class CKBehavior; + + class CKBeObject; + class CKScene; + class CKLevel; + class CKPlace; + class CKGroup; + class CKMaterial; + class CKTexture; + class CKMesh; + class CKDataArray; + class CKRenderObject; + class CK3dEntity; + class CK3dObject; + } + // forward decl for some CKManagers + namespace CKManagerImplements { + class CKBaseManager; + class CKAttributeManager; + } + + // forward decl for some important CK2 classes + class CKMinContext; + class CKStateChunk; + class CKFile; + namespace CKFileData { + class ShallowDocument; + class DeepDocument; + class HybridDocument; + } + + // useful struct define + struct CKGUID { + union { + struct { + CKDWORD d1, d2; + }; + CKDWORD d[2]; + }; + CKGUID(CKDWORD gd1 = 0, CKDWORD gd2 = 0) { d[0] = gd1; d[1] = gd2; } + }; + + + } + + namespace VxMath { + + // forward decl for some important VxMath classes + class VxMemoryMappedFile; + + struct VxVector { + union { + struct { + float x, y, z; + }; + float v[3]; + }; + + VxVector() : x(0.0f), y(0.0f), z(0.0f) { ; } + VxVector(float f) : x(f), y(f), z(f) { ; } + VxVector(float _x, float _y, float _z) : x(_x), y(_y), z(_z) { ; } + VxVector(const float f[3]) : x(f[0]), y(f[1]), z(f[2]) { ; } + }; + + struct VxQuaternion { + union { + struct { + VxVector axis; + float angle; + }; + struct { + float x, y, z, w; + }; + float v[4]; + }; + + VxQuaternion() : x(0.0f), y(0.0f), z(0.0f), w(1.0f) { ; } + VxQuaternion(float X, float Y, float Z, float W) : x(X), y(Y), z(Z), w(W) { ; } + }; + + struct VxMatrix { + float m_Data[4][4]; + + VxMatrix() : m_Data() { + memset(m_Data, 0, sizeof(m_Data)); + m_Data[0][0] = m_Data[1][1] = m_Data[2][2] = m_Data[3][3] = 1.0f; + } + VxMatrix(float m[4][4]) : m_Data() { std::memcpy(m_Data, m, sizeof(m_Data)); } + }; + + } } diff --git a/LibCmo/CKEnums.hpp b/LibCmo/CKEnums.hpp index 05cef5d..7706b86 100644 --- a/LibCmo/CKEnums.hpp +++ b/LibCmo/CKEnums.hpp @@ -1,28 +1,9 @@ #pragma once -#include #include #include -#include -namespace LibCmo { - - namespace EnumsHelper { - template - inline TEnum FlagEnumAdd(TEnum e, ...) { - TEnum result = e; - va_list argptr; - va_start(argptr, e); - result = static_cast(static_cast>(result) | static_cast>(va_arg(argptr, TEnum))); - va_end(argptr); - return result; - } - - template - inline bool FlagEnumHas(TEnum e, TEnum probe) { - return static_cast(static_cast>(e) & static_cast>(probe)); - } - } +namespace LibCmo::CK2 { enum class CK_CLASSID : uint32_t { CKCID_OBJECT = 1, @@ -150,14 +131,14 @@ namespace LibCmo { CKERR_INVALIDANIMATION = -123 }; - enum class CK_FILE_WRITEMODE : int32_t { + enum class CK_FILE_WRITEMODE : uint32_t { CKFILE_UNCOMPRESSED = 0, CKFILE_CHUNKCOMPRESSED_OLD = 1, CKFILE_EXTERNALTEXTURES_OLD = 2, CKFILE_FORVIEWER = 4, CKFILE_WHOLECOMPRESSED = 8 }; - enum class CK_LOAD_FLAGS : int32_t { + enum class CK_LOAD_FLAGS : uint32_t { CK_LOAD_ANIMATION = 1 << 0, CK_LOAD_GEOMETRY = 1 << 1, CK_LOAD_DEFAULT = CK_LOAD_GEOMETRY | CK_LOAD_ANIMATION, @@ -169,13 +150,13 @@ namespace LibCmo { CK_LOAD_CHECKDEPENDENCIES = 1 << 7, CK_LOAD_ONLYBEHAVIORS = 1 << 8 }; - enum class CK_FO_OPTIONS : int32_t { + enum class CK_FO_OPTIONS : uint32_t { CK_FO_DEFAULT = 0, CK_FO_RENAMEOBJECT, CK_FO_REPLACEOBJECT, CK_FO_DONTLOADOBJECT }; - enum class CK_PLUGIN_TYPE : int32_t { + enum class CK_PLUGIN_TYPE : uint32_t { CKPLUGIN_BITMAP_READER = 0, CKPLUGIN_SOUND_READER = 1, CKPLUGIN_MODEL_READER = 2, @@ -185,7 +166,7 @@ namespace LibCmo { CKPLUGIN_MOVIE_READER = 6, CKPLUGIN_EXTENSION_DLL = 7 }; - enum class CK_STATECHUNK_DATAVERSION : int32_t { + enum class CK_STATECHUNK_DATAVERSION : uint32_t { CHUNKDATA_OLDVERSION = 0, CHUNKDATA_BASEVERSION = 1, CHUNK_WAVESOUND_VERSION2 = 2, @@ -199,14 +180,14 @@ namespace LibCmo { CHUNK_DEV_2_1 = 10, CHUNKDATA_CURRENTVERSION = CHUNK_DEV_2_1 }; - enum class CK_STATECHUNK_CHUNKVERSION : int32_t { + enum class CK_STATECHUNK_CHUNKVERSION : uint32_t { CHUNK_VERSIONBASE = 0, CHUNK_VERSION1 = 4, CHUNK_VERSION2 = 5, CHUNK_VERSION3 = 6, CHUNK_VERSION4 = 7 }; - enum class CK_STATECHUNK_CHUNKOPTIONS : int32_t { + enum class CK_STATECHUNK_CHUNKOPTIONS : uint32_t { CHNK_OPTION_IDS = 0x01, CHNK_OPTION_MAN = 0x02, CHNK_OPTION_CHN = 0x04, @@ -216,5 +197,40 @@ namespace LibCmo { CHNK_DONTDELETE_PTR = 0x40, CHNK_DONTDELETE_PARSER = 0x80 }; + enum class CK_OBJECT_FLAGS : uint32_t { + CK_OBJECT_INTERFACEOBJ = 0x00000001, + CK_OBJECT_PRIVATE = 0x00000002, + CK_OBJECT_INTERFACEMARK = 0x00000004, + CK_OBJECT_FREEID = 0x00000008, + CK_OBJECT_TOBEDELETED = 0x00000010, + CK_OBJECT_NOTTOBESAVED = 0x00000020, + CK_OBJECT_VISIBLE = 0x00000040, + CK_OBJECT_NAMESHARED = 0x00000080, + CK_OBJECT_DYNAMIC = 0x00000108, + CK_OBJECT_HIERACHICALHIDE = 0x00000200, + CK_OBJECT_UPTODATE = 0x00000400, + CK_OBJECT_TEMPMARKER = 0x00000800, + CK_OBJECT_ONLYFORFILEREFERENCE = 0x00001000, + CK_OBJECT_NOTTOBEDELETED = 0x00002000, + CK_OBJECT_APPDATA = 0x00004000, + CK_OBJECT_SINGLEACTIVITY = 0x00008000, + CK_OBJECT_LOADSKIPBEOBJECT = 0x00010000, + CK_OBJECT_NOTTOBELISTEDANDSAVED = 0x00000023, + CK_PARAMETEROUT_SETTINGS = 0x00400000, + CK_PARAMETEROUT_PARAMOP = 0x00800000, + CK_PARAMETERIN_DISABLED = 0x01000000, + CK_PARAMETERIN_THIS = 0x02000000, + CK_PARAMETERIN_SHARED = 0x04000000, + CK_PARAMETEROUT_DELETEAFTERUSE = 0x08000000, + CK_OBJECT_PARAMMASK = 0x0FC00000, + CK_BEHAVIORIO_IN = 0x10000000, + CK_BEHAVIORIO_OUT = 0x20000000, + CK_BEHAVIORIO_ACTIVE = 0x40000000, + CK_OBJECT_IOTYPEMASK = 0x30000000, + CK_OBJECT_IOMASK = 0xF0000000, + CKBEHAVIORLINK_RESERVED = 0x10000000, + CKBEHAVIORLINK_ACTIVATEDLASTFRAME = 0x20000000, + CK_OBJECT_BEHAVIORLINKMASK = 0x30000000 + }; } diff --git a/LibCmo/CKFile.cpp b/LibCmo/CKFile.cpp index 1484bca..4e652a5 100644 --- a/LibCmo/CKFile.cpp +++ b/LibCmo/CKFile.cpp @@ -1,7 +1,9 @@ #include "CKFile.hpp" +#include "CKStateChunk.hpp" +#include "CKMinContext.hpp" #include -namespace LibCmo { +namespace LibCmo::CK2 { #pragma region CKBufferParser @@ -29,12 +31,12 @@ namespace LibCmo { #pragma region CKFileObject - LibCmo::CKFileObject::CKFileObject() : - Data(nullptr) { + CKFileObject::CKFileObject() : + Data(nullptr) { ; } - LibCmo::CKFileObject::~CKFileObject() { + CKFileObject::~CKFileObject() { ; } @@ -60,30 +62,34 @@ namespace LibCmo { #pragma endregion + namespace CKFileData { + #pragma region ShallowDocument - LibCmo::CKFileData::ShallowDocument::ShallowDocument() { - this->m_IndexByClassId.resize(static_cast(CK_CLASSID::CKCID_MAXCLASSID)); - } + ShallowDocument::ShallowDocument() { + this->m_IndexByClassId.resize(static_cast(CK_CLASSID::CKCID_MAXCLASSID)); + } - LibCmo::CKFileData::ShallowDocument::~ShallowDocument() { + ShallowDocument::~ShallowDocument() { - } + } #pragma endregion #pragma region DeepDocument - LibCmo::CKFileData::DeepDocument::DeepDocument() { - this->m_IndexByClassId.resize(static_cast(CK_CLASSID::CKCID_MAXCLASSID)); - } + DeepDocument::DeepDocument() { + this->m_IndexByClassId.resize(static_cast(CK_CLASSID::CKCID_MAXCLASSID)); + } - LibCmo::CKFileData::DeepDocument::~DeepDocument() { + DeepDocument::~DeepDocument() { - } + } #pragma endregion + } + #pragma region CKFile Misc CKFile::CKFile(CKMinContext* ctx) : diff --git a/LibCmo/CKFile.hpp b/LibCmo/CKFile.hpp index a252ced..b30cbe0 100644 --- a/LibCmo/CKFile.hpp +++ b/LibCmo/CKFile.hpp @@ -3,11 +3,7 @@ #include "CKDefines.hpp" #include "CKEnums.hpp" -#include "VxMemoryMappedFile.hpp" -#include "CKStateChunk.hpp" -#include "CKMinContext.hpp" - -namespace LibCmo { +namespace LibCmo::CK2 { class CKBufferParser { private: @@ -24,11 +20,11 @@ namespace LibCmo { inline const void* GetPtr(void) { return (this->m_MemBegin + m_MemPos); } inline void Read(void* data, size_t data_size) { - memcpy(data, (this->m_MemBegin + m_MemPos), data_size); + std::memcpy(data, (this->m_MemBegin + m_MemPos), data_size); this->m_MemPos += data_size; } inline void Write(const void* data, size_t data_size) { - memcpy((this->m_MemBegin + m_MemPos), data, data_size); + std::memcpy((this->m_MemBegin + m_MemPos), data, data_size); this->m_MemPos += data_size; } inline void* GetBase(void) { return this->m_MemBegin; } @@ -158,7 +154,7 @@ namespace LibCmo { int32_t m_SaveIDMax; CKFileInfo m_FileInfo; - XArray m_Objects; + XArray m_Objects; XClassArray m_IndexByClassId; XClassArray m_IncludedFiles; private: diff --git a/LibCmo/CKFileReader.cpp b/LibCmo/CKFileReader.cpp index a3adb8d..fd7b0e3 100644 --- a/LibCmo/CKFileReader.cpp +++ b/LibCmo/CKFileReader.cpp @@ -1,8 +1,11 @@ #include "CKFile.hpp" #include "CKGlobals.hpp" +#include "CKStateChunk.hpp" +#include "VxMemoryMappedFile.hpp" +#include "CKMinContext.hpp" #include -namespace LibCmo { +namespace LibCmo::CK2 { /* * NOTE: @@ -17,7 +20,7 @@ namespace LibCmo { // check file and open memory if (u8_filename == nullptr) return CKERROR::CKERR_INVALIDPARAMETER; - std::unique_ptr mappedFile(new(std::nothrow) VxMemoryMappedFile(u8_filename)); + std::unique_ptr mappedFile(new(std::nothrow) VxMath::VxMemoryMappedFile(u8_filename)); if (mappedFile == nullptr) { this->m_MinCtx->Printf("Out of memory when creating Memory File."); return CKERROR::CKERR_OUTOFMEMORY; @@ -54,7 +57,7 @@ namespace LibCmo { // ========== read header ========== // check header size if (parser->GetSize() < sizeof(CKRawFileInfo)) return CKERROR::CKERR_INVALIDFILE; - if (memcmp(parser->GetPtr(), "Nemo Fi", sizeof(CKRawFileInfo::NeMo))) return CKERROR::CKERR_INVALIDFILE; + if (std::memcmp(parser->GetPtr(), "Nemo Fi", sizeof(CKRawFileInfo::NeMo))) return CKERROR::CKERR_INVALIDFILE; // read header CKRawFileInfo rawHeader; parser->Read(&rawHeader, sizeof(CKRawFileInfo)); @@ -138,7 +141,7 @@ namespace LibCmo { if (namelen != 0) { name_conv.resize(namelen); parser->Read(name_conv.data(), namelen); - m_MinCtx->GetUtf8ObjectName(name_conv, fileobj.Name); + m_MinCtx->GetUtf8String(name_conv, fileobj.Name); } } } @@ -325,7 +328,7 @@ namespace LibCmo { // read filename if (filenamelen != 0) { parser->Read(name_conv.data(), filenamelen); - m_MinCtx->GetUtf8ObjectName(name_conv, file); + m_MinCtx->GetUtf8String(name_conv, file); } // read file body length @@ -335,7 +338,7 @@ namespace LibCmo { // read file body FILE* fp = m_MinCtx->OpenTempFile(file.c_str(), false); if (fp != nullptr) { - Utils::CopyStream(parser->GetPtr(), fp, filebodylen); + StreamHelper::CopyStream(parser->GetPtr(), fp, filebodylen); fclose(fp); } diff --git a/LibCmo/CKGlobals.cpp b/LibCmo/CKGlobals.cpp index 2fa5284..2d04431 100644 --- a/LibCmo/CKGlobals.cpp +++ b/LibCmo/CKGlobals.cpp @@ -4,12 +4,10 @@ #include #endif -#include "CKDefines.hpp" #include "CKGlobals.hpp" #include -namespace LibCmo { - +namespace LibCmo::CK2 { void* CKUnPackData(CKINT DestSize, const void* SrcBuffer, CKINT SrcSize) { char* DestBuffer = new(std::nothrow) char[DestSize]; @@ -26,7 +24,7 @@ namespace LibCmo { return DestBuffer; } - CKDWORD LibCmo::CKComputeDataCRC(const void* data, size_t size, CKDWORD PreviousCRC) { + CKDWORD CKComputeDataCRC(const void* data, size_t size, CKDWORD PreviousCRC) { return static_cast(adler32( static_cast(PreviousCRC), reinterpret_cast(data), @@ -34,5 +32,4 @@ namespace LibCmo { )); } - } diff --git a/LibCmo/CKGlobals.hpp b/LibCmo/CKGlobals.hpp index e029e00..4c991e6 100644 --- a/LibCmo/CKGlobals.hpp +++ b/LibCmo/CKGlobals.hpp @@ -1,6 +1,8 @@ #pragma once -namespace LibCmo { +#include "CKDefines.hpp" + +namespace LibCmo::CK2 { void* CKUnPackData(CKINT DestSize, const void* SrcBuffer, CKINT SrcSize); CKDWORD CKComputeDataCRC(const void* data, size_t size, CKDWORD PreviousCRC = 0); diff --git a/LibCmo/CKManagers.hpp b/LibCmo/CKManagers.hpp new file mode 100644 index 0000000..618642b --- /dev/null +++ b/LibCmo/CKManagers.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include "CKDefines.hpp" +#include "CKEnums.hpp" + +namespace LibCmo::CK2::CKManagerImplements { + + class CKBaseManager { + public: + CKBaseManager(); + CKBaseManager(const CKBaseManager&) = delete; + CKBaseManager& operator=(const CKBaseManager&) = delete; + virtual ~CKBaseManager(); + + virtual CKERROR LoadData(CKStateChunk* statechunk, CKFileData::ShallowDocument* doc); + virtual CKStateChunk* SaveData(CKFileData::ShallowDocument* doc); + private: + + }; + + class CKAttributeManager { + public: + CKAttributeManager(); + CKAttributeManager(const CKAttributeManager&) = delete; + CKAttributeManager& operator=(const CKAttributeManager&) = delete; + virtual ~CKAttributeManager(); + + private: + + }; + +} diff --git a/LibCmo/CKMinContext.cpp b/LibCmo/CKMinContext.cpp index d3e758c..12dda7d 100644 --- a/LibCmo/CKMinContext.cpp +++ b/LibCmo/CKMinContext.cpp @@ -1,7 +1,7 @@ #include "VTUtils.hpp" #include "CKMinContext.hpp" -namespace LibCmo { +namespace LibCmo::CK2 { #if defined(LIBCMO_OS_WIN32) static wchar_t g_UniqueFolder[] = L"LibCmo"; @@ -11,53 +11,69 @@ namespace LibCmo { CKMinContext::CKMinContext() : - NameEncoding(), NameEncodingToken(Encoding::ENCODING_TOKEN_DEFAULT), - TempFolder() + m_NameEncoding(), m_NameEncodingToken(EncodingHelper::ENCODING_TOKEN_DEFAULT), + m_TempFolder(), + m_PrintCallback(nullptr) { // preset for temp folder - TempFolder = std::filesystem::temp_directory_path(); - TempFolder /= g_UniqueFolder; - std::filesystem::create_directory(TempFolder); + m_TempFolder = std::filesystem::temp_directory_path(); + m_TempFolder /= g_UniqueFolder; + std::filesystem::create_directory(m_TempFolder); } CKMinContext::~CKMinContext() { } void CKMinContext::Printf(CKSTRING fmt, ...) { + if (m_PrintCallback == nullptr) return; + va_list argptr; va_start(argptr, fmt); - vfprintf(stdout, fmt, argptr); + + std::string result; + int count = std::vsnprintf(nullptr, 0, fmt, argptr); + result.resize(count); + int write_result = std::vsnprintf(result.data(), count, fmt, argptr); + + if (write_result < 0 || write_result > count) return; + va_end(argptr); + + m_PrintCallback(result); } - void CKMinContext::GetUtf8ObjectName(std::string& native_name, std::string& u8_name) { - Encoding::GetUtf8VirtoolsName(native_name, u8_name, this->NameEncodingToken); + void CKMinContext::SetPrintCallback(PrintCallback cb) { + m_PrintCallback = cb; } - void CKMinContext::GetNativeObjectName(std::string& u8_name, std::string& native_name) { - Encoding::GetNativeVirtoolsName(u8_name, native_name, this->NameEncodingToken); + void CKMinContext::GetUtf8String(std::string& native_name, std::string& u8_name) { + EncodingHelper::GetUtf8VirtoolsName(native_name, u8_name, this->m_NameEncodingToken); + } + + void CKMinContext::GetNativeString(std::string& u8_name, std::string& native_name) { + EncodingHelper::GetNativeVirtoolsName(u8_name, native_name, this->m_NameEncodingToken); } void CKMinContext::SetEncoding(CKSTRING encoding) { - this->NameEncoding = encoding; + this->m_NameEncoding = encoding; this->RefetchEncodingToken(); } void CKMinContext::SetTempPath(CKSTRING u8_temp) { - Encoding::SetStdPathFromU8Path(this->TempFolder, u8_temp); + EncodingHelper::SetStdPathFromU8Path(this->m_TempFolder, u8_temp); } FILE* CKMinContext::OpenTempFile(CKSTRING u8_filename, bool is_read) { std::filesystem::path stdfilename; - Encoding::SetStdPathFromU8Path(stdfilename, u8_filename); + EncodingHelper::SetStdPathFromU8Path(stdfilename, u8_filename); - auto realfile = this->TempFolder / stdfilename; - return Encoding::OpenStdPathFile(realfile, is_read); + auto realfile = this->m_TempFolder / stdfilename; + return EncodingHelper::OpenStdPathFile(realfile, is_read); } void CKMinContext::RefetchEncodingToken(void) { - Encoding::DestroyEncodingToken(this->NameEncodingToken); - this->NameEncodingToken = Encoding::CreateEncodingToken(this->NameEncoding); + EncodingHelper::DestroyEncodingToken(this->m_NameEncodingToken); + this->m_NameEncodingToken = EncodingHelper::CreateEncodingToken(this->m_NameEncoding); } } \ No newline at end of file diff --git a/LibCmo/CKMinContext.hpp b/LibCmo/CKMinContext.hpp index 1175545..e40a7ad 100644 --- a/LibCmo/CKMinContext.hpp +++ b/LibCmo/CKMinContext.hpp @@ -1,12 +1,11 @@ #pragma once #include "CKDefines.hpp" -#include "CKEnums.hpp" +#include "CKObjects.hpp" #include "VTEncoding.hpp" -#include "VTObjects.hpp" #include -namespace LibCmo { +namespace LibCmo::CK2 { class CKMinContext { public: @@ -15,13 +14,20 @@ namespace LibCmo { CKMinContext& operator=(const CKMinContext&) = delete; ~CKMinContext(); + using PrintCallback = void (*)(std::string&); void Printf(CKSTRING fmt, ...); + void SetPrintCallback(PrintCallback cb); - ObjsImpl::CKObject* CreateObject(CK_ID id, CK_CLASSID cls, CKSTRING name); - void DestroyObject(ObjsImpl::CKObject* obj); + CKObjectImplements::CKObject* CreateCKObject(CK_ID id, CK_CLASSID cls, CKSTRING name); + CKObjectImplements::CKObject* GetCKObject(CK_ID id); + void DestroyCKObject(CKObjectImplements::CKObject* obj); - void GetUtf8ObjectName(std::string& native_name, std::string& u8_name); - void GetNativeObjectName(std::string& u8_name, std::string& native_name); + CKManagerImplements::CKBaseManager* CreateCKManager(CKGUID guid); + CKManagerImplements::CKBaseManager* GetCKManager(CKGUID guid); + void DestroyCKManager(CKManagerImplements::CKBaseManager* mgr); + + void GetUtf8String(std::string& native_name, std::string& u8_name); + void GetNativeString(std::string& u8_name, std::string& native_name); void SetEncoding(CKSTRING encoding); void SetTempPath(CKSTRING u8_temp); @@ -31,9 +37,10 @@ namespace LibCmo { private: void RefetchEncodingToken(void); - std::string NameEncoding; - Encoding::ENCODING_TOKEN NameEncodingToken; - std::filesystem::path TempFolder; + std::string m_NameEncoding; + EncodingHelper::ENCODING_TOKEN m_NameEncodingToken; + std::filesystem::path m_TempFolder; + PrintCallback m_PrintCallback; }; } diff --git a/LibCmo/CKObjectImplements/CKObject.cpp b/LibCmo/CKObjectImplements/CKObject.cpp new file mode 100644 index 0000000..de4f08f --- /dev/null +++ b/LibCmo/CKObjectImplements/CKObject.cpp @@ -0,0 +1,13 @@ +#include "../CKObjects.hpp" + +namespace LibCmo::CK2::CKObjectImplements { + + CKObject::CKObject() { + + } + + CKObject::~CKObject() { + + } + +} \ No newline at end of file diff --git a/LibCmo/CKObjects.hpp b/LibCmo/CKObjects.hpp new file mode 100644 index 0000000..850f61d --- /dev/null +++ b/LibCmo/CKObjects.hpp @@ -0,0 +1,140 @@ +#pragma once + +#include "CKDefines.hpp" +#include "CKEnums.hpp" + +namespace LibCmo::CK2::CKObjectImplements { + + class CKObject { + public: + CKObject(); + CKObject(const CKObject&) = delete; + CKObject& operator=(const CKObject&) = delete; + virtual ~CKObject(); + + CK_ID GetID(void) { return this->m_ID; } + CKSTRING GetName(void) { return this->m_Name.c_str(); } + void SetName(CKSTRING u8_name) { this->m_Name = u8_name; } + CK_OBJECT_FLAGS GetObjectFlags(void) { return this->m_ObjectFlags; } + void SetObjectFlags(CK_OBJECT_FLAGS flags) { this->m_ObjectFlags = flags; } + + virtual CK_CLASSID GetClassID(void) { return CK_CLASSID::CKCID_OBJECT; } + virtual CKERROR Load(CKStateChunk* chunk, CKFileData::ShallowDocument* doc); + virtual CKStateChunk* Save(CKFileData::ShallowDocument* doc); + protected: + CK_ID m_ID; + std::string m_Name; + CK_OBJECT_FLAGS m_ObjectFlags; + CKMinContext* m_Context; + }; + + class CKSceneObject : public CKObject { + public: + CKSceneObject(); + CKSceneObject(const CKSceneObject&) = delete; + CKSceneObject& operator=(const CKSceneObject&) = delete; + virtual ~CKSceneObject(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_SCENEOBJECT; } + protected: + XBitArray m_Scenes; + }; + + class CKBeObject : public CKSceneObject { + public: + CKBeObject(); + CKBeObject(const CKBeObject&) = delete; + CKBeObject& operator=(const CKBeObject&) = delete; + virtual ~CKBeObject(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEOBJECT; } + protected: + + }; + + class CKGroup : public CKBeObject { + public: + CKGroup(); + CKGroup(const CKGroup&) = delete; + CKGroup& operator=(const CKGroup&) = delete; + virtual ~CKGroup(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_GROUP; } + protected: + + }; + + class CKMesh : public CKBeObject { + public: + CKMesh(); + CKMesh(const CKMesh&) = delete; + CKMesh& operator=(const CKMesh&) = delete; + virtual ~CKMesh(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_MESH; } + protected: + + }; + + class CKTexture : public CKBeObject { + public: + CKTexture(); + CKTexture(const CKTexture&) = delete; + CKTexture& operator=(const CKTexture&) = delete; + virtual ~CKTexture(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_TEXTURE; } + protected: + + }; + + class CKMaterial : public CKBeObject { + public: + CKMaterial(); + CKMaterial(const CKMaterial&) = delete; + CKMaterial& operator=(const CKMaterial&) = delete; + virtual ~CKMaterial(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_MATERIAL; } + protected: + + }; + + class CKRenderObject : public CKBeObject { + public: + CKRenderObject(); + CKRenderObject(const CKRenderObject&) = delete; + CKRenderObject& operator=(const CKRenderObject&) = delete; + ~CKRenderObject(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_RENDEROBJECT; } + protected: + + }; + + class CK3dEntity : public CKBeObject { + public: + CK3dEntity(); + CK3dEntity(const CK3dEntity&) = delete; + CK3dEntity& operator=(const CK3dEntity&) = delete; + virtual ~CK3dEntity(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_3DENTITY; } + protected: + + }; + + class CK3dObject :public CK3dEntity { + public: + CK3dObject(); + CK3dObject(const CK3dObject&) = delete; + CK3dObject& operator=(const CK3dObject&) = delete; + ~CK3dObject(); + + virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_3DOBJECT; } + protected: + + }; + + +} diff --git a/LibCmo/CKStateChunk.cpp b/LibCmo/CKStateChunk.cpp index 3241094..d354d9d 100644 --- a/LibCmo/CKStateChunk.cpp +++ b/LibCmo/CKStateChunk.cpp @@ -1,13 +1,7 @@ #include "VTUtils.hpp" -#if defined(LIBCMO_OS_WIN32) -#define ZLIB_WINAPI -#include -#endif - -#include #include "CKStateChunk.hpp" -namespace LibCmo { +namespace LibCmo::CK2 { #pragma region Ctor Dtor @@ -29,7 +23,7 @@ namespace LibCmo { if (rhs.m_pData != nullptr) { this->m_pData = new(std::nothrow) CKDWORD[rhs.m_DataDwSize]; if (this->m_pData != nullptr) { - memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize); + std::memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize); } } } @@ -50,7 +44,7 @@ namespace LibCmo { if (rhs.m_pData != nullptr) { this->m_pData = new(std::nothrow) CKDWORD[rhs.m_DataDwSize]; if (this->m_pData != nullptr) { - memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize); + std::memcpy(this->m_pData, rhs.m_pData, sizeof(CKDWORD) * rhs.m_DataDwSize); } } this->m_DataDwSize = rhs.m_DataDwSize; @@ -90,7 +84,7 @@ namespace LibCmo { return sizeof(CKDWORD) * this->m_DataDwSize; } - void LibCmo::CKStateChunk::_EnsureWriteSpace(CKDWORD size) { + void CKStateChunk::_EnsureWriteSpace(CKDWORD size) { ; } @@ -129,15 +123,15 @@ namespace LibCmo { this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; if (m_pData == nullptr) return false; - memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); + std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); bufpos += this->m_DataDwSize; } if (!this->m_ObjectList.empty()) { - memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size()); + std::memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size()); bufpos += this->m_ObjectList.size(); } if (!this->m_ChunkList.empty()) { - memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size()); + std::memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size()); bufpos += this->m_ChunkList.size(); } @@ -156,19 +150,19 @@ namespace LibCmo { this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; if (m_pData == nullptr) return false; - memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); + std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); bufpos += this->m_DataDwSize; } if (!this->m_ObjectList.empty()) { - memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size()); + std::memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size()); bufpos += this->m_ObjectList.size(); } if (!this->m_ChunkList.empty()) { - memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size()); + std::memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size()); bufpos += this->m_ChunkList.size(); } if (!this->m_ManagerList.empty()) { - memcpy(this->m_ManagerList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ManagerList.size()); + std::memcpy(this->m_ManagerList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ManagerList.size()); bufpos += this->m_ManagerList.size(); } @@ -193,7 +187,7 @@ namespace LibCmo { this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; if (m_pData == nullptr) return false; - memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); + std::memcpy(this->m_pData, dwbuf + bufpos, sizeof(CKDWORD) * this->m_DataDwSize); bufpos += this->m_DataDwSize; } if (EnumsHelper::FlagEnumHas(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_FILE)) { @@ -203,19 +197,19 @@ namespace LibCmo { if (EnumsHelper::FlagEnumHas(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_IDS)) { this->m_ObjectList.resize(dwbuf[bufpos]); bufpos += 1u; - memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size()); + std::memcpy(this->m_ObjectList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ObjectList.size()); bufpos += this->m_ObjectList.size(); } if (EnumsHelper::FlagEnumHas(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_CHN)) { this->m_ChunkList.resize(dwbuf[bufpos]); bufpos += 1u; - memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size()); + std::memcpy(this->m_ChunkList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ChunkList.size()); bufpos += this->m_ChunkList.size(); } if (EnumsHelper::FlagEnumHas(options, CK_STATECHUNK_CHUNKOPTIONS::CHNK_OPTION_MAN)) { this->m_ManagerList.resize(dwbuf[bufpos]); bufpos += 1u; - memcpy(this->m_ManagerList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ManagerList.size()); + std::memcpy(this->m_ManagerList.data(), dwbuf + bufpos, sizeof(CKDWORD) * this->m_ManagerList.size()); bufpos += this->m_ManagerList.size(); } @@ -257,7 +251,7 @@ namespace LibCmo { // this->m_pData = nullptr; // this->m_pData = new(std::nothrow) CKDWORD[this->m_DataDwSize]; // if (this->m_pData != nullptr) { - // memcpy(this->m_pData, buffer, this->m_DataDwSize * sizeof(CKDWORD)); + // std::memcpy(this->m_pData, buffer, this->m_DataDwSize * sizeof(CKDWORD)); // } // } // delete[] buffer; diff --git a/LibCmo/CKStateChunk.hpp b/LibCmo/CKStateChunk.hpp index 01d017f..1cc08bd 100644 --- a/LibCmo/CKStateChunk.hpp +++ b/LibCmo/CKStateChunk.hpp @@ -3,7 +3,7 @@ #include "CKDefines.hpp" #include "CKEnums.hpp" -namespace LibCmo { +namespace LibCmo::CK2 { class CKStateChunk { public: diff --git a/LibCmo/LibCmo.vcxproj b/LibCmo/LibCmo.vcxproj index 8fa9fb9..5a94dd4 100644 --- a/LibCmo/LibCmo.vcxproj +++ b/LibCmo/LibCmo.vcxproj @@ -103,6 +103,7 @@ $(ZLIB_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console @@ -121,6 +122,7 @@ $(ZLIB_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console @@ -139,6 +141,7 @@ $(ZLIB_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console @@ -159,6 +162,7 @@ $(ZLIB_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console @@ -175,7 +179,7 @@ - + @@ -187,11 +191,11 @@ + - - + diff --git a/LibCmo/LibCmo.vcxproj.filters b/LibCmo/LibCmo.vcxproj.filters index 4649f45..abfd5a5 100644 --- a/LibCmo/LibCmo.vcxproj.filters +++ b/LibCmo/LibCmo.vcxproj.filters @@ -13,9 +13,12 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - + {a8cd2188-b552-478c-9801-a6286b3d48a0} + + {784282d9-4adb-40ca-bbac-902c74e9a2e5} + @@ -33,8 +36,8 @@ Sources - - Sources\ObjsImpl + + Sources\CKObjectImplements Sources @@ -56,7 +59,7 @@ Headers - + Headers @@ -80,7 +83,7 @@ Headers - + Headers diff --git a/LibCmo/ObjsImpl/CKObject.cpp b/LibCmo/ObjsImpl/CKObject.cpp deleted file mode 100644 index e8bd577..0000000 --- a/LibCmo/ObjsImpl/CKObject.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "../VTObjects.hpp" - -namespace LibCmo { - namespace ObjsImpl { - - CKObject::CKObject() { - - } - - CKObject::~CKObject() { - - } - - } -} \ No newline at end of file diff --git a/LibCmo/VTEncoding.cpp b/LibCmo/VTEncoding.cpp index f0319d5..4c45050 100644 --- a/LibCmo/VTEncoding.cpp +++ b/LibCmo/VTEncoding.cpp @@ -1,78 +1,77 @@ #include "VTEncoding.hpp" -namespace LibCmo { - namespace Encoding { +namespace LibCmo::EncodingHelper { #pragma region assist functions #if defined(LIBCMO_OS_WIN32) #define LIBCMO_STR_EQUAL(a, b) strcmp(reinterpret_cast(a), reinterpret_cast(b)) == 0 - bool GetWindowsCodePage(const char* u8_encoding_spec, UINT* result) { - if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_ACP")) *result = CP_ACP; - else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_MACCP")) *result = CP_MACCP; - else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_OEMCP")) *result = CP_OEMCP; - else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_THREAD_ACPP")) *result = CP_THREAD_ACP; - else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_UTF8")) *result = CP_UTF8; - else { - char* pend = nullptr; - errno = 0; - uint64_t v = std::strtoull(u8_encoding_spec, &pend, 10); + bool GetWindowsCodePage(const char* u8_encoding_spec, UINT* result) { + if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_ACP")) *result = CP_ACP; + else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_MACCP")) *result = CP_MACCP; + else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_OEMCP")) *result = CP_OEMCP; + else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_THREAD_ACPP")) *result = CP_THREAD_ACP; + else if (LIBCMO_STR_EQUAL(u8_encoding_spec, u8"CP_UTF8")) *result = CP_UTF8; + else { + char* pend = nullptr; + errno = 0; + uint64_t v = std::strtoull(u8_encoding_spec, &pend, 10); - if (pend == u8_encoding_spec || errno == ERANGE) return false; - *result = static_cast(v); - } - return true; + if (pend == u8_encoding_spec || errno == ERANGE) return false; + *result = static_cast(v); } + return true; + } #undef LIBCMO_STR_EQUAL - bool WcharToChar(const wchar_t* src, std::string& dest, UINT codepage) { - int count, write_result; + bool WcharToChar(const wchar_t* src, std::string& dest, UINT codepage) { + int count, write_result; - //converter to CHAR - count = WideCharToMultiByte(CP_UTF8, 0, src, -1, NULL, 0, NULL, NULL); - if (count <= 0) return false; + //converter to CHAR + count = WideCharToMultiByte(CP_UTF8, 0, src, -1, NULL, 0, NULL, NULL); + if (count <= 0) return false; - dest.resize(count); - write_result = WideCharToMultiByte(CP_UTF8, 0, src, -1, dest.data(), count, NULL, NULL); - if (write_result <= 0) return false; + dest.resize(count); + write_result = WideCharToMultiByte(CP_UTF8, 0, src, -1, dest.data(), count, NULL, NULL); + if (write_result <= 0) return false; - return true; - } - bool WcharToChar(std::wstring& src, std::string& dest, UINT codepage) { - return WcharToChar(src.c_str(), dest, codepage); - } + return true; + } + bool WcharToChar(std::wstring& src, std::string& dest, UINT codepage) { + return WcharToChar(src.c_str(), dest, codepage); + } - bool CharToWchar(const char* src, std::wstring& dest, UINT codepage) { - int wcount, write_result; + bool CharToWchar(const char* src, std::wstring& dest, UINT codepage) { + int wcount, write_result; - // convert to WCHAR - wcount = MultiByteToWideChar(codepage, 0, src, -1, NULL, 0); - if (wcount <= 0) return false; + // convert to WCHAR + wcount = MultiByteToWideChar(codepage, 0, src, -1, NULL, 0); + if (wcount <= 0) return false; - dest.resize(wcount); - write_result = MultiByteToWideChar(CP_UTF8, 0, src, -1, dest.data(), wcount); - if (write_result <= 0) return false; + dest.resize(wcount); + write_result = MultiByteToWideChar(CP_UTF8, 0, src, -1, dest.data(), wcount); + if (write_result <= 0) return false; - return true; - } - bool CharToWchar(std::string& src, std::wstring& dest, UINT codepage) { - return CharToWchar(src.c_str(), dest, codepage); - } + return true; + } + bool CharToWchar(std::string& src, std::wstring& dest, UINT codepage) { + return CharToWchar(src.c_str(), dest, codepage); + } - bool CharToChar(const char* src, std::string& dest, UINT src_codepage, UINT dest_codepage) { - std::wstring intermediary; - if (!CharToWchar(src, intermediary, src_codepage)) return false; - if (!WcharToChar(intermediary, dest, dest_codepage)) return false; - return true; - } - bool CharToChar(std::string& src, std::string& dest, UINT src_codepage, UINT dest_codepage) { - return CharToChar(src.c_str(), dest, src_codepage, dest_codepage); - } + bool CharToChar(const char* src, std::string& dest, UINT src_codepage, UINT dest_codepage) { + std::wstring intermediary; + if (!CharToWchar(src, intermediary, src_codepage)) return false; + if (!WcharToChar(intermediary, dest, dest_codepage)) return false; + return true; + } + bool CharToChar(std::string& src, std::string& dest, UINT src_codepage, UINT dest_codepage) { + return CharToChar(src.c_str(), dest, src_codepage, dest_codepage); + } #else - //todo: linux implementation + //todo: linux implementation #endif @@ -82,71 +81,70 @@ namespace LibCmo { #if defined(LIBCMO_OS_WIN32) - const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT = nullptr; + const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT = nullptr; - ENCODING_TOKEN CreateEncodingToken(std::string& token_string) { - ENCODING_TOKEN token = new(std::nothrow) UINT(); - if (token == nullptr) return ENCODING_TOKEN_DEFAULT; + ENCODING_TOKEN CreateEncodingToken(std::string& token_string) { + ENCODING_TOKEN token = new(std::nothrow) UINT(); + if (token == nullptr) return ENCODING_TOKEN_DEFAULT; - if (!GetWindowsCodePage(token_string.c_str(), token)) { - *token = CP_ACP; - } - return token; + if (!GetWindowsCodePage(token_string.c_str(), token)) { + *token = CP_ACP; } - void DestroyEncodingToken(ENCODING_TOKEN token) { - if (token != ENCODING_TOKEN_DEFAULT) { - delete token; - } + return token; + } + void DestroyEncodingToken(ENCODING_TOKEN token) { + if (token != ENCODING_TOKEN_DEFAULT) { + delete token; + } + } + + void GetUtf8VirtoolsName(std::string& native_name, std::string& u8_name, ENCODING_TOKEN token) { + if (token == ENCODING_TOKEN_DEFAULT) { + u8_name = native_name.c_str(); + return; } - void GetUtf8VirtoolsName(std::string& native_name, std::string& u8_name, ENCODING_TOKEN token) { - if (token == ENCODING_TOKEN_DEFAULT) { - u8_name = native_name.c_str(); - return; - } + // convert with fallback + if (!CharToChar(native_name, u8_name, *token, CP_UTF8)) { + u8_name = native_name.c_str(); + } + } - // convert with fallback - if (!CharToChar(native_name, u8_name, *token, CP_UTF8)) { - u8_name = native_name.c_str(); - } + void GetNativeVirtoolsName(std::string& u8_name, std::string& native_name, ENCODING_TOKEN token) { + if (token == ENCODING_TOKEN_DEFAULT) { + native_name = u8_name.c_str(); + return; } - void GetNativeVirtoolsName(std::string& u8_name, std::string& native_name, ENCODING_TOKEN token) { - if (token == ENCODING_TOKEN_DEFAULT) { - native_name = u8_name.c_str(); - return; - } - - // convert with fallback - if (!CharToChar(u8_name, native_name, CP_UTF8, *token)) { - native_name = u8_name.c_str(); - } + // convert with fallback + if (!CharToChar(u8_name, native_name, CP_UTF8, *token)) { + native_name = u8_name.c_str(); } + } - void SetStdPathFromU8Path(std::filesystem::path& stdpath, const char* u8_path) { - std::wstring intermediary; - if (CharToWchar(u8_path, intermediary, CP_UTF8)) { - stdpath = intermediary.c_str(); - } else { - // fallback - stdpath = u8_path; - } + void SetStdPathFromU8Path(std::filesystem::path& stdpath, const char* u8_path) { + std::wstring intermediary; + if (CharToWchar(u8_path, intermediary, CP_UTF8)) { + stdpath = intermediary.c_str(); + } else { + // fallback + stdpath = u8_path; } + } - FILE* OpenStdPathFile(std::filesystem::path& u8_filepath, bool is_read) { - return _wfopen(u8_filepath.wstring().c_str(), is_read ? L"rb" : L"wb"); - } + FILE* OpenStdPathFile(std::filesystem::path& u8_filepath, bool is_read) { + return _wfopen(u8_filepath.wstring().c_str(), is_read ? L"rb" : L"wb"); + } #else - const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT = nullptr; + const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT = nullptr; - //todo: linux implementation + //todo: linux implementation #endif #pragma endregion - } } diff --git a/LibCmo/VTEncoding.hpp b/LibCmo/VTEncoding.hpp index 9665cd3..1709f47 100644 --- a/LibCmo/VTEncoding.hpp +++ b/LibCmo/VTEncoding.hpp @@ -11,23 +11,22 @@ #include #endif -namespace LibCmo { - namespace Encoding { +namespace LibCmo::EncodingHelper { #pragma region assist functions #if defined(LIBCMO_OS_WIN32) - bool GetWindowsCodePage(const char* u8_encoding_spec, UINT* result); + bool GetWindowsCodePage(const char* u8_encoding_spec, UINT* result); - bool WcharToChar(const wchar_t* src, std::string& dest, UINT codepage); - bool WcharToChar(std::wstring& src, std::string& dest, UINT codepage); + bool WcharToChar(const wchar_t* src, std::string& dest, UINT codepage); + bool WcharToChar(std::wstring& src, std::string& dest, UINT codepage); - bool CharToWchar(const char* src, std::wstring& dest, UINT codepage); - bool CharToWchar(std::string& src, std::wstring& dest, UINT codepage); + bool CharToWchar(const char* src, std::wstring& dest, UINT codepage); + bool CharToWchar(std::string& src, std::wstring& dest, UINT codepage); - bool CharToChar(const char* src, std::string& dest, UINT src_codepage, UINT dest_codepage); - bool CharToChar(std::string& src, std::string& dest, UINT src_codepage, UINT dest_codepage); + bool CharToChar(const char* src, std::string& dest, UINT src_codepage, UINT dest_codepage); + bool CharToChar(std::string& src, std::string& dest, UINT src_codepage, UINT dest_codepage); #else #error NO IMPLEMENTATION FOR LINUX ENCODING! @@ -39,35 +38,34 @@ namespace LibCmo { #if defined(LIBCMO_OS_WIN32) - /// - /// Token is the ticket for using encoding functions. - /// It should be created by "GenerateEncodingToken" and free by "DestroyEncodingToken". - /// - using ENCODING_TOKEN = UINT*; - extern const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT; + /// + /// Token is the ticket for using encoding functions. + /// It should be created by "GenerateEncodingToken" and free by "DestroyEncodingToken". + /// + using ENCODING_TOKEN = UINT*; + extern const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT; - ENCODING_TOKEN CreateEncodingToken(std::string& token_string); - void DestroyEncodingToken(ENCODING_TOKEN token); + ENCODING_TOKEN CreateEncodingToken(std::string& token_string); + void DestroyEncodingToken(ENCODING_TOKEN token); - void GetUtf8VirtoolsName(std::string& native_name, std::string& u8_name, ENCODING_TOKEN token); - void GetNativeVirtoolsName(std::string& u8_name, std::string& native_name, ENCODING_TOKEN token); + void GetUtf8VirtoolsName(std::string& native_name, std::string& u8_name, ENCODING_TOKEN token); + void GetNativeVirtoolsName(std::string& u8_name, std::string& native_name, ENCODING_TOKEN token); - void SetStdPathFromU8Path(std::filesystem::path& stdpath, const char* u8_path); - FILE* OpenStdPathFile(std::filesystem::path& u8_filepath, bool is_read); + void SetStdPathFromU8Path(std::filesystem::path& stdpath, const char* u8_path); + FILE* OpenStdPathFile(std::filesystem::path& u8_filepath, bool is_read); #else - /// - /// Token is the ticket for using encoding functions. - /// It should be created by "GenerateEncodingToken" and free by "DestroyEncodingToken". - /// - using ENCODING_TOKEN = char*; - extern const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT; + /// + /// Token is the ticket for using encoding functions. + /// It should be created by "GenerateEncodingToken" and free by "DestroyEncodingToken". + /// + using ENCODING_TOKEN = char*; + extern const ENCODING_TOKEN ENCODING_TOKEN_DEFAULT; #error NO IMPLEMENTATION FOR LINUX ENCODING! #endif #pragma endregion - } } diff --git a/LibCmo/VTManagers.hpp b/LibCmo/VTManagers.hpp deleted file mode 100644 index e6cd65e..0000000 --- a/LibCmo/VTManagers.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "CKDefines.hpp" -#include "CKEnums.hpp" - -namespace LibCmo { - - // forward decl to rm recursive reference - class CKMinContext; - class CKStateChunk; - - namespace MgrsImpl { - - class CKBaseManager { - public: - CKBaseManager(); - CKBaseManager(const CKBaseManager&) = delete; - CKBaseManager& operator=(const CKBaseManager&) = delete; - virtual ~CKBaseManager(); - - private: - - }; - - } -} diff --git a/LibCmo/VTObjects.hpp b/LibCmo/VTObjects.hpp deleted file mode 100644 index 4d69abd..0000000 --- a/LibCmo/VTObjects.hpp +++ /dev/null @@ -1,126 +0,0 @@ -#pragma once - -#include "CKDefines.hpp" -#include "CKEnums.hpp" - -namespace LibCmo { - - // forward decl to rm recursive reference - class CKMinContext; - class CKStateChunk; - - namespace ObjsImpl { - - class CKObject { - public: - CKObject(); - CKObject(const CKObject&) = delete; - CKObject& operator=(const CKObject&) = delete; - virtual ~CKObject(); - - private: - - }; - - class CKSceneObject : public CKObject { - public: - CKSceneObject(); - CKSceneObject(const CKSceneObject&) = delete; - CKSceneObject& operator=(const CKSceneObject&) = delete; - virtual ~CKSceneObject(); - - private: - - }; - - class CKBeObject : public CKSceneObject { - public: - CKBeObject(); - CKBeObject(const CKBeObject&) = delete; - CKBeObject& operator=(const CKBeObject&) = delete; - virtual ~CKBeObject(); - - private: - - }; - - class CKGroup : public CKBeObject { - public: - CKGroup(); - CKGroup(const CKGroup&) = delete; - CKGroup& operator=(const CKGroup&) = delete; - virtual ~CKGroup(); - - private: - - }; - - class CKMesh : public CKBeObject { - public: - CKMesh(); - CKMesh(const CKMesh&) = delete; - CKMesh& operator=(const CKMesh&) = delete; - virtual ~CKMesh(); - - private: - - }; - - class CKTexture : public CKBeObject { - public: - CKTexture(); - CKTexture(const CKTexture&) = delete; - CKTexture& operator=(const CKTexture&) = delete; - virtual ~CKTexture(); - - private: - - }; - - class CKMaterial : public CKBeObject { - public: - CKMaterial(); - CKMaterial(const CKMaterial&) = delete; - CKMaterial& operator=(const CKMaterial&) = delete; - virtual ~CKMaterial(); - - private: - - }; - - class CKRenderObject : public CKBeObject { - public: - CKRenderObject(); - CKRenderObject(const CKRenderObject&) = delete; - CKRenderObject& operator=(const CKRenderObject&) = delete; - ~CKRenderObject(); - - private: - - }; - - class CK3dEntity : public CKBeObject { - public: - CK3dEntity(); - CK3dEntity(const CK3dEntity&) = delete; - CK3dEntity& operator=(const CK3dEntity&) = delete; - virtual ~CK3dEntity(); - - private: - - }; - - class CK3dObject :public CK3dEntity { - public: - CK3dObject(); - CK3dObject(const CK3dObject&) = delete; - CK3dObject& operator=(const CK3dObject&) = delete; - ~CK3dObject(); - - private: - - }; - - - } -} diff --git a/LibCmo/VTUtils.cpp b/LibCmo/VTUtils.cpp index 0ed8ddf..8eb2035 100644 --- a/LibCmo/VTUtils.cpp +++ b/LibCmo/VTUtils.cpp @@ -1,8 +1,7 @@ #include "VTUtils.hpp" namespace LibCmo { - namespace Utils { - + namespace StreamHelper { static constexpr const size_t CHUNK_SIZE = 10240; void CopyStream(const void* src, FILE* dest, size_t len) { diff --git a/LibCmo/VTUtils.hpp b/LibCmo/VTUtils.hpp index 3097924..cd76466 100644 --- a/LibCmo/VTUtils.hpp +++ b/LibCmo/VTUtils.hpp @@ -42,9 +42,31 @@ #endif #include +#include +#include +#include +#include namespace LibCmo { - namespace Utils { + + namespace EnumsHelper { + template + inline TEnum FlagEnumAdd(TEnum e, ...) { + TEnum result = e; + va_list argptr; + va_start(argptr, e); + result = static_cast(static_cast>(result) | static_cast>(va_arg(argptr, TEnum))); + va_end(argptr); + return result; + } + + template + inline bool FlagEnumHas(TEnum e, TEnum probe) { + return static_cast(static_cast>(e) & static_cast>(probe)); + } + } + + namespace StreamHelper { void CopyStream(const void* src, FILE* dest, size_t len); void CopyStream(FILE* src, void* dest, size_t len); diff --git a/LibCmo/VxMemoryMappedFile.cpp b/LibCmo/VxMemoryMappedFile.cpp index 7c3a34b..f9c9ab6 100644 --- a/LibCmo/VxMemoryMappedFile.cpp +++ b/LibCmo/VxMemoryMappedFile.cpp @@ -1,7 +1,7 @@ #include "VxMemoryMappedFile.hpp" #include "VTEncoding.hpp" -namespace LibCmo { +namespace LibCmo::VxMath { VxMemoryMappedFile::VxMemoryMappedFile(const char* u8_filepath) : // init members @@ -16,7 +16,7 @@ namespace LibCmo { // save file path #if defined(LIBCMO_OS_WIN32) - Encoding::SetStdPathFromU8Path(m_szFilePath, u8_filepath); + EncodingHelper::SetStdPathFromU8Path(m_szFilePath, u8_filepath); #else this->m_szFilePath = u8_filepath; #endif diff --git a/LibCmo/VxMemoryMappedFile.hpp b/LibCmo/VxMemoryMappedFile.hpp index 29437c7..a26970b 100644 --- a/LibCmo/VxMemoryMappedFile.hpp +++ b/LibCmo/VxMemoryMappedFile.hpp @@ -10,7 +10,7 @@ #include #include -namespace LibCmo { +namespace LibCmo::VxMath { class VxMemoryMappedFile { private: diff --git a/Unvirt/AccessibleValue.cpp b/Unvirt/AccessibleValue.cpp index 21dca52..131c492 100644 --- a/Unvirt/AccessibleValue.cpp +++ b/Unvirt/AccessibleValue.cpp @@ -11,40 +11,40 @@ namespace Unvirt { const char c_InvalidEnumName[] = "[undefined]"; namespace EnumDesc { - const EnumDescPairArray CK_FILE_WRITEMODE{ - { LibCmo::CK_FILE_WRITEMODE::CKFILE_UNCOMPRESSED, "CKFILE_UNCOMPRESSED" }, - { LibCmo::CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD, "CKFILE_CHUNKCOMPRESSED_OLD" }, - { LibCmo::CK_FILE_WRITEMODE::CKFILE_EXTERNALTEXTURES_OLD, "CKFILE_EXTERNALTEXTURES_OLD" }, - { LibCmo::CK_FILE_WRITEMODE::CKFILE_FORVIEWER, "CKFILE_FORVIEWER" }, - { LibCmo::CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED, "CKFILE_WHOLECOMPRESSED" } + const EnumDescPairArray CK_FILE_WRITEMODE{ + { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_UNCOMPRESSED, "CKFILE_UNCOMPRESSED" }, + { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_CHUNKCOMPRESSED_OLD, "CKFILE_CHUNKCOMPRESSED_OLD" }, + { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_EXTERNALTEXTURES_OLD, "CKFILE_EXTERNALTEXTURES_OLD" }, + { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_FORVIEWER, "CKFILE_FORVIEWER" }, + { LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED, "CKFILE_WHOLECOMPRESSED" } }; - const EnumDescPairArray CK_LOAD_FLAGS{ - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_ANIMATION, "CK_LOAD_ANIMATION" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_GEOMETRY, "CK_LOAD_GEOMETRY" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_DEFAULT, "CK_LOAD_DEFAULT" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_ASCHARACTER, "CK_LOAD_ASCHARACTER" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_DODIALOG, "CK_LOAD_DODIALOG" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_AS_DYNAMIC_OBJECT, "CK_LOAD_AS_DYNAMIC_OBJECT" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_AUTOMATICMODE, "CK_LOAD_AUTOMATICMODE" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_CHECKDUPLICATES, "CK_LOAD_CHECKDUPLICATES" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_CHECKDEPENDENCIES, "CK_LOAD_CHECKDEPENDENCIES" }, - { LibCmo::CK_LOAD_FLAGS::CK_LOAD_ONLYBEHAVIORS, "CK_LOAD_ONLYBEHAVIORS" } + const EnumDescPairArray CK_LOAD_FLAGS{ + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ANIMATION, "CK_LOAD_ANIMATION" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_GEOMETRY, "CK_LOAD_GEOMETRY" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_DEFAULT, "CK_LOAD_DEFAULT" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ASCHARACTER, "CK_LOAD_ASCHARACTER" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_DODIALOG, "CK_LOAD_DODIALOG" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_AS_DYNAMIC_OBJECT, "CK_LOAD_AS_DYNAMIC_OBJECT" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_AUTOMATICMODE, "CK_LOAD_AUTOMATICMODE" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_CHECKDUPLICATES, "CK_LOAD_CHECKDUPLICATES" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_CHECKDEPENDENCIES, "CK_LOAD_CHECKDEPENDENCIES" }, + { LibCmo::CK2::CK_LOAD_FLAGS::CK_LOAD_ONLYBEHAVIORS, "CK_LOAD_ONLYBEHAVIORS" } }; - const EnumDescPairArray CK_FO_OPTIONS{ - { LibCmo::CK_FO_OPTIONS::CK_FO_DEFAULT, "CK_FO_DEFAULT" }, - { LibCmo::CK_FO_OPTIONS::CK_FO_RENAMEOBJECT, "CK_FO_RENAMEOBJECT" }, - { LibCmo::CK_FO_OPTIONS::CK_FO_REPLACEOBJECT, "CK_FO_REPLACEOBJECT" }, - { LibCmo::CK_FO_OPTIONS::CK_FO_DONTLOADOBJECT, "CK_FO_DONTLOADOBJECT" } + const EnumDescPairArray CK_FO_OPTIONS{ + { LibCmo::CK2::CK_FO_OPTIONS::CK_FO_DEFAULT, "CK_FO_DEFAULT" }, + { LibCmo::CK2::CK_FO_OPTIONS::CK_FO_RENAMEOBJECT, "CK_FO_RENAMEOBJECT" }, + { LibCmo::CK2::CK_FO_OPTIONS::CK_FO_REPLACEOBJECT, "CK_FO_REPLACEOBJECT" }, + { LibCmo::CK2::CK_FO_OPTIONS::CK_FO_DONTLOADOBJECT, "CK_FO_DONTLOADOBJECT" } }; - const EnumDescPairArray CK_PLUGIN_TYPE{ - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_BITMAP_READER, "CKPLUGIN_BITMAP_READER" }, - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_SOUND_READER, "CKPLUGIN_SOUND_READER" }, - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_MODEL_READER, "CKPLUGIN_MODEL_READER" }, - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_MANAGER_DLL, "CKPLUGIN_MANAGER_DLL" }, - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_BEHAVIOR_DLL, "CKPLUGIN_BEHAVIOR_DLL" }, - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_RENDERENGINE_DLL, "CKPLUGIN_RENDERENGINE_DLL" }, - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_MOVIE_READER, "CKPLUGIN_MOVIE_READER" }, - { LibCmo::CK_PLUGIN_TYPE::CKPLUGIN_EXTENSION_DLL, "CKPLUGIN_EXTENSION_DLL" } + const EnumDescPairArray CK_PLUGIN_TYPE{ + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_BITMAP_READER, "CKPLUGIN_BITMAP_READER" }, + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_SOUND_READER, "CKPLUGIN_SOUND_READER" }, + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MODEL_READER, "CKPLUGIN_MODEL_READER" }, + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MANAGER_DLL, "CKPLUGIN_MANAGER_DLL" }, + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_BEHAVIOR_DLL, "CKPLUGIN_BEHAVIOR_DLL" }, + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_RENDERENGINE_DLL, "CKPLUGIN_RENDERENGINE_DLL" }, + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_MOVIE_READER, "CKPLUGIN_MOVIE_READER" }, + { LibCmo::CK2::CK_PLUGIN_TYPE::CKPLUGIN_EXTENSION_DLL, "CKPLUGIN_EXTENSION_DLL" } }; } @@ -61,62 +61,62 @@ namespace Unvirt { return nullptr; } - static const std::vector>> _CkErrorData{ - { LibCmo::CKERROR::CKERR_OK, { "CKERR_OK", "Operation successful" } }, - { LibCmo::CKERROR::CKERR_INVALIDPARAMETER, {"CKERR_INVALIDPARAMETER", "One of the parameter passed to the function was invalid"} }, - { LibCmo::CKERROR::CKERR_INVALIDPARAMETERTYPE, {"CKERR_INVALIDPARAMETERTYPE", "One of the parameter passed to the function was invalid"} }, - { LibCmo::CKERROR::CKERR_INVALIDSIZE, {"CKERR_INVALIDSIZE", "The parameter size was invalid"} }, - { LibCmo::CKERROR::CKERR_INVALIDOPERATION, {"CKERR_INVALIDOPERATION", "The operation type didn't exist"} }, - { LibCmo::CKERROR::CKERR_OPERATIONNOTIMPLEMENTED, {"CKERR_OPERATIONNOTIMPLEMENTED", "The function used to execute the operation is not yet implemented"} }, - { LibCmo::CKERROR::CKERR_OUTOFMEMORY, {"CKERR_OUTOFMEMORY", "There was not enough memory to perform the action"} }, - { LibCmo::CKERROR::CKERR_NOTIMPLEMENTED, {"CKERR_NOTIMPLEMENTED", "The function is not yet implemented"} }, - { LibCmo::CKERROR::CKERR_NOTFOUND, {"CKERR_NOTFOUND", "There was an attempt to remove something not present"} }, - { LibCmo::CKERROR::CKERR_NOLEVEL, {"CKERR_NOLEVEL", "There is no level currently created"} }, - { LibCmo::CKERROR::CKERR_CANCREATERENDERCONTEXT, {"CKERR_CANCREATERENDERCONTEXT", ""} }, - { LibCmo::CKERROR::CKERR_NOTIFICATIONNOTHANDLED, {"CKERR_NOTIFICATIONNOTHANDLED", "The notification message was not used"} }, - { LibCmo::CKERROR::CKERR_ALREADYPRESENT, {"CKERR_ALREADYPRESENT", "Attempt to add an item that was already present"} }, - { LibCmo::CKERROR::CKERR_INVALIDRENDERCONTEXT, {"CKERR_INVALIDRENDERCONTEXT", "the render context is not valid"} }, - { LibCmo::CKERROR::CKERR_RENDERCONTEXTINACTIVE, {"CKERR_RENDERCONTEXTINACTIVE", "the render context is not activated for rendering"} }, - { LibCmo::CKERROR::CKERR_NOLOADPLUGINS, {"CKERR_NOLOADPLUGINS", "there was no plugins to load this kind of file"} }, - { LibCmo::CKERROR::CKERR_NOSAVEPLUGINS, {"CKERR_NOSAVEPLUGINS", "there was no plugins to save this kind of file"} }, - { LibCmo::CKERROR::CKERR_INVALIDFILE, {"CKERR_INVALIDFILE", "attempt to load an invalid file"} }, - { LibCmo::CKERROR::CKERR_INVALIDPLUGIN, {"CKERR_INVALIDPLUGIN", "attempt to load with an invalid plugin"} }, - { LibCmo::CKERROR::CKERR_NOTINITIALIZED, {"CKERR_NOTINITIALIZED", "attempt use an object that wasnt initialized"} }, - { LibCmo::CKERROR::CKERR_INVALIDMESSAGE, {"CKERR_INVALIDMESSAGE", "attempt use a message type that wasn't registred"} }, - { LibCmo::CKERROR::CKERR_INVALIDPROTOTYPE, {"CKERR_INVALIDPROTOTYPE", "attempt use an invalid prototype"} }, - { LibCmo::CKERROR::CKERR_NODLLFOUND, {"CKERR_NODLLFOUND", "No dll file found in the parse directory"} }, - { LibCmo::CKERROR::CKERR_ALREADYREGISTREDDLL, {"CKERR_ALREADYREGISTREDDLL", "this dll has already been registred"} }, - { LibCmo::CKERROR::CKERR_INVALIDDLL, {"CKERR_INVALIDDLL", "this dll does not contain information to create the prototype"} }, - { LibCmo::CKERROR::CKERR_INVALIDOBJECT, {"CKERR_INVALIDOBJECT", "Invalid Object (attempt to Get an object from an invalid ID)"} }, - { LibCmo::CKERROR::CKERR_INVALIDCONDSOLEWINDOW, {"CKERR_INVALIDCONDSOLEWINDOW", "Invalid window was provided as console window"} }, - { LibCmo::CKERROR::CKERR_INVALIDKINEMATICCHAIN, {"CKERR_INVALIDKINEMATICCHAIN", "Invalid kinematic chain ( end and start effector may not be part of the same hierarchy )"} }, - { LibCmo::CKERROR::CKERR_NOKEYBOARD, {"CKERR_NOKEYBOARD", "Keyboard not attached or not working properly"} }, - { LibCmo::CKERROR::CKERR_NOMOUSE, {"CKERR_NOMOUSE", "Mouse not attached or not working properly"} }, - { LibCmo::CKERROR::CKERR_NOJOYSTICK, {"CKERR_NOJOYSTICK", "Joystick not attached or not working properly"} }, - { LibCmo::CKERROR::CKERR_INCOMPATIBLEPARAMETERS, {"CKERR_INCOMPATIBLEPARAMETERS", "Try to link imcompatible Parameters"} }, - { LibCmo::CKERROR::CKERR_NORENDERENGINE, {"CKERR_NORENDERENGINE", "There is no render engine dll"} }, - { LibCmo::CKERROR::CKERR_NOCURRENTLEVEL, {"CKERR_NOCURRENTLEVEL", "There is no current level (use CKSetCurrentLevel )"} }, - { LibCmo::CKERROR::CKERR_SOUNDDISABLED, {"CKERR_SOUNDDISABLED", "Sound Management has been disabled"} }, - { LibCmo::CKERROR::CKERR_DINPUTDISABLED, {"CKERR_DINPUTDISABLED", "DirectInput Management has been disabled"} }, - { LibCmo::CKERROR::CKERR_INVALIDGUID, {"CKERR_INVALIDGUID", "Guid is already in use or invalid"} }, - { LibCmo::CKERROR::CKERR_NOTENOUGHDISKPLACE, {"CKERR_NOTENOUGHDISKPLACE", "There was no more free space on disk when trying to save a file"} }, - { LibCmo::CKERROR::CKERR_CANTWRITETOFILE, {"CKERR_CANTWRITETOFILE", "Impossible to write to file (write-protection ?)"} }, - { LibCmo::CKERROR::CKERR_BEHAVIORADDDENIEDBYCB, {"CKERR_BEHAVIORADDDENIEDBYCB", "The behavior cannnot be added to this entity"} }, - { LibCmo::CKERROR::CKERR_INCOMPATIBLECLASSID, {"CKERR_INCOMPATIBLECLASSID", "The behavior cannnot be added to this entity"} }, - { LibCmo::CKERROR::CKERR_MANAGERALREADYEXISTS, {"CKERR_MANAGERALREADYEXISTS", "A manager was registered more than once"} }, - { LibCmo::CKERROR::CKERR_PAUSED, {"CKERR_PAUSED", "CKprocess or TimeManager process while CK is paused will fail"} }, - { LibCmo::CKERROR::CKERR_PLUGINSMISSING, {"CKERR_PLUGINSMISSING", "Some plugins were missing whileloading a file"} }, - { LibCmo::CKERROR::CKERR_OBSOLETEVIRTOOLS, {"CKERR_OBSOLETEVIRTOOLS", "Virtools version too old to load this file"} }, - { LibCmo::CKERROR::CKERR_FILECRCERROR, {"CKERR_FILECRCERROR", "CRC Error while loading file"} }, - { LibCmo::CKERROR::CKERR_ALREADYFULLSCREEN, {"CKERR_ALREADYFULLSCREEN", "A Render context is already in Fullscreen Mode"} }, - { LibCmo::CKERROR::CKERR_CANCELLED, {"CKERR_CANCELLED", "Operation was cancelled by user"} }, - { LibCmo::CKERROR::CKERR_NOANIMATIONKEY, {"CKERR_NOANIMATIONKEY", "there were no animation key at the given index"} }, - { LibCmo::CKERROR::CKERR_INVALIDINDEX, {"CKERR_INVALIDINDEX", "attemp to acces an animation key with an invalid index"} }, - { LibCmo::CKERROR::CKERR_INVALIDANIMATION, {"CKERR_INVALIDANIMATION", "the animation is invalid (no entity associated or zero length)"} } + static const std::vector>> _CkErrorData{ + { LibCmo::CK2::CKERROR::CKERR_OK, { "CKERR_OK", "Operation successful" } }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDPARAMETER, {"CKERR_INVALIDPARAMETER", "One of the parameter passed to the function was invalid"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDPARAMETERTYPE, {"CKERR_INVALIDPARAMETERTYPE", "One of the parameter passed to the function was invalid"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDSIZE, {"CKERR_INVALIDSIZE", "The parameter size was invalid"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDOPERATION, {"CKERR_INVALIDOPERATION", "The operation type didn't exist"} }, + { LibCmo::CK2::CKERROR::CKERR_OPERATIONNOTIMPLEMENTED, {"CKERR_OPERATIONNOTIMPLEMENTED", "The function used to execute the operation is not yet implemented"} }, + { LibCmo::CK2::CKERROR::CKERR_OUTOFMEMORY, {"CKERR_OUTOFMEMORY", "There was not enough memory to perform the action"} }, + { LibCmo::CK2::CKERROR::CKERR_NOTIMPLEMENTED, {"CKERR_NOTIMPLEMENTED", "The function is not yet implemented"} }, + { LibCmo::CK2::CKERROR::CKERR_NOTFOUND, {"CKERR_NOTFOUND", "There was an attempt to remove something not present"} }, + { LibCmo::CK2::CKERROR::CKERR_NOLEVEL, {"CKERR_NOLEVEL", "There is no level currently created"} }, + { LibCmo::CK2::CKERROR::CKERR_CANCREATERENDERCONTEXT, {"CKERR_CANCREATERENDERCONTEXT", ""} }, + { LibCmo::CK2::CKERROR::CKERR_NOTIFICATIONNOTHANDLED, {"CKERR_NOTIFICATIONNOTHANDLED", "The notification message was not used"} }, + { LibCmo::CK2::CKERROR::CKERR_ALREADYPRESENT, {"CKERR_ALREADYPRESENT", "Attempt to add an item that was already present"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDRENDERCONTEXT, {"CKERR_INVALIDRENDERCONTEXT", "the render context is not valid"} }, + { LibCmo::CK2::CKERROR::CKERR_RENDERCONTEXTINACTIVE, {"CKERR_RENDERCONTEXTINACTIVE", "the render context is not activated for rendering"} }, + { LibCmo::CK2::CKERROR::CKERR_NOLOADPLUGINS, {"CKERR_NOLOADPLUGINS", "there was no plugins to load this kind of file"} }, + { LibCmo::CK2::CKERROR::CKERR_NOSAVEPLUGINS, {"CKERR_NOSAVEPLUGINS", "there was no plugins to save this kind of file"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDFILE, {"CKERR_INVALIDFILE", "attempt to load an invalid file"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDPLUGIN, {"CKERR_INVALIDPLUGIN", "attempt to load with an invalid plugin"} }, + { LibCmo::CK2::CKERROR::CKERR_NOTINITIALIZED, {"CKERR_NOTINITIALIZED", "attempt use an object that wasnt initialized"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDMESSAGE, {"CKERR_INVALIDMESSAGE", "attempt use a message type that wasn't registred"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDPROTOTYPE, {"CKERR_INVALIDPROTOTYPE", "attempt use an invalid prototype"} }, + { LibCmo::CK2::CKERROR::CKERR_NODLLFOUND, {"CKERR_NODLLFOUND", "No dll file found in the parse directory"} }, + { LibCmo::CK2::CKERROR::CKERR_ALREADYREGISTREDDLL, {"CKERR_ALREADYREGISTREDDLL", "this dll has already been registred"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDDLL, {"CKERR_INVALIDDLL", "this dll does not contain information to create the prototype"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDOBJECT, {"CKERR_INVALIDOBJECT", "Invalid Object (attempt to Get an object from an invalid ID)"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDCONDSOLEWINDOW, {"CKERR_INVALIDCONDSOLEWINDOW", "Invalid window was provided as console window"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDKINEMATICCHAIN, {"CKERR_INVALIDKINEMATICCHAIN", "Invalid kinematic chain ( end and start effector may not be part of the same hierarchy )"} }, + { LibCmo::CK2::CKERROR::CKERR_NOKEYBOARD, {"CKERR_NOKEYBOARD", "Keyboard not attached or not working properly"} }, + { LibCmo::CK2::CKERROR::CKERR_NOMOUSE, {"CKERR_NOMOUSE", "Mouse not attached or not working properly"} }, + { LibCmo::CK2::CKERROR::CKERR_NOJOYSTICK, {"CKERR_NOJOYSTICK", "Joystick not attached or not working properly"} }, + { LibCmo::CK2::CKERROR::CKERR_INCOMPATIBLEPARAMETERS, {"CKERR_INCOMPATIBLEPARAMETERS", "Try to link imcompatible Parameters"} }, + { LibCmo::CK2::CKERROR::CKERR_NORENDERENGINE, {"CKERR_NORENDERENGINE", "There is no render engine dll"} }, + { LibCmo::CK2::CKERROR::CKERR_NOCURRENTLEVEL, {"CKERR_NOCURRENTLEVEL", "There is no current level (use CKSetCurrentLevel )"} }, + { LibCmo::CK2::CKERROR::CKERR_SOUNDDISABLED, {"CKERR_SOUNDDISABLED", "Sound Management has been disabled"} }, + { LibCmo::CK2::CKERROR::CKERR_DINPUTDISABLED, {"CKERR_DINPUTDISABLED", "DirectInput Management has been disabled"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDGUID, {"CKERR_INVALIDGUID", "Guid is already in use or invalid"} }, + { LibCmo::CK2::CKERROR::CKERR_NOTENOUGHDISKPLACE, {"CKERR_NOTENOUGHDISKPLACE", "There was no more free space on disk when trying to save a file"} }, + { LibCmo::CK2::CKERROR::CKERR_CANTWRITETOFILE, {"CKERR_CANTWRITETOFILE", "Impossible to write to file (write-protection ?)"} }, + { LibCmo::CK2::CKERROR::CKERR_BEHAVIORADDDENIEDBYCB, {"CKERR_BEHAVIORADDDENIEDBYCB", "The behavior cannnot be added to this entity"} }, + { LibCmo::CK2::CKERROR::CKERR_INCOMPATIBLECLASSID, {"CKERR_INCOMPATIBLECLASSID", "The behavior cannnot be added to this entity"} }, + { LibCmo::CK2::CKERROR::CKERR_MANAGERALREADYEXISTS, {"CKERR_MANAGERALREADYEXISTS", "A manager was registered more than once"} }, + { LibCmo::CK2::CKERROR::CKERR_PAUSED, {"CKERR_PAUSED", "CKprocess or TimeManager process while CK is paused will fail"} }, + { LibCmo::CK2::CKERROR::CKERR_PLUGINSMISSING, {"CKERR_PLUGINSMISSING", "Some plugins were missing whileloading a file"} }, + { LibCmo::CK2::CKERROR::CKERR_OBSOLETEVIRTOOLS, {"CKERR_OBSOLETEVIRTOOLS", "Virtools version too old to load this file"} }, + { LibCmo::CK2::CKERROR::CKERR_FILECRCERROR, {"CKERR_FILECRCERROR", "CRC Error while loading file"} }, + { LibCmo::CK2::CKERROR::CKERR_ALREADYFULLSCREEN, {"CKERR_ALREADYFULLSCREEN", "A Render context is already in Fullscreen Mode"} }, + { LibCmo::CK2::CKERROR::CKERR_CANCELLED, {"CKERR_CANCELLED", "Operation was cancelled by user"} }, + { LibCmo::CK2::CKERROR::CKERR_NOANIMATIONKEY, {"CKERR_NOANIMATIONKEY", "there were no animation key at the given index"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDINDEX, {"CKERR_INVALIDINDEX", "attemp to acces an animation key with an invalid index"} }, + { LibCmo::CK2::CKERROR::CKERR_INVALIDANIMATION, {"CKERR_INVALIDANIMATION", "the animation is invalid (no entity associated or zero length)"} } }; - void GetCkErrorName(std::string& strl, LibCmo::CKERROR err) { - const std::array* pErrDesc = GetEnumData>( + void GetCkErrorName(std::string& strl, LibCmo::CK2::CKERROR err) { + const std::array* pErrDesc = GetEnumData>( _CkErrorData, err ); @@ -127,8 +127,8 @@ namespace Unvirt { } } - void GetCkErrorDescription(std::string& strl, LibCmo::CKERROR err) { - const std::array* pErrDesc = GetEnumData>( + void GetCkErrorDescription(std::string& strl, LibCmo::CK2::CKERROR err) { + const std::array* pErrDesc = GetEnumData>( _CkErrorData, err ); @@ -139,78 +139,78 @@ namespace Unvirt { } } - static const std::vector>> _CkClassHierarchy{ - { LibCmo::CK_CLASSID::CKCID_OBJECT, {"CKCID_OBJECT"} }, - { LibCmo::CK_CLASSID::CKCID_PARAMETERIN, {"CKCID_OBJECT", "CKCID_PARAMETERIN"} }, - { LibCmo::CK_CLASSID::CKCID_PARAMETEROPERATION, {"CKCID_OBJECT", "CKCID_PARAMETEROPERATION"} }, - { LibCmo::CK_CLASSID::CKCID_STATE, {"CKCID_OBJECT", "CKCID_STATE"} }, - { LibCmo::CK_CLASSID::CKCID_BEHAVIORLINK, {"CKCID_OBJECT", "CKCID_BEHAVIORLINK"} }, - { LibCmo::CK_CLASSID::CKCID_BEHAVIOR, {"CKCID_OBJECT", "CKCID_BEHAVIOR"} }, - { LibCmo::CK_CLASSID::CKCID_BEHAVIORIO, {"CKCID_OBJECT", "CKCID_BEHAVIORIO"} }, - { LibCmo::CK_CLASSID::CKCID_RENDERCONTEXT, {"CKCID_OBJECT", "CKCID_RENDERCONTEXT"} }, - { LibCmo::CK_CLASSID::CKCID_KINEMATICCHAIN, {"CKCID_OBJECT", "CKCID_KINEMATICCHAIN"} }, - { LibCmo::CK_CLASSID::CKCID_SCENEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT"} }, - { LibCmo::CK_CLASSID::CKCID_OBJECTANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_OBJECTANIMATION"} }, - { LibCmo::CK_CLASSID::CKCID_ANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION"} }, - { LibCmo::CK_CLASSID::CKCID_KEYEDANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION", "CKCID_KEYEDANIMATION"} }, - { LibCmo::CK_CLASSID::CKCID_BEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT"} }, - { LibCmo::CK_CLASSID::CKCID_DATAARRAY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_DATAARRAY"} }, - { LibCmo::CK_CLASSID::CKCID_SCENE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SCENE"} }, - { LibCmo::CK_CLASSID::CKCID_LEVEL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_LEVEL"} }, - { LibCmo::CK_CLASSID::CKCID_PLACE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_PLACE"} }, - { LibCmo::CK_CLASSID::CKCID_GROUP, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_GROUP"} }, - { LibCmo::CK_CLASSID::CKCID_SOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND"} }, - { LibCmo::CK_CLASSID::CKCID_WAVESOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_WAVESOUND"} }, - { LibCmo::CK_CLASSID::CKCID_MIDISOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_MIDISOUND"} }, - { LibCmo::CK_CLASSID::CKCID_MATERIAL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MATERIAL"} }, - { LibCmo::CK_CLASSID::CKCID_TEXTURE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_TEXTURE"} }, - { LibCmo::CK_CLASSID::CKCID_MESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH"} }, - { LibCmo::CK_CLASSID::CKCID_PATCHMESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH", "CKCID_PATCHMESH"} }, - { LibCmo::CK_CLASSID::CKCID_RENDEROBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT"} }, - { LibCmo::CK_CLASSID::CKCID_2DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY"} }, - { LibCmo::CK_CLASSID::CKCID_SPRITE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITE"} }, - { LibCmo::CK_CLASSID::CKCID_SPRITETEXT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITETEXT"} }, - { LibCmo::CK_CLASSID::CKCID_3DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY"} }, - { LibCmo::CK_CLASSID::CKCID_GRID, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_GRID"} }, - { LibCmo::CK_CLASSID::CKCID_CURVEPOINT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVEPOINT"} }, - { LibCmo::CK_CLASSID::CKCID_SPRITE3D, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_SPRITE3D"} }, - { LibCmo::CK_CLASSID::CKCID_CURVE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVE"} }, - { LibCmo::CK_CLASSID::CKCID_CAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA"} }, - { LibCmo::CK_CLASSID::CKCID_TARGETCAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA", "CKCID_TARGETCAMERA"} }, - { LibCmo::CK_CLASSID::CKCID_LIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT"} }, - { LibCmo::CK_CLASSID::CKCID_TARGETLIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT", "CKCID_TARGETLIGHT"} }, - { LibCmo::CK_CLASSID::CKCID_CHARACTER, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CHARACTER"} }, - { LibCmo::CK_CLASSID::CKCID_3DOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT"} }, - { LibCmo::CK_CLASSID::CKCID_BODYPART, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT", "CKCID_BODYPART"} }, - { LibCmo::CK_CLASSID::CKCID_PARAMETER, {"CKCID_OBJECT", "CKCID_PARAMETER"} }, - { LibCmo::CK_CLASSID::CKCID_PARAMETERLOCAL, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETERLOCAL"} }, - { LibCmo::CK_CLASSID::CKCID_PARAMETEROUT, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETEROUT"} }, - { LibCmo::CK_CLASSID::CKCID_INTERFACEOBJECTMANAGER, {"CKCID_OBJECT", "CKCID_INTERFACEOBJECTMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_CRITICALSECTION, {"CKCID_OBJECT", "CKCID_CRITICALSECTION"} }, - { LibCmo::CK_CLASSID::CKCID_LAYER, {"CKCID_OBJECT", "CKCID_LAYER"} }, - { LibCmo::CK_CLASSID::CKCID_PROGRESSIVEMESH, {"CKCID_OBJECT", "CKCID_PROGRESSIVEMESH"} }, - { LibCmo::CK_CLASSID::CKCID_SYNCHRO, {"CKCID_OBJECT", "CKCID_SYNCHRO"} }, - { LibCmo::CK_CLASSID::CKCID_OBJECTARRAY, {"CKCID_OBJECTARRAY"} }, - { LibCmo::CK_CLASSID::CKCID_SCENEOBJECTDESC, {"CKCID_SCENEOBJECTDESC"} }, - { LibCmo::CK_CLASSID::CKCID_ATTRIBUTEMANAGER, {"CKCID_ATTRIBUTEMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_MESSAGEMANAGER, {"CKCID_MESSAGEMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_COLLISIONMANAGER, {"CKCID_COLLISIONMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_OBJECTMANAGER, {"CKCID_OBJECTMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_FLOORMANAGER, {"CKCID_FLOORMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_RENDERMANAGER, {"CKCID_RENDERMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_BEHAVIORMANAGER, {"CKCID_BEHAVIORMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_INPUTMANAGER, {"CKCID_INPUTMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_PARAMETERMANAGER, {"CKCID_PARAMETERMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_GRIDMANAGER, {"CKCID_GRIDMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_SOUNDMANAGER, {"CKCID_SOUNDMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_TIMEMANAGER, {"CKCID_TIMEMANAGER"} }, - { LibCmo::CK_CLASSID::CKCID_CUIKBEHDATA, {"CKCID_CUIKBEHDATA"} }, - { LibCmo::CK_CLASSID::CKCID_MAXCLASSID, {"CKCID_MAXCLASSID"} }, - { LibCmo::CK_CLASSID::CKCID_MAXMAXCLASSID, {"CKCID_MAXMAXCLASSID"} } + static const std::vector>> _CkClassHierarchy{ + { LibCmo::CK2::CK_CLASSID::CKCID_OBJECT, {"CKCID_OBJECT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERIN, {"CKCID_OBJECT", "CKCID_PARAMETERIN"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PARAMETEROPERATION, {"CKCID_OBJECT", "CKCID_PARAMETEROPERATION"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_STATE, {"CKCID_OBJECT", "CKCID_STATE"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORLINK, {"CKCID_OBJECT", "CKCID_BEHAVIORLINK"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIOR, {"CKCID_OBJECT", "CKCID_BEHAVIOR"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORIO, {"CKCID_OBJECT", "CKCID_BEHAVIORIO"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_RENDERCONTEXT, {"CKCID_OBJECT", "CKCID_RENDERCONTEXT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_KINEMATICCHAIN, {"CKCID_OBJECT", "CKCID_KINEMATICCHAIN"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SCENEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_OBJECTANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_OBJECTANIMATION"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_ANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_KEYEDANIMATION, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_ANIMATION", "CKCID_KEYEDANIMATION"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_BEOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_DATAARRAY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_DATAARRAY"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SCENE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SCENE"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_LEVEL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_LEVEL"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PLACE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_PLACE"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_GROUP, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_GROUP"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_WAVESOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_WAVESOUND"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_MIDISOUND, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_SOUND", "CKCID_MIDISOUND"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MATERIAL"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_TEXTURE"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_MESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PATCHMESH, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_MESH", "CKCID_PATCHMESH"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_RENDEROBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_2DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SPRITE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITE"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SPRITETEXT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_RENDEROBJECT", "CKCID_2DENTITY", "CKCID_SPRITETEXT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_GRID, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_GRID"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_CURVEPOINT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVEPOINT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SPRITE3D, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_SPRITE3D"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_CURVE, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CURVE"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_CAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_TARGETCAMERA, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CAMERA", "CKCID_TARGETCAMERA"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_LIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_LIGHT", "CKCID_TARGETLIGHT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_CHARACTER, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_CHARACTER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_BODYPART, {"CKCID_OBJECT", "CKCID_SCENEOBJECT", "CKCID_BEOBJECT", "CKCID_3DENTITY", "CKCID_3DOBJECT", "CKCID_BODYPART"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PARAMETER, {"CKCID_OBJECT", "CKCID_PARAMETER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERLOCAL, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETERLOCAL"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PARAMETEROUT, {"CKCID_OBJECT", "CKCID_PARAMETER", "CKCID_PARAMETEROUT"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_INTERFACEOBJECTMANAGER, {"CKCID_OBJECT", "CKCID_INTERFACEOBJECTMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_CRITICALSECTION, {"CKCID_OBJECT", "CKCID_CRITICALSECTION"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_LAYER, {"CKCID_OBJECT", "CKCID_LAYER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PROGRESSIVEMESH, {"CKCID_OBJECT", "CKCID_PROGRESSIVEMESH"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SYNCHRO, {"CKCID_OBJECT", "CKCID_SYNCHRO"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_OBJECTARRAY, {"CKCID_OBJECTARRAY"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SCENEOBJECTDESC, {"CKCID_SCENEOBJECTDESC"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_ATTRIBUTEMANAGER, {"CKCID_ATTRIBUTEMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_MESSAGEMANAGER, {"CKCID_MESSAGEMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_COLLISIONMANAGER, {"CKCID_COLLISIONMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_OBJECTMANAGER, {"CKCID_OBJECTMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_FLOORMANAGER, {"CKCID_FLOORMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_RENDERMANAGER, {"CKCID_RENDERMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_BEHAVIORMANAGER, {"CKCID_BEHAVIORMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_INPUTMANAGER, {"CKCID_INPUTMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_PARAMETERMANAGER, {"CKCID_PARAMETERMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_GRIDMANAGER, {"CKCID_GRIDMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_SOUNDMANAGER, {"CKCID_SOUNDMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_TIMEMANAGER, {"CKCID_TIMEMANAGER"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_CUIKBEHDATA, {"CKCID_CUIKBEHDATA"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_MAXCLASSID, {"CKCID_MAXCLASSID"} }, + { LibCmo::CK2::CK_CLASSID::CKCID_MAXMAXCLASSID, {"CKCID_MAXMAXCLASSID"} } }; - void GetClassIdName(std::string& strl, LibCmo::CK_CLASSID cls) { - const std::vector* pHierarchy = GetEnumData>( + void GetClassIdName(std::string& strl, LibCmo::CK2::CK_CLASSID cls) { + const std::vector* pHierarchy = GetEnumData>( _CkClassHierarchy, cls ); @@ -221,8 +221,8 @@ namespace Unvirt { } } - void GetClassIdHierarchy(std::string& strl, LibCmo::CK_CLASSID cls) { - const std::vector* pHierarchy = GetEnumData>( + void GetClassIdHierarchy(std::string& strl, LibCmo::CK2::CK_CLASSID cls) { + const std::vector* pHierarchy = GetEnumData>( _CkClassHierarchy, cls ); diff --git a/Unvirt/AccessibleValue.hpp b/Unvirt/AccessibleValue.hpp index d858ddf..8e1599b 100644 --- a/Unvirt/AccessibleValue.hpp +++ b/Unvirt/AccessibleValue.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -15,10 +16,10 @@ namespace Unvirt { using EnumDescPairArray = std::vector>; namespace EnumDesc { - extern const EnumDescPairArray CK_FILE_WRITEMODE; - extern const EnumDescPairArray CK_LOAD_FLAGS; - extern const EnumDescPairArray CK_FO_OPTIONS; - extern const EnumDescPairArray CK_PLUGIN_TYPE; + extern const EnumDescPairArray CK_FILE_WRITEMODE; + extern const EnumDescPairArray CK_LOAD_FLAGS; + extern const EnumDescPairArray CK_FO_OPTIONS; + extern const EnumDescPairArray CK_PLUGIN_TYPE; } template @@ -57,10 +58,10 @@ namespace Unvirt { #pragma endregion - void GetClassIdName(std::string& strl, LibCmo::CK_CLASSID cls); - void GetCkErrorName(std::string& strl, LibCmo::CKERROR err); - void GetClassIdHierarchy(std::string& strl, LibCmo::CK_CLASSID cls); - void GetCkErrorDescription(std::string& strl, LibCmo::CKERROR err); + void GetClassIdName(std::string& strl, LibCmo::CK2::CK_CLASSID cls); + void GetCkErrorName(std::string& strl, LibCmo::CK2::CKERROR err); + void GetClassIdHierarchy(std::string& strl, LibCmo::CK2::CK_CLASSID cls); + void GetCkErrorDescription(std::string& strl, LibCmo::CK2::CKERROR err); void GetAccessibleFileSize(std::string& strl, uint64_t size); diff --git a/Unvirt/StructFormatter.cpp b/Unvirt/StructFormatter.cpp index 098cf23..4401850 100644 --- a/Unvirt/StructFormatter.cpp +++ b/Unvirt/StructFormatter.cpp @@ -7,7 +7,7 @@ namespace Unvirt { static FILE* fout = stdout; - void PrintCKFileInfo(const LibCmo::CKFileInfo& fileinfo) { + void PrintCKFileInfo(const LibCmo::CK2::CKFileInfo& fileinfo) { std::string container; fputs(UNVIRT_TERMCOL_LIGHT_YELLOW(("CKFileInfo\n")), fout); @@ -18,7 +18,7 @@ namespace Unvirt { (fileinfo.CKVersion >> 0) & 0xFFFF ); - LibCmo::CKDWORD product_series[4]{ + LibCmo::CK2::CKDWORD product_series[4]{ (fileinfo.ProductBuild >> 24) & 0xFF, (fileinfo.ProductBuild >> 16) & 0xFF, (fileinfo.ProductBuild >> 8) & 0xFF, @@ -28,7 +28,7 @@ namespace Unvirt { fileinfo.ProductVersion, product_series[0], product_series[1], product_series[2], product_series[3] ); - Unvirt::AccessibleValue::GetFlagEnumName( + Unvirt::AccessibleValue::GetFlagEnumName( Unvirt::AccessibleValue::EnumDesc::CK_FILE_WRITEMODE, container, fileinfo.FileWriteMode ); fprintf(fout, "Save Flags: %s\n", container.c_str()); diff --git a/Unvirt/StructFormatter.hpp b/Unvirt/StructFormatter.hpp index 3690e5e..b05af1d 100644 --- a/Unvirt/StructFormatter.hpp +++ b/Unvirt/StructFormatter.hpp @@ -5,7 +5,7 @@ namespace Unvirt { namespace StructFormatter { - void PrintCKFileInfo(const LibCmo::CKFileInfo& fileinfo); + void PrintCKFileInfo(const LibCmo::CK2::CKFileInfo& fileinfo); } } diff --git a/Unvirt/Unvirt.cpp b/Unvirt/Unvirt.cpp index 925ad6d..0e98e3a 100644 --- a/Unvirt/Unvirt.cpp +++ b/Unvirt/Unvirt.cpp @@ -1,7 +1,10 @@ #include "AccessibleValue.hpp" #include "TerminalHelper.hpp" #include "StructFormatter.hpp" + +#include "CKMinContext.hpp" #include "CKFile.hpp" + #include #include @@ -9,13 +12,13 @@ int main(int argc, char* argv[]) { Unvirt::TerminalHelper::EnsureTerminalColor(); Unvirt::TerminalHelper::EnsureTerminalEncoding(); - LibCmo::CKMinContext vtctx; + LibCmo::CK2::CKMinContext vtctx; vtctx.SetTempPath("Temp"); vtctx.SetEncoding("850"); - LibCmo::CKFile vtfile(&vtctx); - LibCmo::CKFileData::ShallowDocument* doc; - LibCmo::CKERROR err = vtfile.ShallowLoad("Language.old.nmo", &doc); + LibCmo::CK2::CKFile vtfile(&vtctx); + LibCmo::CK2::CKFileData::ShallowDocument* doc; + LibCmo::CK2::CKERROR err = vtfile.ShallowLoad("Language.old.nmo", &doc); if (doc) Unvirt::StructFormatter::PrintCKFileInfo(doc->m_FileInfo); diff --git a/Unvirt/Unvirt.vcxproj b/Unvirt/Unvirt.vcxproj index d6aebc3..735142e 100644 --- a/Unvirt/Unvirt.vcxproj +++ b/Unvirt/Unvirt.vcxproj @@ -103,6 +103,7 @@ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console @@ -122,6 +123,7 @@ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console @@ -141,6 +143,7 @@ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console @@ -160,6 +163,7 @@ $(ZLIB_PATH);../LibCmo;$(SQLITE_HEADER_PATH);%(AdditionalIncludeDirectories) stdcpp20 /utf-8 %(AdditionalOptions) + true Console