From 74d8f02588db036254c0246e5f34f89044f4ae21 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Thu, 30 Nov 2023 22:48:40 +0800 Subject: [PATCH] fix issues - fix usage error of ckid getter in bmap wrapper. - fix CKObject flag init value error. - fix CKFileWriter writing empty object name error. - regulate some statement. --- BMapBindings/PyBMap/PyBMap/bmap_wrapper.py | 16 ++++++++-------- IronPad/IronPad.hpp | 2 +- LibCmo/CK2/CKFileReader.cpp | 2 +- LibCmo/CK2/CKFileWriter.cpp | 5 +++++ LibCmo/CK2/ObjImpls/CKObject.cpp | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/BMapBindings/PyBMap/PyBMap/bmap_wrapper.py b/BMapBindings/PyBMap/PyBMap/bmap_wrapper.py index 6c27172..8ac79d9 100644 --- a/BMapBindings/PyBMap/PyBMap/bmap_wrapper.py +++ b/BMapBindings/PyBMap/PyBMap/bmap_wrapper.py @@ -279,7 +279,7 @@ class BMMaterial(BMObject): def set_texture(self, tex_: BMTexture | None) -> None: objid: bmap.bm_CKID = bmap.bm_CKID(g_InvalidCKID) if tex_ is not None: - objid.value = tex_._get_ckid() + objid = tex_._get_ckid() bmap.BMMaterial_SetTexture(self._get_pointer(), self._get_ckid(), objid) def get_texture_border_color(self) -> virtools_types.VxColor: @@ -521,7 +521,7 @@ class BMMesh(BMObject): if mtlobj is None: mtlid.value = g_InvalidCKID else: - mtlid.value = mtlobj._get_ckid() + mtlid = mtlobj._get_ckid() # set bmap.BMMesh_SetMaterialSlot(self._get_pointer(), self._get_ckid(), idx, mtlid) @@ -551,7 +551,7 @@ class BM3dObject(BMObject): def set_current_mesh(self, mesh: BMMesh | None) -> None: ckid: bmap.bm_CKID = bmap.bm_CKID(g_InvalidCKID) if mesh is not None: - ckid.value = mesh._get_ckid() + ckid = mesh._get_ckid() bmap.BM3dObject_SetCurrentMesh(self._get_pointer(), self._get_ckid(), ckid) def get_visibility(self) -> bool: @@ -733,31 +733,31 @@ class BMFileWriter(_AbstractPointer): return class_type(self._get_pointer(), retid) def create_texture(self) -> BMTexture: - self.__create_ckobject( + return self.__create_ckobject( BMTexture, bmap.BMFile_CreateTexture ) def create_material(self) -> BMMaterial: - self.__create_ckobject( + return self.__create_ckobject( BMMaterial, bmap.BMFile_CreateMaterial ) def create_mesh(self) -> BMMesh: - self.__create_ckobject( + return self.__create_ckobject( BMMesh, bmap.BMFile_CreateMesh ) def create_3dobject(self) -> BM3dObject: - self.__create_ckobject( + return self.__create_ckobject( BM3dObject, bmap.BMFile_Create3dObject ) def create_group(self) -> BMGroup: - self.__create_ckobject( + return self.__create_ckobject( BMGroup, bmap.BMFile_CreateGroup ) diff --git a/IronPad/IronPad.hpp b/IronPad/IronPad.hpp index 67c2874..7224ed8 100644 --- a/IronPad/IronPad.hpp +++ b/IronPad/IronPad.hpp @@ -8,7 +8,7 @@ #endif // Debug IronPad used. Force enable IronPad. -#define IRONPAD_ENABLED 1 +//#define IRONPAD_ENABLED 1 namespace IronPad { diff --git a/LibCmo/CK2/CKFileReader.cpp b/LibCmo/CK2/CKFileReader.cpp index 79f6a18..48f47e2 100644 --- a/LibCmo/CK2/CKFileReader.cpp +++ b/LibCmo/CK2/CKFileReader.cpp @@ -131,7 +131,7 @@ namespace LibCmo::CK2 { parser->Read(name_conv.data(), namelen); m_Ctx->GetUtf8String(name_conv, fileobj.Name); } else { - fileobj.Name.clear(); + XContainer::NSXString::FromCKSTRING(fileobj.Name, nullptr); } } } diff --git a/LibCmo/CK2/CKFileWriter.cpp b/LibCmo/CK2/CKFileWriter.cpp index 1ef99f6..d02e2b3 100644 --- a/LibCmo/CK2/CKFileWriter.cpp +++ b/LibCmo/CK2/CKFileWriter.cpp @@ -175,10 +175,15 @@ namespace LibCmo::CK2 { hdrparser->Write(&obj.FileIndex); if (XContainer::NSXString::ToCKSTRING(obj.Name) != nullptr) { + // if have name, write it m_Ctx->GetNativeString(obj.Name, name_conv); CKDWORD namelen = static_cast(name_conv.size()); hdrparser->Write(&namelen); hdrparser->Write(name_conv.data(), namelen); + } else { + // otherwise, write 0 to indicate no name + CKDWORD namelen = 0; + hdrparser->Write(&namelen); } } diff --git a/LibCmo/CK2/ObjImpls/CKObject.cpp b/LibCmo/CK2/ObjImpls/CKObject.cpp index 2235e71..7bdaec0 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.cpp +++ b/LibCmo/CK2/ObjImpls/CKObject.cpp @@ -7,7 +7,7 @@ namespace LibCmo::CK2::ObjImpls { m_ID(ckid), m_Name(), m_Context(ctx), - m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED) { + m_ObjectFlags(CK_OBJECT_FLAGS::CK_OBJECT_VISIBLE) { // set name with possible nullptr. XContainer::NSXString::FromCKSTRING(m_Name, name); }