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:
shweetandClaude Opus 5.5 committed 2026-11-19 21:10:23 -05:00
1 parent 2ff2d5d87f
commit 3ce74c6e2d
331 files changed
+485 -7835

No files matched your search

+159
View File
@@ -0,0 +1,159 @@
#include "classes.h"
// 00835c90
void KeyConfigs::apply_to_device(int deviceId)
{
int iVar1;
char cVar2;
uint uVar3;
int iVar4;
byte *deviceNameChar;
char *pcVar5;
char *pcVar6;
char *pcVar7;
undefined4 *puVar8;
char **newEntryWord;
byte *configNameChar;
bool isLess;
uint actionOffset;
int targetDevice;
int *targetDeviceRef;
int *local_124;
int *deviceRef;
uint actionId;
char *newEntry [65];
uint local_14;
void *local_10;
undefined1 *puStack_c;
char *local_8;
undefined4 binding;
byte ch;
local_8 = GHIDRA_CAST<char *>(0xffffffff);
puStack_c = &LAB_00b0235b;
local_10 = ExceptionList;
uVar3 = __security_cookie ^ GHIDRA_UINT((newEntry + 0x45));
ExceptionList = &local_10;
local_14 = uVar3;
(GHIDRA_CAST<InputManager *>((&PTR_vftable_00c57b18)))->InputManager::get_device(&local_124,deviceId);
local_8 = GHIDRA_CAST<char *>(0x0);
if (local_124 != GHIDRA_CAST<int *>(0x0)) {
iVar4 = __RTDynamicCast(local_124,0,&KAGE::Input::InputDeviceBase::RTTI_Type_Descriptor,
&IsaacRepentancePlus::NetInputDevice::RTTI_Type_Descriptor,0,uVar3);
if (iVar4 == 0) {
puVar8 = *GHIDRA_CAST<undefined4 **>(this);
if (puVar8 != *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(this) + 4))) {
do {
configNameChar = GHIDRA_CAST<byte *>(*puVar8);
deviceNameChar = GHIDRA_CAST<byte *>((**(code **)(*local_124 + 0xc))());
do {
ch = *deviceNameChar;
isLess = ch < *configNameChar;
if (ch != *configNameChar) {
LAB_00835d40:
uVar3 = -GHIDRA_UINT(isLess) | 1;
goto LAB_00835d45;
}
if (ch == 0) break;
ch = deviceNameChar[1];
isLess = ch < configNameChar[1];
if (ch != configNameChar[1]) goto LAB_00835d40;
deviceNameChar = deviceNameChar + 2;
configNameChar = configNameChar + 2;
} while (ch != 0);
uVar3 = 0;
LAB_00835d45:
if (uVar3 == 0) {
(GHIDRA_CAST<InputManager *>((&PTR_vftable_00c57b18)))->InputManager::get_device(&targetDevice,deviceId);
local_8 = GHIDRA_CAST<char *>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1));
if (targetDevice == 0) {
local_8 = GHIDRA_CAST<char *>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),2));
if (targetDeviceRef != GHIDRA_CAST<int *>(0x0)) {
cVar2 = (**(code **)(*targetDeviceRef + 0xc))();
if ((cVar2 != '\0') && (g_inputDeviceRelease != (void *)0x0)) {
(*g_inputDeviceRelease)(&targetDevice);
}
}
}
else {
actionId = 0;
actionOffset = 0;
puVar8 = puVar8 + 1;
do {
uVar3 = 0;
do {
iVar1 = targetDevice;
binding = *puVar8;
iVar4 = *GHIDRA_CAST<int *>((targetDevice + 0x10));
if (GHIDRA_UINT((*GHIDRA_CAST<int *>((targetDevice + 0x14)) - iVar4 >> 4)) <= actionId) {
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("ActionId is out of range\n"));
iVar4 = *GHIDRA_CAST<int *>((iVar1 + 0x10));
}
puVar8 = puVar8 + 1;
*GHIDRA_CAST<undefined4 *>((actionOffset + iVar4 + uVar3)) = binding;
uVar3 = uVar3 + 4;
} while (uVar3 < 8);
actionId = actionId + 1;
actionOffset = actionOffset + 0x10;
} while (actionOffset < 0x200);
local_8 = GHIDRA_CAST<char *>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),3));
if (targetDeviceRef != GHIDRA_CAST<int *>(0x0)) {
cVar2 = (**(code **)(*targetDeviceRef + 0xc))();
if ((cVar2 != '\0') && (g_inputDeviceRelease != (void *)0x0)) {
(*g_inputDeviceRelease)(&targetDevice);
}
}
}
goto LAB_00835f18;
}
puVar8 = puVar8 + 0x41;
} while (puVar8 != *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(this) + 4)));
}
newEntryWord = newEntry;
for (iVar4 = 0x40; newEntryWord = newEntryWord + 1, iVar4 != 0; iVar4 = iVar4 + -1) {
*newEntryWord = GHIDRA_CAST<char *>(0xffffffff);
}
pcVar5 = GHIDRA_CAST<char *>((**(code **)(*local_124 + 0xc))());
pcVar7 = pcVar5 + 1;
do {
cVar2 = *pcVar5;
pcVar5 = pcVar5 + 1;
} while (cVar2 != '\0');
pcVar5 = operator_new_tracked(GHIDRA_UINT((pcVar5 + (1 - GHIDRA_INT(pcVar7)))));
newEntry[0] = pcVar5;
pcVar6 = GHIDRA_CAST<char *>((**(code **)(*local_124 + 0xc))());
pcVar7 = pcVar6 + 1;
do {
cVar2 = *pcVar6;
pcVar6 = pcVar6 + 1;
} while (cVar2 != '\0');
pcVar6 = pcVar6 + (1 - GHIDRA_INT(pcVar7));
pcVar7 = GHIDRA_CAST<char *>((**(code **)(*local_124 + 0xc))());
strncpy(pcVar5,pcVar7,(size_t)pcVar6);
FUN_00835ba0(deviceId);
puVar8 = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(this) + 4));
if (puVar8 == *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(this) + 8))) {
FUN_008367e0(puVar8,newEntry);
}
else {
newEntryWord = newEntry;
for (iVar4 = 0x41; iVar4 != 0; iVar4 = iVar4 + -1) {
*puVar8 = *newEntryWord;
newEntryWord = newEntryWord + 1;
puVar8 = puVar8 + 1;
}
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) + 0x104;
}
}
}
LAB_00835f18:
local_8 = GHIDRA_CAST<char *>(0x4);
if (deviceRef != GHIDRA_CAST<int *>(0x0)) {
cVar2 = (**(code **)(*deviceRef + 0xc))();
if ((cVar2 != '\0') && (g_inputDeviceRelease != (void *)0x0)) {
(*g_inputDeviceRelease)(&local_124);
}
}
ExceptionList = local_10;
return;
}