fix saving issue

- fix CKStateChunk resize memory error.
- fix wrong CKBitmapHandler free position in CKBitmapData writer.
- fix init value error of CKFileWriter::m_DisableAddingFile when copying from reader.
- fix ReadString, WriteString error in CKStateChunk (forget NULL terminal)
- change CKPathManager resolve path order. Resolve temp path first, then resources folder.
- fix mixdata combine error when writing CKTexture.
This commit is contained in:
2023-09-30 16:01:39 +08:00
parent abea66d6f0
commit ee4b621cac
10 changed files with 62 additions and 36 deletions

View File

@ -140,18 +140,25 @@ namespace LibCmo::CK2 {
XContainer::XString cache;
m_BindContext->GetNativeString(*strl, cache);
// get size
CKDWORD strByteSize = static_cast<CKDWORD>(cache.size());
if (!this->WriteStruct(strByteSize)) {
return false;
}
if (cache.empty()) {
// write zero string
return this->WriteStruct(0);
} else {
// write string with NULL terminal
// write data
if (!this->WriteByteData(cache.c_str(), strByteSize)) {
return false;
}
// write size
CKDWORD strByteSize = static_cast<CKDWORD>(cache.size()) + 1;
if (!this->WriteStruct(strByteSize)) {
return false;
}
return true;
// write data with NULL terminal
if (!this->WriteByteData(cache.c_str(), strByteSize)) {
return false;
}
return true;
}
}
bool CKStateChunk::WriteObjectID(const CK_ID* id) {