write garbage for BMap dll

This commit is contained in:
yyc12345 2023-09-23 15:55:57 +08:00
parent c0626eefee
commit 94dadbfb1f
7 changed files with 226 additions and 131 deletions

View File

@ -1,9 +1,24 @@
#include "BMExports.hpp" #include "BMExports.hpp"
#include <IronPad.hpp>
#include <set>
static std::set<BMap::BMFile*> g_AllBMFiles = std::set<BMap::BMFile*>();
void BMInit() { void BMInit() {
// register IronPad
IronPad::IronPadRegister();
// and startup CK environment
LibCmo::CK2::CKStartUp();
} }
void BMDispose() { void BMDispose() {
// free all existed file reader / writer
for (auto ptr : g_AllBMFiles) {
delete ptr;
}
g_AllBMFiles.clear();
// shutdown CK environment
LibCmo::CK2::CKShutdown();
// unregister iron pad
IronPad::IronPadUnregister();
} }

View File

@ -9,7 +9,7 @@ LIBCMO_EXPORT void BMDispose();
#pragma endregion #pragma endregion
#pragma region BMapFile Life Time Manager #pragma region BMFile
//LIBCMO_EXPORT BMap::BMFile* BMFile_Load(const char* file_name, const char* temp_folder, const char* texture_folder, const char* encoding); //LIBCMO_EXPORT BMap::BMFile* BMFile_Load(const char* file_name, const char* temp_folder, const char* texture_folder, const char* encoding);
//LIBCMO_EXPORT BMap::BMFile* BMFile_Create(); //LIBCMO_EXPORT BMap::BMFile* BMFile_Create();
@ -18,4 +18,9 @@ LIBCMO_EXPORT void BMDispose();
#pragma endregion #pragma endregion
#pragma region BMMeshTransition
#pragma endregion

View File

@ -10,7 +10,7 @@ namespace BMap {
const LibCmo::VxMath::VxVector2& uv) : const LibCmo::VxMath::VxVector2& uv) :
m_Vertex(vec), m_Norm(norm), m_UV(uv) {} m_Vertex(vec), m_Norm(norm), m_UV(uv) {}
BMMeshTransition::TransitionFace::TransitionFace(uint32_t _i1, uint32_t _i2, uint32_t _i3, uint32_t mtl_id) : BMMeshTransition::TransitionFace::TransitionFace(LibCmo::CKDWORD _i1, LibCmo::CKDWORD _i2, LibCmo::CKDWORD _i3, LibCmo::CKDWORD mtl_id) :
m_Idx1(_i1), m_Idx2(_i2), m_Idx3(_i3), m_MtlSlotIdx(mtl_id) {} m_Idx1(_i1), m_Idx2(_i2), m_Idx3(_i3), m_MtlSlotIdx(mtl_id) {}
bool BMMeshTransition::TransitionVertexCompare::operator()(const TransitionVertex& lhs, const TransitionVertex& rhs) const { bool BMMeshTransition::TransitionVertexCompare::operator()(const TransitionVertex& lhs, const TransitionVertex& rhs) const {
@ -29,56 +29,51 @@ namespace BMap {
BMMeshTransition::~BMMeshTransition() {} BMMeshTransition::~BMMeshTransition() {}
void BMMeshTransition::PrepareVertexCount(uint32_t count) { void BMMeshTransition::PrepareVertexCount(LibCmo::CKDWORD count) {
if (m_IsParsed) return; if (m_IsParsed) return;
m_Vertexs.resize(count); m_Vertexs.resize(count);
m_IsVertexOK = true; m_IsVertexOK = true;
} }
void BMMeshTransition::PrepareVertex(uint32_t index, float x, float y, float z) { LibCmo::VxMath::VxVector3* BMMeshTransition::PrepareVertex() {
if (m_IsParsed || index >= m_Vertexs.size()) return; if (m_IsParsed || !m_IsVertexOK) return nullptr;
m_Vertexs[index].x = x; return m_Vertexs.data();
m_Vertexs[index].y = y;
m_Vertexs[index].z = z;
} }
void BMMeshTransition::PrepareNormalCount(uint32_t count) { void BMMeshTransition::PrepareNormalCount(LibCmo::CKDWORD count) {
if (m_IsParsed) return; if (m_IsParsed) return;
m_Normals.resize(count); m_Normals.resize(count);
m_IsNormalOK = true; m_IsNormalOK = true;
} }
void BMMeshTransition::PrepareNormal(uint32_t index, float x, float y, float z) { LibCmo::VxMath::VxVector3* BMMeshTransition::PrepareNormal() {
if (m_IsParsed || index >= m_Normals.size()) return; if (m_IsParsed || !m_IsNormalOK) return nullptr;
m_Normals[index].x = x; return m_Normals.data();
m_Normals[index].y = y;
m_Normals[index].z = z;
} }
void BMMeshTransition::PrepareUVCount(uint32_t count) { void BMMeshTransition::PrepareUVCount(LibCmo::CKDWORD count) {
if (m_IsParsed) return; if (m_IsParsed) return;
m_UVs.resize(count); m_UVs.resize(count);
m_IsUVOK = true; m_IsUVOK = true;
} }
void BMMeshTransition::PrepareUV(uint32_t index, float u, float v) { LibCmo::VxMath::VxVector2* BMMeshTransition::PrepareUV() {
if (m_IsParsed || index >= m_UVs.size()) return; if (m_IsParsed || !m_IsUVOK) return nullptr;
m_UVs[index].x = u; return m_UVs.data();
m_UVs[index].y = v;
} }
void BMMeshTransition::PrepareMtlSlotCount(uint32_t count) { void BMMeshTransition::PrepareMtlSlotCount(LibCmo::CKDWORD count) {
if (m_IsParsed) return; if (m_IsParsed) return;
m_MtlSlots.resize(count, nullptr); m_MtlSlots.resize(count, nullptr);
m_IsMtlSlotOK = true; m_IsMtlSlotOK = true;
} }
void BMMeshTransition::PrepareMtlSlot(uint32_t index, BMMaterial* mtl) { LibCmo::CK2::ObjImpls::CKMaterial** BMMeshTransition::PrepareMtlSlot() {
if (m_IsParsed || index >= m_MtlSlots.size()) return; if (m_IsParsed || !m_IsMtlSlotOK) return nullptr;
m_MtlSlots[index] = mtl; return m_MtlSlots.data();
} }
void BMMeshTransition::PrepareFaceCount(uint32_t count) { void BMMeshTransition::PrepareFaceCount(LibCmo::CKDWORD count) {
if (m_IsParsed) return; if (m_IsParsed) return;
m_FaceVertexs.resize(count * 3); m_FaceVertexs.resize(count * 3);
m_FaceNormals.resize(count * 3); m_FaceNormals.resize(count * 3);
@ -87,45 +82,46 @@ namespace BMap {
m_IsFaceOK = true; m_IsFaceOK = true;
} }
void BMMeshTransition::PrepareFaceVertexIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3) { LibCmo::CKDWORD* BMMeshTransition::PrepareFaceVertexIndices() {
index *= 3; if (m_IsParsed || !m_IsFaceOK) return nullptr;
if (m_IsParsed || index >= m_FaceVertexs.size()) return; return m_FaceVertexs.data();
m_FaceVertexs[index] = indice1;
m_FaceVertexs[index + 1] = indice2;
m_FaceVertexs[index + 2] = indice3;
} }
void BMMeshTransition::PrepareFaceNormalIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3) { LibCmo::CKDWORD* BMMeshTransition::PrepareFaceNormalIndices() {
index *= 3; if (m_IsParsed || !m_IsFaceOK) return nullptr;
if (m_IsParsed || index >= m_FaceNormals.size()) return; return m_FaceVertexs.data();
m_FaceNormals[index] = indice1;
m_FaceNormals[index + 1] = indice2;
m_FaceNormals[index + 2] = indice3;
} }
void BMMeshTransition::PrepareFaceUVIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3) { LibCmo::CKDWORD* BMMeshTransition::PrepareFaceUVIndices() {
index *= 3; if (m_IsParsed || !m_IsFaceOK) return nullptr;
if (m_IsParsed || index >= m_FaceUVs.size()) return; return m_FaceVertexs.data();
m_FaceUVs[index] = indice1;
m_FaceUVs[index + 1] = indice2;
m_FaceUVs[index + 2] = indice3;
} }
void BMMeshTransition::PrepareFaceMtlSlot(uint32_t index, uint32_t mtl_slot) { LibCmo::CKDWORD* BMMeshTransition::PrepareFaceMtlSlot() {
if (m_IsParsed || index >= m_FaceMtlSlotIdxs.size()) return; if (m_IsParsed || !m_IsFaceOK) return nullptr;
m_FaceMtlSlotIdxs[index] = mtl_slot; return m_FaceVertexs.data();
} }
bool BMMeshTransition::Parse(BMMesh* write_into_mesh) { bool BMMeshTransition::Parse(LibCmo::CK2::ObjImpls::CKMesh* write_into_mesh) {
if (m_IsParsed || write_into_mesh == nullptr) return false; if (m_IsParsed || write_into_mesh == nullptr) return false;
if (!m_IsVertexOK || !m_IsNormalOK || !m_IsUVOK || !m_IsFaceOK || !m_IsMtlSlotOK) return false; if (!m_IsVertexOK || !m_IsNormalOK || !m_IsUVOK || !m_IsFaceOK || !m_IsMtlSlotOK) return false;
m_IsParsed = true;
// do parse
DoRealParse(); DoRealParse();
// check vertex overflow
if (m_ProcVertexs.size() > std::numeric_limits<LibCmo::CKWORD>::max()) {
return false;
}
// check mtl slot overflow
if (m_MtlSlots.size() > std::numeric_limits<LibCmo::CKWORD>::max()) {
return false;
}
// apply to mesh
ApplyToMesh(write_into_mesh); ApplyToMesh(write_into_mesh);
m_IsParsed = true;
return true; return true;
} }
@ -138,7 +134,7 @@ namespace BMap {
// iterate face // iterate face
for (size_t faceid = 0; faceid < face_size; ++faceid) { for (size_t faceid = 0; faceid < face_size; ++faceid) {
uint32_t idx[3]; LibCmo::CKDWORD idx[3];
for (int j = 0; j < 3; ++j) { for (int j = 0; j < 3; ++j) {
// create one first // create one first
TransitionVertex tvec( TransitionVertex tvec(
@ -148,7 +144,7 @@ namespace BMap {
); );
// try insert it // try insert it
auto insert_result = m_ProcDupRemover.try_emplace(tvec, static_cast<uint32_t>(m_ProcVertexs.size())); auto insert_result = m_ProcDupRemover.try_emplace(tvec, static_cast<LibCmo::CKDWORD>(m_ProcVertexs.size()));
// get the new inserted index or existed index. // get the new inserted index or existed index.
idx[j] = insert_result.first->second; idx[j] = insert_result.first->second;
// if insert successfully, append to proc vertexs // if insert successfully, append to proc vertexs
@ -162,12 +158,104 @@ namespace BMap {
} }
} }
void BMMeshTransition::ApplyToMesh(BMMesh* write_into_mesh) { void BMMeshTransition::ApplyToMesh(LibCmo::CK2::ObjImpls::CKMesh* write_into_mesh) {
// todo: apply to mesh LibCmo::CKDWORD vec_count = static_cast<LibCmo::CKDWORD>(m_ProcVertexs.size()),
face_count = static_cast<LibCmo::CKDWORD>(m_ProcFaces.size()),
mtl_count = static_cast<LibCmo::CKDWORD>(m_MtlSlots.size());
write_into_mesh->CleanMesh();
// write vertex
write_into_mesh->SetVertexCount(vec_count);
LibCmo::VxMath::VxCopyStructure(
vec_count,
write_into_mesh->GetVertexPositions(),
CKSizeof(LibCmo::VxMath::VxVector3),
CKSizeof(LibCmo::VxMath::VxVector3),
&m_ProcVertexs.data()->m_Vertex,
CKSizeof(TransitionVertex)
);
LibCmo::VxMath::VxCopyStructure(
vec_count,
write_into_mesh->GetVertexNormals(),
CKSizeof(LibCmo::VxMath::VxVector3),
CKSizeof(LibCmo::VxMath::VxVector3),
&m_ProcVertexs.data()->m_Norm,
CKSizeof(TransitionVertex)
);
LibCmo::VxMath::VxCopyStructure(
vec_count,
write_into_mesh->GetVertexUVs(),
CKSizeof(LibCmo::VxMath::VxVector2),
CKSizeof(LibCmo::VxMath::VxVector2),
&m_ProcVertexs.data()->m_UV,
CKSizeof(TransitionVertex)
);
// write face
write_into_mesh->SetFaceCount(face_count);
auto pIndices = write_into_mesh->GetFaceIndices();
auto pMtlIdx = write_into_mesh->GetFaceMaterialSlotIndexs();
for (LibCmo::CKDWORD i = 0; i < face_count; ++i) {
*(pIndices++) = static_cast<LibCmo::CKWORD>(m_ProcFaces[i].m_Idx1);
*(pIndices++) = static_cast<LibCmo::CKWORD>(m_ProcFaces[i].m_Idx2);
*(pIndices++) = static_cast<LibCmo::CKWORD>(m_ProcFaces[i].m_Idx3);
*(pMtlIdx++) = static_cast<LibCmo::CKWORD>(m_ProcFaces[i].m_MtlSlotIdx);
}
// set mtl slot
write_into_mesh->SetMaterialSlotCount(mtl_count);
auto pMtlSlot = write_into_mesh->GetMaterialSlots();
for (LibCmo::CKDWORD i = 0; i < mtl_count; ++i) {
*(pMtlSlot++) = m_MtlSlots[i];
}
} }
#pragma endregion #pragma endregion
#pragma region BMfile
BMFile::BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[], bool is_reader) {
}
BMFile::~BMFile() {}
bool BMFile::Load(LibCmo::CKSTRING filename) {
return false;
}
bool BMFile::Save(LibCmo::CKSTRING filename, LibCmo::CKINT compress_level) {
return false;
}
#define VISITOR_IMPL(namepart, cidpart) \
LibCmo::CKDWORD BMFile::Get ## namepart ## Count() { \
if (!m_IsReader) return 0; \
return static_cast<LibCmo::CKDWORD>(m_Obj ## namepart ## s.size()); \
} \
LibCmo::CK2::ObjImpls::CK ## namepart * BMFile::Get ## namepart (LibCmo::CKDWORD idx) { \
if (!m_IsReader || idx >= m_Obj ## namepart ## s.size()) return nullptr; \
return m_Obj ## namepart ## s[idx]; \
} \
LibCmo::CK2::ObjImpls::CK ## namepart * BMFile::Create ## namepart (LibCmo::CKSTRING name) { \
if (m_IsReader) return nullptr; \
LibCmo::CK2::ObjImpls::CK ## namepart * obj = static_cast<LibCmo::CK2::ObjImpls::CK ## namepart *>( \
m_Context->CreateObject(LibCmo::CK2::CK_CLASSID::CKCID_ ## cidpart, name) \
); \
if (obj != nullptr) m_Obj ## namepart ## s.emplace_back(obj); \
return obj; \
}
VISITOR_IMPL(Group, GROUP)
VISITOR_IMPL(3dObject, 3DOBJECT)
VISITOR_IMPL(Mesh, MESH)
VISITOR_IMPL(Material, MATERIAL)
VISITOR_IMPL(Texture, TEXTURE)
#undef VISITOR_IMPL
#pragma endregion
} }

View File

@ -7,51 +7,6 @@
namespace BMap { namespace BMap {
class BMGroup {
public:
BMGroup(LibCmo::CK2::ObjImpls::CKGroup* ptr);
~BMGroup();
LIBCMO_DEFAULT_COPY_MOVE(BMGroup);
LibCmo::CK2::ObjImpls::CKGroup* m_NativePtr;
};
class BMTexture {
public:
BMTexture(LibCmo::CK2::ObjImpls::CKTexture* ptr);
~BMTexture();
LIBCMO_DEFAULT_COPY_MOVE(BMTexture);
LibCmo::CK2::ObjImpls::CKTexture* m_NativePtr;
};
class BMMaterial {
public:
BMMaterial(LibCmo::CK2::ObjImpls::CKMaterial* ptr);
~BMMaterial();
LIBCMO_DEFAULT_COPY_MOVE(BMMaterial);
LibCmo::CK2::ObjImpls::CKMaterial* m_NativePtr;
};
class BMMesh {
public:
BMMesh(LibCmo::CK2::ObjImpls::CKMesh* ptr);
~BMMesh();
LIBCMO_DEFAULT_COPY_MOVE(BMMesh);
LibCmo::CK2::ObjImpls::CKMesh* m_NativePtr;
};
class BM3dEntity {
public:
BM3dEntity(LibCmo::CK2::ObjImpls::CK3dEntity* ptr);
~BM3dEntity();
LIBCMO_DEFAULT_COPY_MOVE(BM3dEntity);
LibCmo::CK2::ObjImpls::CK3dEntity* m_NativePtr;
};
class BMMeshTransition { class BMMeshTransition {
private: private:
struct TransitionVertex { struct TransitionVertex {
@ -64,9 +19,9 @@ namespace BMap {
LibCmo::VxMath::VxVector2 m_UV; LibCmo::VxMath::VxVector2 m_UV;
}; };
struct TransitionFace { struct TransitionFace {
TransitionFace(uint32_t _i1, uint32_t _i2, uint32_t _i3, uint32_t mtl_id); TransitionFace(LibCmo::CKDWORD _i1, LibCmo::CKDWORD _i2, LibCmo::CKDWORD _i3, LibCmo::CKDWORD mtl_id);
uint32_t m_Idx1, m_Idx2, m_Idx3; LibCmo::CKDWORD m_Idx1, m_Idx2, m_Idx3;
uint32_t m_MtlSlotIdx; LibCmo::CKDWORD m_MtlSlotIdx;
}; };
struct TransitionVertexCompare { struct TransitionVertexCompare {
bool operator()(const TransitionVertex& lhs, const TransitionVertex& rhs) const; bool operator()(const TransitionVertex& lhs, const TransitionVertex& rhs) const;
@ -76,54 +31,81 @@ namespace BMap {
BMMeshTransition(); BMMeshTransition();
~BMMeshTransition(); ~BMMeshTransition();
void PrepareVertexCount(uint32_t count); void PrepareVertexCount(LibCmo::CKDWORD count);
void PrepareVertex(uint32_t index, float x, float y, float z); LibCmo::VxMath::VxVector3* PrepareVertex();
void PrepareNormalCount(uint32_t count); void PrepareNormalCount(LibCmo::CKDWORD count);
void PrepareNormal(uint32_t index, float x, float y, float z); LibCmo::VxMath::VxVector3* PrepareNormal();
void PrepareUVCount(uint32_t count); void PrepareUVCount(LibCmo::CKDWORD count);
void PrepareUV(uint32_t index, float u, float v); LibCmo::VxMath::VxVector2* PrepareUV();
void PrepareMtlSlotCount(uint32_t count); void PrepareMtlSlotCount(LibCmo::CKDWORD count);
void PrepareMtlSlot(uint32_t index, BMMaterial* mtl); LibCmo::CK2::ObjImpls::CKMaterial** PrepareMtlSlot();
void PrepareFaceCount(uint32_t count); void PrepareFaceCount(LibCmo::CKDWORD count);
void PrepareFaceVertexIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3); LibCmo::CKDWORD* PrepareFaceVertexIndices();
void PrepareFaceNormalIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3); LibCmo::CKDWORD* PrepareFaceNormalIndices();
void PrepareFaceUVIndices(uint32_t index, uint32_t indice1, uint32_t indice2, uint32_t indice3); LibCmo::CKDWORD* PrepareFaceUVIndices();
void PrepareFaceMtlSlot(uint32_t index, uint32_t mtl_slot); LibCmo::CKDWORD* PrepareFaceMtlSlot();
bool Parse(BMMesh* write_into_mesh); bool Parse(LibCmo::CK2::ObjImpls::CKMesh* write_into_mesh);
private: private:
void DoRealParse(); void DoRealParse();
void ApplyToMesh(BMMesh* write_into_mesh); void ApplyToMesh(LibCmo::CK2::ObjImpls::CKMesh* write_into_mesh);
bool m_IsVertexOK, m_IsNormalOK, m_IsUVOK, m_IsFaceOK, m_IsMtlSlotOK; bool m_IsVertexOK, m_IsNormalOK, m_IsUVOK, m_IsFaceOK, m_IsMtlSlotOK;
bool m_IsParsed; bool m_IsParsed;
std::vector<LibCmo::VxMath::VxVector3> m_Vertexs, m_Normals; std::vector<LibCmo::VxMath::VxVector3> m_Vertexs, m_Normals;
std::vector<LibCmo::VxMath::VxVector2> m_UVs; std::vector<LibCmo::VxMath::VxVector2> m_UVs;
std::vector<uint32_t> m_FaceVertexs, m_FaceNormals, m_FaceUVs; std::vector<LibCmo::CKDWORD> m_FaceVertexs, m_FaceNormals, m_FaceUVs;
std::vector<uint32_t> m_FaceMtlSlotIdxs; std::vector<LibCmo::CKDWORD> m_FaceMtlSlotIdxs;
std::vector<BMMaterial*> m_MtlSlots; std::vector<LibCmo::CK2::ObjImpls::CKMaterial*> m_MtlSlots;
std::vector<TransitionVertex> m_ProcVertexs; std::vector<TransitionVertex> m_ProcVertexs;
std::vector<TransitionFace> m_ProcFaces; std::vector<TransitionFace> m_ProcFaces;
// unordered_map have performance problem when dealing with massive data (in this case, big mesh) /**
// so we use map to get stable time cost. @brief The core duplication vertex remover.
std::map<TransitionVertex, uint32_t, TransitionVertexCompare> m_ProcDupRemover; @remark
unordered_map have performance problem when dealing with massive data (in this case, big mesh).
so we use map to get stable time cost.
*/
std::map<TransitionVertex, LibCmo::CKDWORD, TransitionVertexCompare> m_ProcDupRemover;
}; };
class BMFile { class BMFile {
public: public:
BMFile(); BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[], bool is_reader);
~BMFile(); ~BMFile();
bool Load(LibCmo::CKSTRING filename);
bool Save(LibCmo::CKSTRING filename, LibCmo::CKINT compress_level);
#define VISITOR_DECL(namepart) \
LibCmo::CKDWORD Get ## namepart ## Count(); \
LibCmo::CK2::ObjImpls::CK ## namepart * Get ## namepart (LibCmo::CKDWORD idx); \
LibCmo::CK2::ObjImpls::CK ## namepart * Create ## namepart (LibCmo::CKSTRING name);
VISITOR_DECL(Group)
VISITOR_DECL(3dObject)
VISITOR_DECL(Mesh)
VISITOR_DECL(Material)
VISITOR_DECL(Texture)
#undef VISITOR_DECL
private: private:
bool m_IsReader;
LibCmo::CK2::CKContext* m_Context; LibCmo::CK2::CKContext* m_Context;
std::vector<LibCmo::CK2::ObjImpls::CKGroup*> m_ObjGroups;
std::vector<LibCmo::CK2::ObjImpls::CK3dObject*> m_Obj3dObjects; #define VISITOR_SELF(namepart) \
std::vector<LibCmo::CK2::ObjImpls::CKMesh*> m_ObjMeshs; std::vector<LibCmo::CK2::ObjImpls::CK ## namepart *> m_Obj ## namepart ## s;
std::vector<LibCmo::CK2::ObjImpls::CKMaterial*> m_ObjMaterials;
std::vector<LibCmo::CK2::ObjImpls::CKTexture*> m_ObjTextures; VISITOR_SELF(Group)
VISITOR_SELF(3dObject)
VISITOR_SELF(Mesh)
VISITOR_SELF(Material)
VISITOR_SELF(Texture)
#undef VISITOR_SELF
}; };
} }

View File

@ -392,7 +392,7 @@ namespace LibCmo::CK2 {
// reserve class info array. // reserve class info array.
g_CKClassInfo.reserve(static_cast<size_t>(CK_CLASSID::CKCID_MAXCLASSID)); g_CKClassInfo.reserve(static_cast<size_t>(CK_CLASSID::CKCID_MAXCLASSID));
// todo: add class type registrations // MARK: add class type registrations here
#define EasyClassReg(clsname, cid, parentCid, strName) \ #define EasyClassReg(clsname, cid, parentCid, strName) \
CKClassRegister(cid, parentCid, \ CKClassRegister(cid, parentCid, \
nullptr, \ nullptr, \

View File

@ -154,6 +154,7 @@ namespace LibCmo::CK2 {
XContainer::XBitArray CKGetAllNotifyClassID(const XContainer::XBitArray& delObjCids); XContainer::XBitArray CKGetAllNotifyClassID(const XContainer::XBitArray& delObjCids);
// ========== Initializations functions ========== // ========== Initializations functions ==========
CKERROR CKStartUp(); CKERROR CKStartUp();
CKERROR CKShutdown(); CKERROR CKShutdown();

View File

@ -145,6 +145,8 @@ namespace LibCmo::CK2::ObjImpls {
// so we just read it and skip it. // so we just read it and skip it.
CK_ID placeid; CK_ID placeid;
chunk->ReadObjectID(placeid); chunk->ReadObjectID(placeid);
// and remove this flag
EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PLACEVALID);
} }
// read parent // read parent
@ -153,6 +155,8 @@ namespace LibCmo::CK2::ObjImpls {
// we ignore this field. // we ignore this field.
CK_ID parentid; CK_ID parentid;
chunk->ReadObjectID(parentid); chunk->ReadObjectID(parentid);
// and remove this flag
EnumsHelper::Rm(m_3dEntityFlags, CK_3DENTITY_FLAGS::CK_3DENTITY_PARENTVALID);
} }
// read priority (non-zero zorder) // read priority (non-zero zorder)