Reconstruction layout: generated-src/ (generated) and src/ (curated), CMake, the first takeover: RNG
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>
This commit is contained in:
1 parent
2ff2d5d87f
commit
3ce74c6e2d
331 files changed
+485
-7835
No files matched your search
@@ -0,0 +1,196 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 00828b60
|
||||
void RoomConfigMode::ctor()
|
||||
{
|
||||
void *treeHead;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
|
||||
puStack_c = &LAB_00af192d;
|
||||
local_10 = ExceptionList;
|
||||
ExceptionList = &local_10;
|
||||
*GHIDRA_CAST<undefined4 *>(this) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0xf;
|
||||
*GHIDRA_CAST<undefined1 *>(this) = 0;
|
||||
local_8 = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x24)) = 0;
|
||||
treeHead = operator_new(0x18);
|
||||
*(void **)treeHead = treeHead;
|
||||
*(void **)(GHIDRA_CAST<char *>(treeHead) + 4) = treeHead;
|
||||
*(void **)(GHIDRA_CAST<char *>(treeHead) + 8) = treeHead;
|
||||
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(treeHead) + 0xc)) = 0x101;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)) = treeHead;
|
||||
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(this) + 0x28)) = 0;
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
|
||||
// 00828c00
|
||||
void RoomConfigMode::Clear()
|
||||
{
|
||||
void *roomMap = this;
|
||||
undefined4 *this_00;
|
||||
qword qVar1;
|
||||
void *pvVar2;
|
||||
qword *allocCounter;
|
||||
int spawnOffset;
|
||||
int spawnEntry;
|
||||
int *mapNode;
|
||||
int room;
|
||||
int *piVar3;
|
||||
int roomOffset;
|
||||
uint roomIdx;
|
||||
uint spawnIdx;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 uStack_8;
|
||||
uint *blockHeader;
|
||||
uint blockSize;
|
||||
undefined4 *entryList;
|
||||
char isNil;
|
||||
void *nextNode;
|
||||
int *parentNode;
|
||||
|
||||
uStack_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b01a70;
|
||||
local_10 = ExceptionList;
|
||||
ExceptionList = &local_10;
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(roomMap) + 0x1c)) != 0) {
|
||||
KAGE_LogMessage(1,GHIDRA_CAST<byte *>("delete %d rooms.\n"));
|
||||
roomIdx = 0;
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(roomMap) + 0x1c)) != 0) {
|
||||
roomOffset = 0;
|
||||
pvVar2 = g_mainHeap;
|
||||
do {
|
||||
room = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(roomMap) + 0x18)) + roomOffset;
|
||||
if (*GHIDRA_CAST<short *>((room + 0x44)) != 0) {
|
||||
spawnIdx = 0;
|
||||
spawnOffset = 0;
|
||||
do {
|
||||
spawnEntry = *GHIDRA_CAST<int *>((room + 0x40)) + spawnOffset;
|
||||
if (*GHIDRA_CAST<char *>((spawnEntry + 8)) != '\0') {
|
||||
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(pvVar2) + 0x30));
|
||||
if (pvVar2 == (void *)0x0) {
|
||||
allocCounter = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
if (*GHIDRA_CAST<int *>((spawnEntry + 4)) != 0) {
|
||||
blockHeader = GHIDRA_CAST<uint *>((*GHIDRA_CAST<int *>((spawnEntry + 4)) + -4));
|
||||
blockSize = *blockHeader;
|
||||
qVar1 = *allocCounter;
|
||||
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < blockSize));
|
||||
free(blockHeader);
|
||||
pvVar2 = g_mainHeap;
|
||||
}
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((spawnEntry + 4)) = 0;
|
||||
spawnOffset = spawnOffset + 0x10;
|
||||
*GHIDRA_CAST<undefined1 *>((spawnEntry + 8)) = 0;
|
||||
spawnIdx = spawnIdx + 1;
|
||||
} while (spawnIdx < *GHIDRA_CAST<ushort *>((room + 0x44)));
|
||||
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(pvVar2) + 0x30));
|
||||
if (pvVar2 == (void *)0x0) {
|
||||
allocCounter = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
if (*GHIDRA_CAST<int *>((room + 0x40)) != 0) {
|
||||
blockHeader = GHIDRA_CAST<uint *>((*GHIDRA_CAST<int *>((room + 0x40)) + -4));
|
||||
blockSize = *blockHeader;
|
||||
qVar1 = *allocCounter;
|
||||
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < blockSize));
|
||||
free(blockHeader);
|
||||
pvVar2 = g_mainHeap;
|
||||
}
|
||||
uStack_8 = 0xffffffff;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>((room + 0x40)) = 0;
|
||||
roomIdx = roomIdx + 1;
|
||||
*GHIDRA_CAST<undefined2 *>((room + 0x44)) = 0;
|
||||
roomOffset = roomOffset + 0x5c;
|
||||
} while (roomIdx < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(roomMap) + 0x1c)));
|
||||
}
|
||||
pvVar2 = *(void **)(GHIDRA_CAST<char *>(roomMap) + 0x18);
|
||||
if (pvVar2 != (void *)0x0) {
|
||||
blockHeader = GHIDRA_CAST<uint *>((GHIDRA_INT(pvVar2) + -4));
|
||||
uStack_8 = 2;
|
||||
_eh_vector_destructor_iterator_(pvVar2,0x5c,*blockHeader,RoomConfigRoom::dtor);
|
||||
operator_delete(blockHeader,*blockHeader * 0x5c + 4);
|
||||
}
|
||||
}
|
||||
piVar3 = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(roomMap) + 0x20));
|
||||
this_00 = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(roomMap) + 0x20));
|
||||
mapNode = GHIDRA_CAST<int *>(*piVar3);
|
||||
if (mapNode != piVar3) {
|
||||
do {
|
||||
entryList = GHIDRA_CAST<undefined4 *>(mapNode[5]);
|
||||
if (entryList != GHIDRA_CAST<undefined4 *>(0x0)) {
|
||||
pvVar2 = (void *)*entryList;
|
||||
while (pvVar2 != (void *)0x0) {
|
||||
nextNode = *(void **)(GHIDRA_CAST<char *>(pvVar2) + 8);
|
||||
operator_delete(pvVar2,0xc);
|
||||
pvVar2 = nextNode;
|
||||
}
|
||||
*entryList = 0;
|
||||
operator_delete(entryList,4);
|
||||
mapNode[5] = 0;
|
||||
}
|
||||
piVar3 = GHIDRA_CAST<int *>(mapNode[2]);
|
||||
if (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(piVar3) + 0xd)) == '\0') {
|
||||
isNil = *GHIDRA_CAST<char *>((*piVar3 + 0xd));
|
||||
mapNode = piVar3;
|
||||
piVar3 = GHIDRA_CAST<int *>(*piVar3);
|
||||
while (isNil == '\0') {
|
||||
isNil = *GHIDRA_CAST<char *>((*piVar3 + 0xd));
|
||||
mapNode = piVar3;
|
||||
piVar3 = GHIDRA_CAST<int *>(*piVar3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
isNil = *GHIDRA_CAST<char *>((mapNode[1] + 0xd));
|
||||
parentNode = GHIDRA_CAST<int *>(mapNode[1]);
|
||||
piVar3 = mapNode;
|
||||
while ((mapNode = parentNode, isNil == '\0' && (piVar3 == GHIDRA_CAST<int *>(mapNode[2])))) {
|
||||
isNil = *GHIDRA_CAST<char *>((mapNode[1] + 0xd));
|
||||
parentNode = GHIDRA_CAST<int *>(mapNode[1]);
|
||||
piVar3 = mapNode;
|
||||
}
|
||||
}
|
||||
piVar3 = GHIDRA_CAST<int *>(*this_00);
|
||||
} while (mapNode != piVar3);
|
||||
}
|
||||
FID_conflict__Erase_tree<fuzzer::fuzzer_allocator<std::_Tree_node<fuzzer::TracePC::PCTableEntry_const*,void*>_>_>
|
||||
(this_00,(fuzzer_allocator<std::_Tree_node<unsigned_int,void*>_> *)this_00,
|
||||
(_Tree_node<unsigned_int,void*> *)piVar3[1]);
|
||||
piVar3[1] = GHIDRA_INT(piVar3);
|
||||
*piVar3 = GHIDRA_INT(piVar3);
|
||||
piVar3[2] = GHIDRA_INT(piVar3);
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(roomMap) + 0x24)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(roomMap) + 0x1c)) = 0;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(roomMap) + 0x18)) = 0;
|
||||
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(roomMap) + 0x28)) = 0;
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
|
||||
// 00829260
|
||||
void RoomConfigMode::dtor()
|
||||
{
|
||||
char *this;
|
||||
char *in_ECX;
|
||||
|
||||
this = in_ECX + 0x20;
|
||||
FID_conflict__Erase_tree<fuzzer::fuzzer_allocator<std::_Tree_node<fuzzer::TracePC::PCTableEntry_const*,void*>_>_>
|
||||
(this,(fuzzer_allocator<std::_Tree_node<unsigned_int,void*>_> *)this,
|
||||
*(_Tree_node<unsigned_int,void*> **)(*GHIDRA_CAST<int *>((in_ECX + 0x20)) + 4));
|
||||
operator_delete(*(void **)this,0x18);
|
||||
(GHIDRA_CAST<std::string *>((in_ECX)))->std::string::_Tidy_deallocate();
|
||||
return;
|
||||
}
|
||||
Reference in new issue
Block a user