fix some fatal error when fully-rewrite file

This commit is contained in:
2023-08-28 22:20:46 +08:00
parent f3e7cdf004
commit 0887cd6d86
5 changed files with 55 additions and 8 deletions

View File

@ -20,8 +20,8 @@ namespace LibCmo::CK2 {
/**
* @brief Current Version of Dev
*/
constexpr const CKDWORD DEVVERSION = 0x02010001u;
constexpr const CKDWORD DEVBUILD = 0u;
constexpr const CKDWORD DEVBUILD = 0x02010001u;
constexpr const CKDWORD DEVVERSION = 0u;
constexpr const CKGUID VIRTOOLS_GUID = CKGUID(0x56495254u, 0x4f4f4c53u);
// ========== Class registration utilities ==========

View File

@ -87,8 +87,13 @@ namespace LibCmo::CK2 {
CKDWORD sumDataObjSize = 0,
sumHdrObjSize = 0;
for (auto& obj : m_FileObjects) {
// += 4DWORD(ObjId, ObjCid, FileIndex, NameLen) + Name size
sumHdrObjSize += 4 * sizeof(CKDWORD) + obj.Name.size();
// += 4DWORD(ObjId, ObjCid, FileIndex, NameLen)
sumHdrObjSize += 4 * sizeof(CKDWORD);
if (obj.Name.c_str() != nullptr) {
// += Name size
m_Ctx->GetNativeString(obj.Name.string(), name_conv);
sumHdrObjSize += name_conv.size();
}
if (obj.Data == nullptr) {
obj.PackSize = 0;