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

+271
View File
@@ -0,0 +1,271 @@
#include "classes.h"
// 00a23610
void KAGE::System::UserProfile::load_steam_avatar()
{
uint height;
undefined2 *ptr;
char cVar1;
int iVar2;
int *steamFriends;
undefined4 *steamInterface;
int extraout_EAX;
longlong lVar3;
undefined8 steamId;
byte *buffer;
char *pcVar4;
int *image;
int *imageRefCount;
undefined2 *rgbaBuffer;
int avatarHeight;
int avatarWidth;
undefined8 local_11c;
byte imageName [256];
uint local_14;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
code *steamFn;
local_8 = 0xffffffff;
puStack_c = &LAB_00b119b0;
local_10 = ExceptionList;
local_14 = __security_cookie ^ GHIDRA_UINT((imageName + 0x110));
ExceptionList = &local_10;
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4));
if (((((iVar2 != 0) && (lVar3 = __aullshr(local_14), lVar3 != 0xfefefefe)) &&
(*GHIDRA_CAST<int *>((iVar2 + 8)) != 0 || *GHIDRA_CAST<int *>((iVar2 + 0xc)) != 0)) &&
((iVar2 = this->FUN_00a233c0(), iVar2 == 1 && (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) != 0))))
&& ((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) + 0x14)) == 0 &&
(steamFriends = GHIDRA_CAST<int *>(SteamInternal_ContextInit(&PTR_FUN_00c5c4f8)), *steamFriends != 0))))
{
steamInterface = GHIDRA_CAST<undefined4 *>(SteamInternal_ContextInit(&PTR_FUN_00c5c4f8));
steamFn = *(code **)(*GHIDRA_CAST<int *>(*steamInterface) + 0x94);
steamId = FUN_00a23920(0);
cVar1 = (*steamFn)(steamId);
if (cVar1 == '\0') {
steamInterface = GHIDRA_CAST<undefined4 *>(SteamInternal_ContextInit(&PTR_FUN_00c5c4f8));
steamFn = *(code **)(*GHIDRA_CAST<int *>(*steamInterface) + 0x8c);
steamId = FUN_00a23920();
iVar2 = (*steamFn)(steamId);
if (0 < iVar2) {
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_11c)) + 0x4))) = iVar2;
steamInterface = GHIDRA_CAST<undefined4 *>(SteamInternal_ContextInit(&PTR_FUN_00c5c4ec));
cVar1 = (**(code **)(*GHIDRA_CAST<int *>(*steamInterface) + 0x14))(iVar2,&avatarWidth,&avatarHeight);
if (cVar1 != '\0') {
iVar2 = avatarWidth * avatarHeight * 4;
height = iVar2 + 4;
rgbaBuffer = tracked_alloc(0,(void *)0x0,(ulonglong)height);
*rgbaBuffer = (undefined2)avatarWidth;
rgbaBuffer[1] = (undefined2)avatarHeight;
steamId = FUN_00a23920();
buffer = imageName;
pcVar4 = "Steam User Avatar - %llu";
sprintf(buffer,GHIDRA_CAST<byte *>("Steam User Avatar - %llu"));
steamInterface =
GHIDRA_CAST<undefined4 *>(SteamInternal_ContextInit(&PTR_FUN_00c5c4ec,buffer,pcVar4,steamId));
(**(code **)(*GHIDRA_CAST<int *>(*steamInterface) + 0x18))((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_11c)) + 0x4))),rgbaBuffer + 2,iVar2);
local_11c = FUN_00a23920();
ptr = rgbaBuffer;
KAGE_Graphics::create_image(&image,GHIDRA_INT(rgbaBuffer),height,4,imageName);
local_8 = 0;
if (image != GHIDRA_CAST<int *>(0x0)) {
if ((image[0xc] != 1) || (image[0xd] != 1)) {
(**(code **)(*image + 0x44))(1,1);
image[0xc] = 1;
image[0xd] = 1;
}
::(GHIDRA_CAST<UserProfile *>((&local_11c)))->UserProfile::find_or_create();
SmartPointer::operator_assign((void *)(extraout_EAX + 0x14),&image);
}
local_8 = 1;
if (imageRefCount != GHIDRA_CAST<int *>(0x0)) {
cVar1 = (**(code **)(*imageRefCount + 0xc))();
if ((cVar1 != '\0') && (g_imageReleaseFn != (void *)0x0)) {
(*g_imageReleaseFn)(&image);
}
}
local_8 = 2;
tracked_alloc(1,ptr,0);
}
}
}
}
ExceptionList = local_10;
return;
}
// 00a5f260
byte KAGE::System::UserProfile::is_local_user()
{
int localIdLow;
longlong idHigh;
byte *profileData;
int profileIdLow;
profileData = *GHIDRA_CAST<byte **>((GHIDRA_CAST<char *>(this) + 4));
if (profileData == GHIDRA_CAST<byte *>(0x0)) {
return 0;
}
idHigh = __aullshr();
if (idHigh == 0xfefefefe) {
profileIdLow = *GHIDRA_CAST<int *>((profileData + 8));
localIdLow = FUN_00a5f090();
return profileIdLow == localIdLow;
}
if ((*GHIDRA_CAST<int *>((profileData + 0x20)) == 0) ||
(*(void **)(*GHIDRA_CAST<int *>((profileData + 0x20)) + 0x10) != g_eosLocalUserId)) {
return *profileData & 1;
}
return 1;
}
// 00a6f770
void KAGE::System::UserProfile::set_id(ulonglong *userId, byte *displayName)
{
undefined4 uVar1;
char cVar2;
void *mapNode;
byte *extraout_EAX;
int iVar3;
byte *userInfo;
uint localIdLow;
undefined4 extraout_ECX;
byte *pbVar4;
byte bVar5;
char *nameCopy;
undefined1 mapIterator [8];
void *foundNode;
undefined8 local_24;
undefined1 local_18 [4];
int *local_14;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
bool isLocalUser;
uint *profileId;
local_8 = 0xffffffff;
puStack_c = &LAB_00b133cd;
local_10 = ExceptionList;
ExceptionList = &local_10;
local_14 = this;
if ((GHIDRA_INT(*userId) != 0 || *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(userId) + 4)) != 0) &&
((profileId = GHIDRA_CAST<uint *>((GHIDRA_INT(this) + 8)), *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 8)) != GHIDRA_INT(*userId) ||
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc)) != *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(userId) + 4)))))) {
if (g_userProfile == (void *)0x0) {
local_24 = 0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) = GHIDRA_CAST<int *>(0x0);
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_24)) + 0x0))) = GHIDRA_CAST<byte *>(0x0);
iVar3 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_INT(local_24))) + 0x4)));
localIdLow = GHIDRA_UINT(GHIDRA_CAST<byte *>(local_24));
}
else {
iVar3 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_userProfile) + 0xc));
localIdLow = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(g_userProfile) + 8));
}
if ((*profileId != localIdLow) || (isLocalUser = true, *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc)) != iVar3)) {
isLocalUser = false;
}
(**(code **)(PTR_vftable_00c5aa70 + 0xc))
(0xffffffff,__security_cookie ^ GHIDRA_UINT((local_18 + 0x14)));
if (((g_userProfile != (void *)0x0) && (*profileId == *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(g_userProfile) + 8)))) &&
(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc)) == *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_userProfile) + 0xc)))) {
g_userProfile = (void *)0x0;
}
FUN_00a24210(mapIterator,profileId);
if (*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(foundNode) + 0xd)) == '\0') {
if (((*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(foundNode) + 0x14)) <= *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0xc))) &&
((*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(foundNode) + 0x14)) < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0xc)) ||
(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(foundNode) + 0x10)) <= *profileId)))) && (foundNode != DAT_00c798d8)) {
mapNode = std_tree_extract(&DAT_00c798d8,foundNode);
FUN_00a70fe0();
operator_delete(mapNode,0x40);
}
}
local_8 = 0;
(**(code **)(PTR_vftable_00c5aa70 + 0x10))();
local_8 = 0xffffffff;
uVar1 = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(userId) + 4));
*profileId = GHIDRA_UINT(*userId);
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = uVar1;
eos_user_info_find_or_create(&DAT_00c5ac08,local_18,local_14);
local_8 = 1;
if (local_14 != GHIDRA_CAST<int *>(0x0)) {
cVar2 = (**(code **)(*local_14 + 0xc))();
if ((cVar2 != '\0') && (g_profileReleaseFn != (void *)0x0)) {
(*g_profileReleaseFn)(local_18);
}
}
local_8 = 0xffffffff;
if (isLocalUser) {
::(GHIDRA_CAST<UserProfile *>((profileId)))->UserProfile::find_or_create();
g_userProfile = extraout_EAX;
*extraout_EAX = *extraout_EAX | 1;
}
}
iVar3 = FUN_00a23bb0();
if (iVar3 == 0) {
SmartPointer<EpicUserInfoType>::SmartPointer(extraout_ECX);
}
else {
FUN_00a23df0(iVar3 + 0x20);
}
local_8 = 2;
if (GHIDRA_CAST<byte *>(local_24) != GHIDRA_CAST<byte *>(0x0)) {
userInfo = GHIDRA_CAST<byte *>(FUN_00a23bb0());
if (userInfo != GHIDRA_CAST<byte *>(0x0)) {
pbVar4 = *GHIDRA_CAST<byte **>((userInfo + 0x10));
if (pbVar4 != displayName) {
if (pbVar4 != GHIDRA_CAST<byte *>(0x0)) {
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 3;
tracked_alloc(1,pbVar4,0);
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),2);
userInfo[0x10] = 0;
userInfo[0x11] = 0;
userInfo[0x12] = 0;
userInfo[0x13] = 0;
}
if (displayName == GHIDRA_CAST<byte *>(0x0)) {
nameCopy = GHIDRA_CAST<char *>(0x0);
}
else {
pbVar4 = displayName;
do {
bVar5 = *pbVar4;
pbVar4 = pbVar4 + 1;
} while (bVar5 != 0);
nameCopy = operator_new_tracked(GHIDRA_UINT((pbVar4 + (1 - GHIDRA_INT((displayName + 1))))));
pbVar4 = displayName;
do {
bVar5 = *pbVar4;
pbVar4 = pbVar4 + 1;
} while (bVar5 != 0);
strncpy(nameCopy,GHIDRA_CAST<char *>(displayName),(size_t)(pbVar4 + (1 - GHIDRA_INT((displayName + 1)))));
}
*GHIDRA_CAST<char **>((userInfo + 0x10)) = nameCopy;
bVar5 = *userInfo | 2;
if ((*GHIDRA_CAST<byte *>(local_24) & 2) == 0) {
bVar5 = *userInfo & 0xfd;
}
*userInfo = bVar5;
if ((*GHIDRA_CAST<byte *>(local_24) & 4) == 0) {
bVar5 = bVar5 & 0xfb;
}
else {
bVar5 = bVar5 | 4;
}
*userInfo = bVar5;
}
}
}
local_8 = 4;
if ((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) != GHIDRA_CAST<int *>(0x0)) {
cVar2 = (**(code **)(*(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_24)) + 0x4))) + 0xc))();
if ((cVar2 != '\0') && (g_profileReleaseFn != (void *)0x0)) {
(*g_profileReleaseFn)(&local_24);
}
}
ExceptionList = local_10;
return;
}