fix: fix issues

- restore some CKGlobals behavior because it will cause runtime exception.
- move some classes from CmdHelper to UnvirtContext to make CmdHelper more common to use.
- output warning string when fail to get utf8 or ordinary string.
This commit is contained in:
2024-08-27 11:25:53 +08:00
parent 3735a202f3
commit 65861143bf
14 changed files with 91 additions and 70 deletions

View File

@ -187,7 +187,8 @@ namespace LibCmo::CK2::ObjImpls {
props.m_ReaderGuid.d1 = realprops.m_ReaderGuid.d1;
props.m_ReaderGuid.d2 = realprops.m_ReaderGuid.d2;
std::string ext;
m_Context->GetOrdinaryString(realprops.m_Ext.GetExt(), ext);
if (!m_Context->GetOrdinaryString(realprops.m_Ext.GetExt(), ext))
m_Context->OutputToConsole(u8"Fail to get ordinary string for the extension of bitmap properties when saving CKTexture. Some textures may be saved with blank extension.");
std::memcpy(
props.m_Ext.m_Data,
ext.c_str(),
@ -314,7 +315,8 @@ namespace LibCmo::CK2::ObjImpls {
// get utf8 extension
XContainer::XString ext;
m_Context->GetUTF8String(props->m_Ext.m_Data, ext);
if (!m_Context->GetUTF8String(props->m_Ext.m_Data, ext))
m_Context->OutputToConsole(u8"Fail to get UTF8 extension when loading CKTexture. Some textures may have blank extension in bitmap properties.");
// get my bitmap prop
CKBitmapProperties myprops(