diff --git a/CodeGen/EnumsMigration/src/CKEnums.txt b/CodeGen/EnumsMigration/src/CKEnums.txt index 842be92..cc03ee2 100644 --- a/CodeGen/EnumsMigration/src/CKEnums.txt +++ b/CodeGen/EnumsMigration/src/CKEnums.txt @@ -129,6 +129,18 @@ enum CK_STATECHUNK_CHUNKOPTIONS { CHNK_DONTDELETE_PARSER = 0x80, // m_Parser Ptr is not owned by CKStateChunk , it must not be deleted... }; +typedef enum CK_OBJECT_SHOWOPTION { + CKHIDE =0, + CKSHOW =1, + CKHIERARCHICALHIDE =2 +} CK_OBJECT_SHOWOPTION; + +typedef enum CK_OBJECT_CANBEHIDE { + CKCANNOTHIDE =0, // the object cannot be hidden + CKCANHIDE =1, // the object can be hidden + CKCANHIERARCHICALHIDE =2 // the object can be hidden and hierarchically hidden +} CK_OBJECT_CANBEHIDE; + /*************************************************** {filename:CK_OBJECT_FLAGS} Summary: CKObject Flags diff --git a/LibCmo/CK2/CKBitmapData.cpp b/LibCmo/CK2/CKBitmapData.cpp index 0b14107..4ee8f21 100644 --- a/LibCmo/CK2/CKBitmapData.cpp +++ b/LibCmo/CK2/CKBitmapData.cpp @@ -56,7 +56,7 @@ namespace LibCmo::CK2 { VxMath::VxDoAlphaBlit(slot, static_cast(globalalpha)); } else { auto alphabuf = chk->ReadBufferWrapper(); - VxMath::VxDoAlphaBlit(slot, reinterpret_cast(alphabuf.get())); + VxMath::VxDoAlphaBlit(slot, static_cast(alphabuf.get())); } } @@ -102,10 +102,10 @@ namespace LibCmo::CK2 { // get essential data CKDWORD pixelcount = slot->GetPixelCount(); CKBYTE* dst = slot->GetMutableImage(), - * redSrc = reinterpret_cast(redBuffer.get()), - * greenSrc = reinterpret_cast(greenBuffer.get()), - * blueSrc = reinterpret_cast(blueBuffer.get()), - * alphaSrc = reinterpret_cast(alphaBuffer.get()); + * redSrc = static_cast(redBuffer.get()), + * greenSrc = static_cast(greenBuffer.get()), + * blueSrc = static_cast(blueBuffer.get()), + * alphaSrc = static_cast(alphaBuffer.get()); for (CKDWORD p = 0; p < pixelcount; ++p) { *(dst++) = *(blueSrc++); *(dst++) = *(greenSrc++); diff --git a/LibCmo/CK2/CKEnums.hpp b/LibCmo/CK2/CKEnums.hpp index be030a0..17d1444 100644 --- a/LibCmo/CK2/CKEnums.hpp +++ b/LibCmo/CK2/CKEnums.hpp @@ -139,6 +139,16 @@ namespace LibCmo::CK2 { CHUNK_DEV_2_1 = 10, /**< Changes in wavesound reading of inside, outside angles */ CHUNKDATA_CURRENTVERSION = CHUNK_DEV_2_1, }; + enum class CK_OBJECT_SHOWOPTION : CKDWORD { + CKHIDE = 0x0, + CKSHOW = 0x1, + CKHIERARCHICALHIDE = 0x2, + }; + enum class CK_OBJECT_CANBEHIDE : CKDWORD { + CKCANNOTHIDE = 0, /**< the object cannot be hidden */ + CKCANHIDE = 1, /**< the object can be hidden */ + CKCANHIERARCHICALHIDE = 2, /**< the object can be hidden and hierarchically hidden */ + }; /** CKObject Flags @remark diff --git a/LibCmo/CK2/CKGlobals.cpp b/LibCmo/CK2/CKGlobals.cpp index 91787ec..2357ba9 100644 --- a/LibCmo/CK2/CKGlobals.cpp +++ b/LibCmo/CK2/CKGlobals.cpp @@ -32,7 +32,7 @@ namespace LibCmo::CK2 { uLongf _destLen = static_cast(boundary); if (compress2( reinterpret_cast(DestBuffer), &_destLen, - reinterpret_cast(Data), static_cast(size), + static_cast(Data), static_cast(size), static_cast(compressionlevel)) != Z_OK) { NewSize = 0; delete[] DestBuffer; @@ -49,7 +49,7 @@ namespace LibCmo::CK2 { uLongf cache = DestSize; if (uncompress( reinterpret_cast(DestBuffer), &cache, - reinterpret_cast(SrcBuffer), static_cast(SrcSize)) != Z_OK) { + static_cast(SrcBuffer), static_cast(SrcSize)) != Z_OK) { delete[] DestBuffer; return nullptr; } @@ -60,7 +60,7 @@ namespace LibCmo::CK2 { CKDWORD CKComputeDataCRC(const void* data, CKDWORD size, CKDWORD PreviousCRC) { return static_cast(adler32( static_cast(PreviousCRC), - reinterpret_cast(data), + static_cast(data), static_cast(size) )); } diff --git a/LibCmo/CK2/CKStateChunkOthers.cpp b/LibCmo/CK2/CKStateChunkOthers.cpp index b9fa05d..d4920af 100644 --- a/LibCmo/CK2/CKStateChunkOthers.cpp +++ b/LibCmo/CK2/CKStateChunkOthers.cpp @@ -315,15 +315,15 @@ namespace LibCmo::CK2 { // read chunk ver and data ver first // chunk ver always set in the 3rd BYTE in every format this->m_ChunkVersion = static_cast( - reinterpret_cast(buf)[2] + static_cast(buf)[2] ); // data ver always set in the 1st BYTE in every format this->m_DataVersion = static_cast( - reinterpret_cast(buf)[0] + static_cast(buf)[0] ); // switch according to chunk ver - const CKDWORD* dwbuf = reinterpret_cast(buf); + const CKDWORD* dwbuf = static_cast(buf); size_t bufpos = 0u; if (this->m_ChunkVersion < CK_STATECHUNK_CHUNKVERSION::CHUNK_VERSION2) { // very old file @@ -390,11 +390,11 @@ namespace LibCmo::CK2 { // re-read some extra data // class id located the 2nd BYTE this->m_ClassId = static_cast( - reinterpret_cast(buf)[1] + static_cast(buf)[1] ); // options located the 4th BYTE CK_STATECHUNK_CHUNKOPTIONS options = static_cast( - reinterpret_cast(buf)[3] + static_cast(buf)[3] ); // read normal data @@ -464,12 +464,12 @@ namespace LibCmo::CK2 { // if buffer provided, write it if (buf != nullptr) { // write header - reinterpret_cast(buf)[0] = static_cast(this->m_DataVersion); - reinterpret_cast(buf)[1] = static_cast(this->m_ClassId); - reinterpret_cast(buf)[2] = static_cast(this->m_ChunkVersion); - reinterpret_cast(buf)[3] = static_cast(options); + static_cast(buf)[0] = static_cast(this->m_DataVersion); + static_cast(buf)[1] = static_cast(this->m_ClassId); + static_cast(buf)[2] = static_cast(this->m_ChunkVersion); + static_cast(buf)[3] = static_cast(options); - CKDWORD* dwbuf = reinterpret_cast(buf); + CKDWORD* dwbuf = static_cast(buf); // write buffer length dwbuf[1] = this->m_DataDwSize; size_t bufpos = 2u; diff --git a/LibCmo/CK2/CKStateChunkReader.cpp b/LibCmo/CK2/CKStateChunkReader.cpp index 0f0762c..4223aab 100644 --- a/LibCmo/CK2/CKStateChunkReader.cpp +++ b/LibCmo/CK2/CKStateChunkReader.cpp @@ -322,7 +322,7 @@ namespace LibCmo::CK2 { void CKStateChunk::DeleteBuffer(const void* buf) { if (buf == nullptr) return; - delete[] reinterpret_cast(buf); + delete[] static_cast(buf); } CKStateChunk::Buffer_t CKStateChunk::ReadBufferWrapper() { diff --git a/LibCmo/CK2/DataHandlers/CKBitmapHandler.cpp b/LibCmo/CK2/DataHandlers/CKBitmapHandler.cpp index 09d1b82..0ca0eeb 100644 --- a/LibCmo/CK2/DataHandlers/CKBitmapHandler.cpp +++ b/LibCmo/CK2/DataHandlers/CKBitmapHandler.cpp @@ -121,7 +121,7 @@ namespace LibCmo::CK2::DataHandlers { // read data int x, y, channels_in_file; stbi_uc* data = stbi_load_from_memory( - reinterpret_cast(memory), + static_cast(memory), static_cast(size), &x, &y, &channels_in_file, 4 // 4 == RGBA8888 ); @@ -145,7 +145,7 @@ namespace LibCmo::CK2::DataHandlers { size_t m_Counter; }; static void FileWriteFunction(void* context, void* data, int size) { - FileSaveContext* ctx = reinterpret_cast(context); + FileSaveContext* ctx = static_cast(context); if (ctx->m_Fs != nullptr) { std::fwrite(data, sizeof(CKBYTE), size, ctx->m_Fs); } @@ -158,7 +158,7 @@ namespace LibCmo::CK2::DataHandlers { size_t m_Counter; }; static void MemoryWriteFunction(void* context, void* data, int size) { - MemorySaveContext* ctx = reinterpret_cast(context); + MemorySaveContext* ctx = static_cast(context); if (ctx->m_Mem != nullptr) { std::memcpy(ctx->m_Mem, data, size); ctx->m_Mem = static_cast(ctx->m_Mem) + size; diff --git a/LibCmo/CK2/ObjImpls/CK3dEntity.cpp b/LibCmo/CK2/ObjImpls/CK3dEntity.cpp index 80836b1..1503521 100644 --- a/LibCmo/CK2/ObjImpls/CK3dEntity.cpp +++ b/LibCmo/CK2/ObjImpls/CK3dEntity.cpp @@ -53,9 +53,15 @@ namespace LibCmo::CK2::ObjImpls { XContainer::XObjectPointerArray potentials; chunk->ReadXObjectPointerArray(potentials); for (const auto& ptr : potentials) { + if (ptr == nullptr) continue; XContainer::NSXObjectPointerArray::AddIfNotHere(m_PotentialMeshes, ptr); } + // add current mesh to potential meshes + if (m_CurrentMesh != nullptr) { + XContainer::NSXObjectPointerArray::AddIfNotHere(m_PotentialMeshes, m_CurrentMesh); + } + } // read core entity data @@ -88,6 +94,8 @@ namespace LibCmo::CK2::ObjImpls { } // read matrix + // reset + m_WorldMatrix.ResetToIdentity(); // force read as vector3 chunk->ReadStruct(reinterpret_cast(&m_WorldMatrix[0])); chunk->ReadStruct(reinterpret_cast(&m_WorldMatrix[1])); @@ -139,7 +147,12 @@ namespace LibCmo::CK2::ObjImpls { chunk->ReadStruct(m_ZOrder); } + } else { + // MARK: compatibility code removed because I don't need them + return false; } + + // MARK: skin and bone are skipped. return true; } diff --git a/LibCmo/CK2/ObjImpls/CKObject.cpp b/LibCmo/CK2/ObjImpls/CKObject.cpp index 6804281..58274ea 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.cpp +++ b/LibCmo/CK2/ObjImpls/CKObject.cpp @@ -3,9 +3,46 @@ namespace LibCmo::CK2::ObjImpls { + CKObject::CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : + m_ID(ckid), + m_Name(name), + m_Context(ctx), + m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED) {} + + CKObject::~CKObject() {} + +#pragma region Non-virtual Functions + + CK_ID CKObject::GetID(void) const { + return m_ID; + } + CKSTRING CKObject::GetName(void) const { + return XContainer::NSXString::ToCKSTRING(m_Name); + } + void CKObject::SetName(CKSTRING u8_name) { + XContainer::NSXString::FromCKSTRING(m_Name, u8_name); + } + CK_OBJECT_FLAGS CKObject::GetObjectFlags(void) const { + return m_ObjectFlags; + } + void CKObject::SetObjectFlags(CK_OBJECT_FLAGS flags) { + m_ObjectFlags = flags; + } + bool CKObject::IsHierarchicallyHide() const { + return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); + } + CKContext* CKObject::GetCKContext() const { + return m_Context; + } + +#pragma endregion + + void CKObject::CheckPreDeletion() {} + void CKObject::CheckPostDeletion() {} + void CKObject::PreSave(CKFileVisitor* file, CKDWORD flags) {} bool CKObject::Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags) { @@ -36,90 +73,36 @@ namespace LibCmo::CK2::ObjImpls { void CKObject::PostLoad() {} - //CKSceneObject::CKSceneObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) { - //} - //CKSceneObject::~CKSceneObject() { - //} + void CKObject::Show(CK_OBJECT_SHOWOPTION show) { + // clear all visible data of object flags + EnumsHelper::Rm(m_ObjectFlags, EnumsHelper::Merge({ + CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE, + CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE + })); - //CKBeObject::CKBeObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKSceneObject(ctx, ckid, name) { - //} - //CKBeObject::~CKBeObject() { - //} + switch (show) { + case CK_OBJECT_SHOWOPTION::CKSHOW: + EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + break; + case CK_OBJECT_SHOWOPTION::CKHIERARCHICALHIDE: + EnumsHelper::Add(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_HIERACHICALHIDE); + break; + case CK_OBJECT_SHOWOPTION::CKHIDE: + return; + } + } - //CKGroup::CKGroup(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) { - //} - //CKGroup::~CKGroup() { - //} + bool CKObject::IsHiddenByParent() const { + return false; + } - //CKMesh::CKMesh(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) { - //} - //CKMesh::~CKMesh() { - //} + CK_OBJECT_CANBEHIDE CKObject::CanBeHide() const { + return CK_OBJECT_CANBEHIDE::CKCANNOTHIDE; + } - //CKTexture::CKTexture(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) { - //} - //CKTexture::~CKTexture() { - //} + bool CKObject::IsVisible() const { + return EnumsHelper::Has(m_ObjectFlags, CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE); + } - //CKMaterial::CKMaterial(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) { - //} - //CKMaterial::~CKMaterial() { - //} - - //CKRenderObject::CKRenderObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKBeObject(ctx, ckid, name) { - //} - //CKRenderObject::~CKRenderObject() { - //} - - //CK3dEntity::CK3dEntity(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKRenderObject(ctx, ckid, name) { - //} - //CK3dEntity::~CK3dEntity() { - //} - - //CK3dObject::CK3dObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : CK3dEntity(ctx, ckid, name) { - //} - //CK3dObject::~CK3dObject() { - //} - - - //CKParameterIn::CKParameterIn(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) { - //} - //CKParameterIn::~CKParameterIn() { - //} - - //CKParameter::CKParameter(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) { - //} - //CKParameter::~CKParameter() { - //} - - //CKParameterOut::CKParameterOut(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKParameter(ctx, ckid, name) { - //} - //CKParameterOut::~CKParameterOut() { - //} - - //CKParameterLocal::CKParameterLocal(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKParameter(ctx, ckid, name) { - //} - //CKParameterLocal::~CKParameterLocal() { - //} - - //CKParameterOperation::CKParameterOperation(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) { - //} - //CKParameterOperation::~CKParameterOperation() { - //} - - //CKBehaviorLink::CKBehaviorLink(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) { - //} - //CKBehaviorLink::~CKBehaviorLink() { - //} - - //CKBehaviorIO::CKBehaviorIO(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKObject(ctx, ckid, name) { - //} - //CKBehaviorIO::~CKBehaviorIO() { - //} - - //CKBehavior::CKBehavior(CKContext* ctx, CK_ID ckid, CKSTRING name) : CKSceneObject(ctx, ckid, name) { - //} - //CKBehavior::~CKBehavior() { - //} } \ No newline at end of file diff --git a/LibCmo/CK2/ObjImpls/CKObject.hpp b/LibCmo/CK2/ObjImpls/CKObject.hpp index 600b9eb..2fdc721 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.hpp +++ b/LibCmo/CK2/ObjImpls/CKObject.hpp @@ -18,15 +18,15 @@ Implement as original meaning: - CanBeHide() - IsVisible() +- CheckPreDeletion() +- CheckPostDeletion() + No implement because don't care: - GetMemoryOccupation() - IsObjectUsed() - PrepareDependencies() - RemapDependencies() -- CheckPreDeletion() -- CheckPostDeletion() - Implement moved into other location: - Copy(): Use CKObject::CKObject(CK_ID newid, const CKObject* obj) ctor and CKClassDesc to implement. - PreDelete(): Write in dtor. @@ -37,44 +37,65 @@ namespace LibCmo::CK2::ObjImpls { class CKObject { public: - CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : - m_ID(ckid), - m_Name(name), - m_Context(ctx), - m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED) - {} - virtual ~CKObject() {} + CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name); + virtual ~CKObject(); LIBCMO_DISABLE_COPY_MOVE(CKObject); - CK_ID GetID(void) { - return m_ID; - } - CKSTRING GetName(void) { - return XContainer::NSXString::ToCKSTRING(m_Name); - } - void SetName(CKSTRING u8_name) { - XContainer::NSXString::FromCKSTRING(m_Name, u8_name); - } - CK_OBJECT_FLAGS GetObjectFlags(void) { - return m_ObjectFlags; - } - void SetObjectFlags(CK_OBJECT_FLAGS flags) { - m_ObjectFlags = flags; - } - CKContext* GetCKContext() { - return m_Context; - } + CK_ID GetID(void) const; + CKSTRING GetName(void) const; + void SetName(CKSTRING u8_name); + CK_OBJECT_FLAGS GetObjectFlags(void) const; + void SetObjectFlags(CK_OBJECT_FLAGS flags); + bool IsHierarchicallyHide() const; + CKContext* GetCKContext() const; virtual CK_CLASSID GetClassID(void) { return CK_CLASSID::CKCID_OBJECT; } + virtual void CheckPreDeletion(); virtual void CheckPostDeletion(); + virtual void PreSave(CKFileVisitor* file, CKDWORD flags); virtual bool Save(CKStateChunk* chunk, CKFileVisitor* file, CKDWORD flags); virtual bool Load(CKStateChunk* chunk, CKFileVisitor* file); virtual void PostLoad(); + /** + * @brief Shows or hides an object + * @remark + * + If show is set to CKHIERARCHICALHIDE this object will be hidden along with all its children. + * + The render engine renders objets in a hierarchical way and stops iterating a hierarchy if it encounters an object which is hierarchically hidden. The problem is that, for performance reason, children objets visibility flags are left unchanged (ie. if a child object was visible CKObject::IsVisible will still return TRUE). To test is a object is hidden because one of its parent object is hierarchically hidden use CKObject::IsHiddenByParent + * + The CKHIERARCHICALHIDE option is only relevant for CK2dEntity and CK3dEntity derived classes. + * + If show is set to CKSHOW the object will be shown and it also removes the hierarchically hidden flags. + * + If show is set to CKHIDE the object will be hidden and it also removes the hierarchically hidden flags. + * + This function is overload by CKGroup,CKMesh and CK3dEntity. + */ + virtual void Show(CK_OBJECT_SHOWOPTION show = CK_OBJECT_SHOWOPTION::CKSHOW); + /** + * @brief Returns whether this object is hidden (and also hides its children). + * @return true if hierarchically hidden. + * @remark + * + This methods returns if this object is hidden and also hides all its sub-hierarchy. + * + See CKObject::Show¡ì for more details on hierarchically hidden objects. + */ + virtual bool IsHiddenByParent() const; + /** + * @brief Returns whether this object class allows it to be shown or hidden. + * @return 3 possible value according to its type. + * + CKCANNOTHIDE if the object cannot be hidden + * + CKCANHIDE if the object can be hidden + * + CKCANHIERARCHICALHIDE if the object can be hidden and hierarchically hidden + * @remark + * + This virtual function is mainly used by the Virtools interface to known if visibility flags have an impact on a specific object class. + * + CKRenderObject and derived classes,can be triggered as to be shown or hidden or hierarchically hidden and will return 2 to this function. + * + CKMesh and CKGroup can be triggered as to be shown or hidden and will return 1 to this function. + * + Other classes will return 0 which means CKObject::Show function will not have any impact on them. + + */ + virtual CK_OBJECT_CANBEHIDE CanBeHide() const; + virtual bool IsVisible() const; + protected: CK_ID m_ID; XContainer::XString m_Name; @@ -82,217 +103,4 @@ namespace LibCmo::CK2::ObjImpls { CKContext* m_Context; }; - //class CKSceneObject : public CKObject { - //public: - // CKSceneObject(CKContext* ctx, CK_ID ckid, CKSTRING name); - // 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(CKContext* ctx, CK_ID ckid, CKSTRING name); - // CKBeObject(const CKBeObject&) = delete; - // CKBeObject& operator=(const CKBeObject&) = delete; - // virtual ~CKBeObject(); - - // virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEOBJECT; } - //protected: - - //}; -// -//#pragma region Map Related -// -// class CKGroup : public CKBeObject { -// public: -// CKGroup(CKContext* ctx, CK_ID ckid, CKSTRING name); -// 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(CKContext* ctx, CK_ID ckid, CKSTRING name); -// 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(CKContext* ctx, CK_ID ckid, CKSTRING name); -// 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(CKContext* ctx, CK_ID ckid, CKSTRING name); -// 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(CKContext* ctx, CK_ID ckid, CKSTRING name); -// 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 CKRenderObject { -// public: -// CK3dEntity(CKContext* ctx, CK_ID ckid, CKSTRING name); -// 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(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CK3dObject(const CK3dObject&) = delete; -// CK3dObject& operator=(const CK3dObject&) = delete; -// ~CK3dObject(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_3DOBJECT; } -// protected: -// -// }; -// -//#pragma endregion -// -//#pragma region Behavior Related -// -// class CKParameterIn :public CKObject { -// public: -// CKParameterIn(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKParameterIn(const CKParameterIn&) = delete; -// CKParameterIn& operator=(const CKParameterIn&) = delete; -// ~CKParameterIn(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETERIN; } -// protected: -// -// }; -// -// class CKParameter :public CKObject { -// public: -// CKParameter(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKParameter(const CKParameter&) = delete; -// CKParameter& operator=(const CKParameter&) = delete; -// ~CKParameter(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETER; } -// protected: -// -// }; -// -// class CKParameterOut :public CKParameter { -// public: -// CKParameterOut(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKParameterOut(const CKParameterOut&) = delete; -// CKParameterOut& operator=(const CKParameterOut&) = delete; -// ~CKParameterOut(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETEROUT; } -// protected: -// -// }; -// -// class CKParameterLocal :public CKParameter { -// public: -// CKParameterLocal(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKParameterLocal(const CKParameterLocal&) = delete; -// CKParameterLocal& operator=(const CKParameterLocal&) = delete; -// ~CKParameterLocal(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETERLOCAL; } -// protected: -// -// }; -// -// class CKParameterOperation :public CKObject { -// public: -// CKParameterOperation(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKParameterOperation(const CKParameterOperation&) = delete; -// CKParameterOperation& operator=(const CKParameterOperation&) = delete; -// ~CKParameterOperation(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_PARAMETEROPERATION; } -// protected: -// -// }; -// -// class CKBehaviorLink :public CKObject { -// public: -// CKBehaviorLink(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKBehaviorLink(const CKBehaviorLink&) = delete; -// CKBehaviorLink& operator=(const CKBehaviorLink&) = delete; -// ~CKBehaviorLink(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEHAVIORLINK; } -// protected: -// -// }; -// -// class CKBehaviorIO :public CKObject { -// public: -// CKBehaviorIO(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKBehaviorIO(const CKBehaviorIO&) = delete; -// CKBehaviorIO& operator=(const CKBehaviorIO&) = delete; -// ~CKBehaviorIO(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEHAVIORIO; } -// protected: -// -// }; -// -// class CKBehavior :public CKSceneObject { -// public: -// CKBehavior(CKContext* ctx, CK_ID ckid, CKSTRING name); -// CKBehavior(const CKBehavior&) = delete; -// CKBehavior& operator=(const CKBehavior&) = delete; -// ~CKBehavior(); -// -// virtual CK_CLASSID GetClassID(void) override { return CK_CLASSID::CKCID_BEHAVIOR; } -// protected: -// -// }; -// -//#pragma endregion - - } diff --git a/LibCmo/CK2/ObjImpls/CKTexture.cpp b/LibCmo/CK2/ObjImpls/CKTexture.cpp index d519bff..7f786ee 100644 --- a/LibCmo/CK2/ObjImpls/CKTexture.cpp +++ b/LibCmo/CK2/ObjImpls/CKTexture.cpp @@ -170,7 +170,7 @@ namespace LibCmo::CK2::ObjImpls { if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_TEXTURE::CK_STATESAVE_TEXSAVEFORMAT)) { auto buf = chunk->ReadBufferWrapper(); if (buf != nullptr) { - FakeBitmapProperties* props = reinterpret_cast(buf.get()); + FakeBitmapProperties* props = static_cast(buf.get()); CKBitmapProperties myprops( CKGUID(props->m_ReaderGuid.d1, props->m_ReaderGuid.d2), diff --git a/LibCmo/VxMath/VxTypes.hpp b/LibCmo/VxMath/VxTypes.hpp index 1dce618..93c673b 100644 --- a/LibCmo/VxMath/VxTypes.hpp +++ b/LibCmo/VxMath/VxTypes.hpp @@ -399,7 +399,7 @@ namespace LibCmo::VxMath { class VxStridedData { public: VxStridedData(_Ty ptr, CKDWORD stride) : - m_Ptr(reinterpret_cast(m_Ptr)), + m_Ptr(reinterpret_cast(ptr)), m_Stride(stride) {} ~VxStridedData() {} diff --git a/LibCmo/XContainer/XTypes.cpp b/LibCmo/XContainer/XTypes.cpp index 0d2247e..39bb8d1 100644 --- a/LibCmo/XContainer/XTypes.cpp +++ b/LibCmo/XContainer/XTypes.cpp @@ -144,10 +144,13 @@ namespace LibCmo::XContainer { } namespace NSXObjectPointerArray { - void AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj) { + bool AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj) { auto finder = std::find(objarray.begin(), objarray.end(), obj); if (finder == objarray.end()) { objarray.emplace_back(obj); + return true; + } else { + return false; } } diff --git a/LibCmo/XContainer/XTypes.hpp b/LibCmo/XContainer/XTypes.hpp index 75ba78d..9b97e5c 100644 --- a/LibCmo/XContainer/XTypes.hpp +++ b/LibCmo/XContainer/XTypes.hpp @@ -181,11 +181,12 @@ namespace LibCmo::XContainer { namespace NSXObjectPointerArray { /** - * @brief Add object pointer if it is not list. + * @brief Inserts the object at the end of the array, if it is not yet present. * @param objarray * @param obj + * @return True if the object was already present, false otherwise */ - void AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj); + bool AddIfNotHere(XObjectPointerArray& objarray, CK2::ObjImpls::CKObject* const obj); /** * @brief Check Object pointer validation and remove invalid pointers before deletion.