From 7c6dd463bd6dd5efaf4e13ab369750bea2af4d9e Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 15 Nov 2023 23:05:21 +0800 Subject: [PATCH] fix issues - fix nullptr name assignment error on CKObject. - remove slot check for CKTexture::GetFileName in BMap. return nullptr, not throw error when no slot to get file name. --- BMap/BMExports.cpp | 2 -- LibCmo/CK2/ObjImpls/CKObject.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/BMap/BMExports.cpp b/BMap/BMExports.cpp index 3d1a0c9..ba31a4c 100644 --- a/BMap/BMExports.cpp +++ b/BMap/BMExports.cpp @@ -371,8 +371,6 @@ bool BMTexture_GetFileName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCm auto obj = CheckCKTexture(bmfile, objid); if (obj == nullptr) return false; - if (obj->GetUnderlyingData().GetSlotCount() == 0) return false; - BMPARAM_OUT_ASSIGN(out_filename, obj->GetUnderlyingData().GetSlotFileName(0)); return true; } diff --git a/LibCmo/CK2/ObjImpls/CKObject.cpp b/LibCmo/CK2/ObjImpls/CKObject.cpp index 2afbb00..2235e71 100644 --- a/LibCmo/CK2/ObjImpls/CKObject.cpp +++ b/LibCmo/CK2/ObjImpls/CKObject.cpp @@ -5,9 +5,12 @@ namespace LibCmo::CK2::ObjImpls { CKObject::CKObject(CKContext* ctx, CK_ID ckid, CKSTRING name) : m_ID(ckid), - m_Name(name), + m_Name(), m_Context(ctx), - m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED) {} + m_ObjectFlags(CK_OBJECT_FLAGS::CK_PARAMETERIN_DISABLED) { + // set name with possible nullptr. + XContainer::NSXString::FromCKSTRING(m_Name, name); + } CKObject::~CKObject() {}