The decompiled C++ tree moves to generated-src/ (classes.h, C++20); src/ is for code written by hand. A curated function defines the generated declaration and starts its comment with its address, and source_tree.py stops emitting that body. src/rng.cpp takes over RNG (SetSeed, the constructor, Next, RandomInt, RandomFloat, Shuffle) with the shift table read from the exe as a constexpr array; src/log.h names KAGE_LogMessage's levels (1 INFO, 2 NET, 4 WARN, 8 ERROR, 16 ASSERT, from its prefix jump table). CMakeLists.txt builds src/*.cpp against generated-src/classes.h (clean with -Wall -Wextra). structs.hpp and headers.py are retired: scripts/merge_fields.py writes the merged field list, classes.h checks the layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
215 lines
8.3 KiB
C++
215 lines
8.3 KiB
C++
#include "classes.h"
|
|
|
|
// 0091acc0
|
|
void * PersistentGameDataWriter::compress(uint *outSize)
|
|
{
|
|
uint dataSize;
|
|
void *pvVar1;
|
|
undefined4 extraout_ECX;
|
|
undefined4 extraout_ECX_00;
|
|
undefined4 uVar2;
|
|
undefined4 extraout_ECX_01;
|
|
int streamData;
|
|
|
|
dataSize = (**(code **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x48)) + 8))();
|
|
*outSize = dataSize;
|
|
pvVar1 = operator_new_tracked(dataSize);
|
|
dataSize = *outSize;
|
|
streamData = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x38));
|
|
if (streamData == 0) {
|
|
streamData = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x2c));
|
|
}
|
|
uVar2 = extraout_ECX;
|
|
if (g_deflateCompressor == (void *)0x0) {
|
|
g_deflateCompressor = operator_new(0x14);
|
|
if (g_deflateCompressor == GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
g_deflateCompressor = GHIDRA_CAST<undefined4 *>(0x0);
|
|
}
|
|
else {
|
|
*GHIDRA_CAST<undefined4 *>(g_deflateCompressor) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_deflateCompressor) + 4)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_deflateCompressor) + 0xc)) = 0;
|
|
}
|
|
uVar2 = extraout_ECX_00;
|
|
}
|
|
FUN_00a89ba0(uVar2);
|
|
dataSize = tdefl_compress(pvVar1,dataSize,streamData,dataSize,extraout_ECX_01);
|
|
*outSize = dataSize;
|
|
return pvVar1;
|
|
}
|
|
|
|
// 0091b130
|
|
void PersistentGameDataWriter::write(PersistentGameData *data, void *header)
|
|
{
|
|
undefined4 killCount;
|
|
undefined4 uVar2;
|
|
undefined4 uVar3;
|
|
undefined4 *puVar4;
|
|
undefined4 *puVar5;
|
|
uint uVar6;
|
|
void *node;
|
|
int *piVar7;
|
|
undefined4 *entriesEnd;
|
|
void *local_3c;
|
|
undefined4 killKey;
|
|
void *local_34;
|
|
undefined4 *local_30;
|
|
undefined4 encounterKey;
|
|
undefined4 *local_28;
|
|
undefined4 *self;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
uint killCount;
|
|
|
|
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00b0a0f5;
|
|
local_1c = ExceptionList;
|
|
ExceptionList = &local_1c;
|
|
self = this;
|
|
(**(code **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x48)) + 0xc))
|
|
(0,0,__security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U);
|
|
uVar6 = (data->_bestiaryEncounters)._size;
|
|
killCount = (data->_bestiaryKills)._size;
|
|
(**(code **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20)) + 8))();
|
|
(**(code **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20)) + 4))((uVar6 + killCount) * 8 + 0x994,0xffffffff);
|
|
*GHIDRA_CAST<undefined4 *>(this) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
|
|
FUN_0091b580(data->_achievements,0x282);
|
|
piVar7 = self + 0x12;
|
|
(**(code **)(*piVar7 + 0x1c))(data->_eventCounters,1,0x82c);
|
|
FUN_0091b580(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((data)) + 0xae8))),0x2dd);
|
|
(**(code **)(*piVar7 + 0x1c))(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((data)) + 0xdc8))),1,0x38);
|
|
FUN_0091b580(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((data)) + 0xe00))),7);
|
|
FUN_0091b580(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((data)) + 0xe07))),0x68);
|
|
(**(code **)(*piVar7 + 0x1c))(data->_cutsceneCounters,1,0x6c);
|
|
FUN_0091b580(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((data)) + 0xe6f))),0x2e);
|
|
local_28 = GHIDRA_CAST<undefined4 *>(0x0);
|
|
entriesEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_30 = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 0;
|
|
local_3c = (void *)(data->_bestiaryEncounters)._size;
|
|
node = *(void **)(data->_bestiaryEncounters)._head;
|
|
local_34 = node;
|
|
if (local_3c != (void *)0x0) {
|
|
if ((void *)0x1fffffff < local_3c) {
|
|
/* WARNING: Subroutine does not return */
|
|
std::_Xlen();
|
|
}
|
|
std::vector<8byte>::_Reallocate_exactly(local_3c);
|
|
}
|
|
local_30 = GHIDRA_CAST<undefined4 *>(0x0);
|
|
puVar5 = GHIDRA_CAST<undefined4 *>(0x0);
|
|
if (node != (data->_bestiaryEncounters)._head) {
|
|
do {
|
|
local_28 = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(node) + 0x14));
|
|
encounterKey = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(node) + 0x10));
|
|
if (entriesEnd == local_30) {
|
|
std::vector<8byte>::_Emplace_reallocate(entriesEnd,&encounterKey);
|
|
local_30 = GHIDRA_CAST<undefined4 *>(0x0);
|
|
}
|
|
else {
|
|
*entriesEnd = encounterKey;
|
|
entriesEnd[1] = local_28;
|
|
entriesEnd = entriesEnd + 2;
|
|
}
|
|
std::
|
|
_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<unsigned_int>_>,std::_Iterator_base0>
|
|
::operator++((_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<unsigned_int>_>,std::_Iterator_base0>
|
|
*)&local_34);
|
|
node = local_34;
|
|
puVar5 = entriesEnd;
|
|
} while (local_34 != (data->_bestiaryEncounters)._head);
|
|
}
|
|
puVar4 = self;
|
|
local_28 = (void *)0x0;
|
|
local_3c = (void *)(GHIDRA_INT(puVar5) >> 3);
|
|
(**(code **)(self[0x12] + 0x1c))(&local_3c,1,4);
|
|
if (local_3c != (void *)0x0) {
|
|
(**(code **)(puVar4[0x12] + 0x1c))(local_28,1,GHIDRA_INT(local_3c) << 3);
|
|
}
|
|
local_14 = 0xffffffff;
|
|
if (local_28 != (void *)0x0) {
|
|
uVar6 = (GHIDRA_INT(local_30) - GHIDRA_INT(local_28) >> 3) * 8;
|
|
puVar5 = local_28;
|
|
if (0xfff < uVar6) {
|
|
puVar5 = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(local_28) + -4));
|
|
uVar6 = uVar6 + 0x23;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(local_28) + (-4 - GHIDRA_INT(puVar5))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(puVar5,uVar6);
|
|
}
|
|
local_34 = (void *)0x0;
|
|
local_28 = GHIDRA_CAST<undefined4 *>(0x0);
|
|
entriesEnd = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_14 = 1;
|
|
uVar6 = (data->_bestiaryKills)._size;
|
|
node = *(void **)(data->_bestiaryKills)._head;
|
|
local_3c = node;
|
|
if (uVar6 != 0) {
|
|
if (0x1fffffff < uVar6) {
|
|
/* WARNING: Subroutine does not return */
|
|
std::_Xlen();
|
|
}
|
|
std::vector<8byte>::_Reallocate_exactly(uVar6);
|
|
}
|
|
local_28 = GHIDRA_CAST<undefined4 *>(0x0);
|
|
local_34 = (void *)0x0;
|
|
if (node != (data->_bestiaryKills)._head) {
|
|
do {
|
|
local_34 = *(void **)(GHIDRA_CAST<char *>(node) + 0x14);
|
|
killKey = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(node) + 0x10));
|
|
if (local_28 == GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
std::vector<8byte>::_Emplace_reallocate(0,&killKey);
|
|
}
|
|
else {
|
|
*local_28 = killKey;
|
|
local_28[1] = local_34;
|
|
entriesEnd = local_28 + 2;
|
|
}
|
|
local_28 = entriesEnd;
|
|
std::
|
|
_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<unsigned_int>_>,std::_Iterator_base0>
|
|
::operator++((_Tree_unchecked_const_iterator<std::_Tree_val<std::_Tree_simple_types<unsigned_int>_>,std::_Iterator_base0>
|
|
*)&local_3c);
|
|
node = local_3c;
|
|
} while (local_3c != (data->_bestiaryKills)._head);
|
|
}
|
|
local_30 = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(local_28) >> 3));
|
|
(**(code **)(self[0x12] + 0x1c))(&local_30,1,4);
|
|
if (local_30 != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
(**(code **)(self[0x12] + 0x1c))(0,1,GHIDRA_INT(local_30) << 3);
|
|
}
|
|
puVar5 = self;
|
|
local_14 = 0xffffffff;
|
|
(**(code **)(self[0x12] + 0xc))(0,2);
|
|
killCount = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(header) + 4));
|
|
uVar2 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(header) + 8));
|
|
uVar3 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(header) + 0xc));
|
|
*puVar5 = *GHIDRA_CAST<undefined4 *>(header);
|
|
puVar5[1] = killCount;
|
|
puVar5[2] = uVar2;
|
|
puVar5[3] = uVar3;
|
|
killCount = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(header) + 0x14));
|
|
uVar2 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(header) + 0x18));
|
|
uVar3 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(header) + 0x1c));
|
|
puVar5[4] = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(header) + 0x10));
|
|
puVar5[5] = killCount;
|
|
puVar5[6] = uVar2;
|
|
puVar5[7] = uVar3;
|
|
(**(code **)(puVar5[0x12] + 0x1c))(puVar5,1,0x20);
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|