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,332 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 008f99c0
|
||||
std_string * Mod::GetContentPath(std_string *outPath, std_string *name)
|
||||
{
|
||||
undefined4 *appendResult;
|
||||
byte ****ppppbVar1;
|
||||
byte *pbVar2;
|
||||
int iVar3;
|
||||
uint uVar4;
|
||||
void *ptr;
|
||||
std_string *psVar5;
|
||||
std_string *nameText;
|
||||
byte ****dlcDir;
|
||||
undefined4 uStack_68;
|
||||
undefined4 uStack_64;
|
||||
undefined4 uStack_60;
|
||||
undefined8 local_5c;
|
||||
void *contentDirTrimmed [4];
|
||||
undefined4 local_44;
|
||||
uint local_40;
|
||||
byte ****dlcPath;
|
||||
undefined4 uStack_38;
|
||||
undefined4 uStack_34;
|
||||
undefined4 uStack_30;
|
||||
undefined4 local_2c;
|
||||
uint uStack_28;
|
||||
uint local_24;
|
||||
undefined1 *puStack_20;
|
||||
void *local_1c;
|
||||
undefined1 *puStack_18;
|
||||
void *local_14;
|
||||
byte *contentDir;
|
||||
uint *nameSize;
|
||||
|
||||
puStack_20 = GHIDRA_CAST<undefined1 *>((contentDirTrimmed + 0x14));
|
||||
local_14 = (void *)0xffffffff;
|
||||
puStack_18 = &LAB_00b07b5d;
|
||||
local_1c = ExceptionList;
|
||||
local_24 = __security_cookie ^ GHIDRA_UINT((contentDirTrimmed + 0x11));
|
||||
ExceptionList = &local_1c;
|
||||
contentDir = GHIDRA_CAST<byte *>((GHIDRA_INT(this) + 0x48));
|
||||
uVar4 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x58)) - 1;
|
||||
if (*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x58)) < uVar4) {
|
||||
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x58));
|
||||
}
|
||||
local_44 = 0;
|
||||
local_40 = 0xf;
|
||||
contentDirTrimmed[0] = (void *)0x0;
|
||||
pbVar2 = contentDir;
|
||||
if (0xf < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x5c))) {
|
||||
pbVar2 = *GHIDRA_CAST<byte **>(contentDir);
|
||||
}
|
||||
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(contentDirTrimmed))))->std::string::assign(pbVar2,uVar4);
|
||||
local_14 = (void *)0x0;
|
||||
appendResult = (GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(contentDirTrimmed))))->std::string::append(GHIDRA_CAST<byte *>("-dlc3/"),6);
|
||||
dlcDir = GHIDRA_CAST<byte ****>(*appendResult);
|
||||
uStack_68 = appendResult[1];
|
||||
uStack_64 = appendResult[2];
|
||||
uStack_60 = appendResult[3];
|
||||
local_5c = *GHIDRA_CAST<undefined8 *>((appendResult + 4));
|
||||
appendResult[4] = 0;
|
||||
appendResult[5] = 0xf;
|
||||
*GHIDRA_CAST<undefined1 *>(appendResult) = 0;
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 2;
|
||||
if (0xf < local_40) {
|
||||
uVar4 = local_40 + 1;
|
||||
ptr = contentDirTrimmed[0];
|
||||
if (0xfff < uVar4) {
|
||||
ptr = *(void **)(GHIDRA_INT(contentDirTrimmed[0]) + -4);
|
||||
uVar4 = local_40 + 0x24;
|
||||
if (0x1f < GHIDRA_UINT((GHIDRA_INT(contentDirTrimmed[0]) + (-4 - GHIDRA_INT(ptr))))) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(ptr,uVar4);
|
||||
}
|
||||
psVar5 = GHIDRA_CAST<std_string *>(name->_size);
|
||||
local_44 = 0;
|
||||
local_40 = 0xf;
|
||||
contentDirTrimmed[0] = (void *)(GHIDRA_UINT(contentDirTrimmed[0]) & 0xffffff00);
|
||||
if (GHIDRA_CAST<std_string *>((0x7fffffff - GHIDRA_UINT(local_5c))) < psVar5) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
std::string::_Xlen();
|
||||
}
|
||||
ppppbVar1 = GHIDRA_CAST<byte ****>(&dlcDir);
|
||||
if (0xf < (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_5c)) + 0x4)))) {
|
||||
ppppbVar1 = dlcDir;
|
||||
}
|
||||
nameText = name;
|
||||
if (0xf < name->_capacity) {
|
||||
nameText = *GHIDRA_CAST<std_string **>(name->_buf);
|
||||
psVar5 = GHIDRA_CAST<std_string *>(name->_size);
|
||||
}
|
||||
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(&dlcPath))))->std::string::concat(GHIDRA_INT(contentDir),psVar5,GHIDRA_CAST<byte *>(ppppbVar1),GHIDRA_UINT(local_5c),
|
||||
GHIDRA_CAST<byte *>(nameText),GHIDRA_UINT(psVar5));
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 3;
|
||||
ppppbVar1 = GHIDRA_CAST<byte ****>(&dlcPath);
|
||||
if (0xf < uStack_28) {
|
||||
ppppbVar1 = dlcPath;
|
||||
}
|
||||
pbVar2 = FileSystem::ResolvePath(GHIDRA_CAST<byte *>(ppppbVar1));
|
||||
if (pbVar2 == GHIDRA_CAST<byte *>(0x0)) {
|
||||
nameSize = &name->_size;
|
||||
psVar5 = GHIDRA_CAST<std_string *>((0x7fffffff - *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x58))));
|
||||
if (psVar5 < GHIDRA_CAST<std_string *>(*nameSize)) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
std::string::_Xlen();
|
||||
}
|
||||
pbVar2 = contentDir;
|
||||
if (0xf < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x5c))) {
|
||||
pbVar2 = *GHIDRA_CAST<byte **>(contentDir);
|
||||
}
|
||||
if (0xf < name->_capacity) {
|
||||
name = *GHIDRA_CAST<std_string **>(name->_buf);
|
||||
}
|
||||
(GHIDRA_CAST<std::string *>((outPath->_buf)))->std::string::concat(GHIDRA_INT(contentDir),psVar5,pbVar2,*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x58)),
|
||||
GHIDRA_CAST<byte *>(name),*nameSize);
|
||||
if (0xf < uStack_28) {
|
||||
uVar4 = uStack_28 + 1;
|
||||
ppppbVar1 = dlcPath;
|
||||
if (0xfff < uVar4) {
|
||||
ppppbVar1 = GHIDRA_CAST<byte ****>(dlcPath[-1]);
|
||||
uVar4 = uStack_28 + 0x24;
|
||||
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(dlcPath) + (-4 - GHIDRA_INT(ppppbVar1))))) goto LAB_008f9c94;
|
||||
}
|
||||
operator_delete(ppppbVar1,uVar4);
|
||||
}
|
||||
dlcPath = GHIDRA_CAST<byte ****>((GHIDRA_UINT(dlcPath) & 0xffffff00));
|
||||
if ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_5c)) + 0x4))) < 0x10) {
|
||||
ExceptionList = local_1c;
|
||||
return outPath;
|
||||
}
|
||||
uVar4 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_5c)) + 0x4))) + 1;
|
||||
ppppbVar1 = dlcDir;
|
||||
if (uVar4 < 0x1000) goto LAB_008f9bb7;
|
||||
ppppbVar1 = GHIDRA_CAST<byte ****>(dlcDir[-1]);
|
||||
iVar3 = GHIDRA_INT(dlcDir) - GHIDRA_INT(ppppbVar1);
|
||||
}
|
||||
else {
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 4;
|
||||
tracked_alloc(1,pbVar2,0);
|
||||
ppppbVar1 = dlcPath;
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 3;
|
||||
outPath->_buf[0] = '\0';
|
||||
outPath->_buf[1] = '\0';
|
||||
outPath->_buf[2] = '\0';
|
||||
outPath->_buf[3] = '\0';
|
||||
outPath->_size = 0;
|
||||
outPath->_capacity = 0;
|
||||
dlcPath = GHIDRA_CAST<byte ****>((GHIDRA_UINT(dlcPath) & 0xffffff00));
|
||||
*GHIDRA_CAST<byte *****>(outPath->_buf) = ppppbVar1;
|
||||
*GHIDRA_CAST<undefined4 *>((outPath->_buf + 4)) = uStack_38;
|
||||
*GHIDRA_CAST<undefined4 *>((outPath->_buf + 8)) = uStack_34;
|
||||
*GHIDRA_CAST<undefined4 *>((outPath->_buf + 0xc)) = uStack_30;
|
||||
outPath->_size = local_2c;
|
||||
outPath->_capacity = uStack_28;
|
||||
if ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_5c)) + 0x4))) < 0x10) {
|
||||
ExceptionList = local_1c;
|
||||
return outPath;
|
||||
}
|
||||
uVar4 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_5c)) + 0x4))) + 1;
|
||||
ppppbVar1 = dlcDir;
|
||||
if (uVar4 < 0x1000) goto LAB_008f9bb7;
|
||||
ppppbVar1 = GHIDRA_CAST<byte ****>(dlcDir[-1]);
|
||||
iVar3 = GHIDRA_INT(dlcDir) - GHIDRA_INT(ppppbVar1);
|
||||
}
|
||||
uStack_28 = 0xf;
|
||||
local_2c = 0;
|
||||
uVar4 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_5c)) + 0x4))) + 0x24;
|
||||
if (0x1f < iVar3 - 4U) {
|
||||
LAB_008f9c94:
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
LAB_008f9bb7:
|
||||
uStack_28 = 0xf;
|
||||
local_2c = 0;
|
||||
operator_delete(ppppbVar1,uVar4);
|
||||
ExceptionList = local_1c;
|
||||
return outPath;
|
||||
}
|
||||
|
||||
// 008f9cb0
|
||||
void Mod::load_menu_sprites()
|
||||
{
|
||||
byte bVar1;
|
||||
qword qVar2;
|
||||
byte *pbVar3;
|
||||
std_string *path;
|
||||
byte *pbVar4;
|
||||
void *in_ECX;
|
||||
void *pvVar5;
|
||||
uint uVar6;
|
||||
qword *allocCounter;
|
||||
uint pathTableOffset;
|
||||
ANM2 *sprite;
|
||||
std_string contentPath;
|
||||
std_string relativePath;
|
||||
uint local_14;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 0xff;
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))) = 0xffffff;
|
||||
puStack_c = &LAB_00b07ba5;
|
||||
local_10 = ExceptionList;
|
||||
local_14 = __security_cookie ^ GHIDRA_INT(&relativePath) + 0x28U;
|
||||
ExceptionList = &local_10;
|
||||
sprite = GHIDRA_CAST<ANM2 *>((GHIDRA_INT(in_ECX) + 0x100));
|
||||
pathTableOffset = 0;
|
||||
do {
|
||||
pbVar4 = *GHIDRA_CAST<byte **>((GHIDRA_INT(&PTR_s_gfx_CharacterMenu_anm2_00b240c0) + pathTableOffset));
|
||||
if (pbVar4 != GHIDRA_CAST<byte *>(0x0)) {
|
||||
relativePath._size = 0;
|
||||
relativePath._capacity = 0xf;
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(relativePath._buf)) + 0x0))) = (void *)0x0;
|
||||
pbVar3 = pbVar4;
|
||||
do {
|
||||
bVar1 = *pbVar3;
|
||||
pbVar3 = pbVar3 + 1;
|
||||
} while (bVar1 != 0);
|
||||
(GHIDRA_CAST<std::string *>((relativePath._buf)))->std::string::assign(pbVar4,GHIDRA_INT(pbVar3) - GHIDRA_INT((pbVar4 + 1)));
|
||||
local_8 = 0;
|
||||
GetContentPath(in_ECX,&contentPath,&relativePath);
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 2;
|
||||
if (0xf < relativePath._capacity) {
|
||||
uVar6 = relativePath._capacity + 1;
|
||||
pvVar5 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((void *)relativePath._buf)) + 0x0)));
|
||||
if (0xfff < uVar6) {
|
||||
pvVar5 = *(void **)((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(relativePath._buf)) + 0x0))) + -4);
|
||||
uVar6 = relativePath._capacity + 0x24;
|
||||
if (0x1f < GHIDRA_UINT(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(relativePath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pvVar5))))) goto LAB_008f9e44;
|
||||
}
|
||||
operator_delete(pvVar5,uVar6);
|
||||
}
|
||||
path = &contentPath;
|
||||
if (0xf < contentPath._capacity) {
|
||||
path = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(contentPath._buf))) + 0x0)));
|
||||
}
|
||||
pbVar4 = FileSystem::ResolvePath(GHIDRA_CAST<byte *>(path));
|
||||
if (pbVar4 != GHIDRA_CAST<byte *>(0x0)) {
|
||||
if (g_mainHeap == (void *)0x0) {
|
||||
allocCounter = &g_allocatedBytesNoHeap;
|
||||
}
|
||||
else {
|
||||
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
|
||||
}
|
||||
uVar6 = *GHIDRA_CAST<uint *>((pbVar4 + -4));
|
||||
qVar2 = *allocCounter;
|
||||
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - uVar6;
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
|
||||
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar2) < uVar6));
|
||||
free(pbVar4 + -4);
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 2;
|
||||
}
|
||||
if (pbVar4 != GHIDRA_CAST<byte *>(0x0)) {
|
||||
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Load(&contentPath,1);
|
||||
}
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 0xff;
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))) = 0xffffff;
|
||||
if (0xf < contentPath._capacity) {
|
||||
uVar6 = contentPath._capacity + 1;
|
||||
pvVar5 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((void *)contentPath._buf)) + 0x0)));
|
||||
if (0xfff < uVar6) {
|
||||
pvVar5 = *(void **)((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(contentPath._buf)) + 0x0))) + -4);
|
||||
uVar6 = contentPath._capacity + 0x24;
|
||||
if (0x1f < ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(contentPath._buf)) + 0x0))) - GHIDRA_INT(pvVar5)) - 4U) {
|
||||
LAB_008f9e44:
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(pvVar5,uVar6);
|
||||
}
|
||||
}
|
||||
pathTableOffset = pathTableOffset + 4;
|
||||
sprite = sprite + 1;
|
||||
if (0x33 < pathTableOffset) {
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
} while( true );
|
||||
}
|
||||
|
||||
// 008f9e50
|
||||
void Mod::load_content_anm2(int slot, std_string *relativePath)
|
||||
{
|
||||
std_string *path;
|
||||
byte *resolvedPath;
|
||||
void *resolvedPath;
|
||||
uint size;
|
||||
std_string contentPath;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
int local_8;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b07bdd;
|
||||
local_10 = ExceptionList;
|
||||
ExceptionList = &local_10;
|
||||
GetContentPath(this,&contentPath,relativePath);
|
||||
local_8 = 0;
|
||||
path = &contentPath;
|
||||
if (0xf < contentPath._capacity) {
|
||||
path = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(contentPath._buf))) + 0x0)));
|
||||
}
|
||||
resolvedPath = FileSystem::ResolvePath(GHIDRA_CAST<byte *>(path));
|
||||
if (resolvedPath != GHIDRA_CAST<byte *>(0x0)) {
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 1;
|
||||
tracked_alloc(1,resolvedPath,0);
|
||||
local_8 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(GHIDRA_UINT(local_8))) + 0x1))) << 8;
|
||||
(GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((slot * 0x114 + 0x100 + GHIDRA_INT(this))))))->ANM2::Load(&contentPath,1);
|
||||
}
|
||||
if (0xf < contentPath._capacity) {
|
||||
size = contentPath._capacity + 1;
|
||||
resolvedPath = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((void *)contentPath._buf)) + 0x0)));
|
||||
if (0xfff < size) {
|
||||
resolvedPath = *(void **)((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(contentPath._buf)) + 0x0))) + -4);
|
||||
size = contentPath._capacity + 0x24;
|
||||
if (0x1f < ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(contentPath._buf)) + 0x0))) - GHIDRA_INT(resolvedPath)) - 4U) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(resolvedPath,size);
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
Reference in new issue
Block a user