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

@@ -0,0 +1,75 @@
#include "classes.h"
// 00a57060
undefined4 KAGE::System::FriendManager::request_friend_lobbies(int param_1, int param_2)
{
char isInGame;
undefined4 *steamFriends;
undefined4 steamIdHigh;
int *in_ECX;
undefined4 steamIdLow;
int friendCursor;
int friendsBegin;
int friendsEnd;
undefined8 local_20;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
code *getFriendGamePlayed;
int profile;
local_8 = 0xffffffff;
puStack_c = &LAB_00b12935;
local_10 = ExceptionList;
ExceptionList = &local_10;
in_ECX[2] = param_1;
in_ECX[3] = param_2;
in_ECX[6] = 0;
FUN_00a57a10();
in_ECX[8] = in_ECX[7];
in_ECX[10] = 0;
FUN_00a57a10();
in_ECX[0xc] = in_ECX[0xb];
(**(code **)(*in_ECX + 0x10))();
local_8 = 0;
friendCursor = friendsBegin;
if (friendsBegin != friendsEnd) {
do {
steamFriends = GHIDRA_CAST<undefined4 *>(SteamInternal_ContextInit());
getFriendGamePlayed = *(code **)(*GHIDRA_CAST<int *>(*steamFriends) + 0x20);
profile = *GHIDRA_CAST<int *>((friendCursor + 4));
if (profile == 0) {
local_20 = 0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_20)) + 0x4))) = 0;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_20)) + 0x0))) = 0;
steamIdHigh = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_20)) + 0x4)));
steamIdLow = (undefined4)local_20;
}
else {
steamIdHigh = *GHIDRA_CAST<undefined4 *>((profile + 0xc));
steamIdLow = *GHIDRA_CAST<undefined4 *>((profile + 8));
}
FUN_00a238e0(steamIdLow,steamIdHigh);
isInGame = (*getFriendGamePlayed)();
if (isInGame != '\0') {
steamFriends = GHIDRA_CAST<undefined4 *>(SteamInternal_ContextInit());
(**(code **)(*GHIDRA_CAST<int *>(*steamFriends) + 0x24))();
}
friendCursor = friendCursor + 8;
} while (friendCursor != friendsEnd);
}
if (in_ECX[10] != 0) {
in_ECX[6] = in_ECX[6] + 1;
}
local_8 = 0xffffffff;
vector_UserProfile_destroy(&friendsBegin);
in_ECX[6] = in_ECX[6] + 1;
eos_friend_lobby_search_start();
if ((in_ECX[6] == 0) && (DAT_00c5ab58 != (code *)0x0)) {
(*DAT_00c5ab58)();
DAT_00c5ab58 = (code *)0x0;
DAT_00c5ab5c = 0;
}
ExceptionList = local_10;
return 1;
}
@@ -0,0 +1,105 @@
#include "classes.h"
// 00a51790
int KAGE::System::LeaderboardManager::get_result(uint handle)
{
int result;
undefined1 findResult [8];
int foundNode;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
uint key;
key = handle;
local_8 = 0xffffffff;
puStack_c = &LAB_00af0eb0;
local_10 = ExceptionList;
if (handle == 0) {
return 0;
}
ExceptionList = &local_10;
(**(code **)(DAT_00c5ab20 + 0xc))(0xffffffff,__security_cookie ^ GHIDRA_UINT((findResult + 0x18)));
_Find_lower_bound<>(findResult,&handle);
if (((*GHIDRA_CAST<char *>((foundNode + 0xd)) == '\0') && (*GHIDRA_CAST<uint *>((foundNode + 0x10)) <= key)) &&
(foundNode != DAT_00c5ab18)) {
result = *GHIDRA_CAST<int *>((foundNode + 0x14));
}
else {
result = 0;
}
local_8 = 0;
(**(code **)(DAT_00c5ab20 + 0x10))();
ExceptionList = local_10;
return result;
}
// 00a51840
void KAGE::System::LeaderboardManager::release_result(int handle)
{
int iVar1;
void *pvVar2;
int *mapHead;
undefined1 foundIter [8];
int *foundNode;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
iVar1 = handle;
local_8 = 0xffffffff;
puStack_c = &LAB_00b122d0;
local_10 = ExceptionList;
ExceptionList = &local_10;
if ((((byte)DAT_00c5ab14 & 1) != 0) && (handle != 0)) {
(**(code **)(DAT_00c5ab20 + 0xc))(0xffffffff,__security_cookie ^ GHIDRA_UINT((foundIter + 0x18)));
if (iVar1 == -1) {
handle = *DAT_00c5ab18;
mapHead = DAT_00c5ab18;
if (GHIDRA_CAST<int *>(handle) != DAT_00c5ab18) {
do {
iVar1 = handle;
pvVar2 = *(void **)(handle + 0x14);
if (pvVar2 != (void *)0x0) {
if (*(void **)(GHIDRA_CAST<char *>(pvVar2) + 4) != (void *)0x0) {
local_8 = 0;
tracked_alloc(1,*(void **)(GHIDRA_CAST<char *>(pvVar2) + 4),0);
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(pvVar2) + 4)) = 0;
}
operator_delete(pvVar2,0x18);
*GHIDRA_CAST<undefined4 *>((iVar1 + 0x14)) = 0;
mapHead = DAT_00c5ab18;
}
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>
*)&handle);
} while (GHIDRA_CAST<int *>(handle) != mapHead);
}
FID_conflict__Erase_tree<fuzzer::fuzzer_allocator<std::_Tree_node<fuzzer::TracePC::PCTableEntry_const*,void*>_>_>
(&DAT_00c5ab18,
(fuzzer_allocator<std::_Tree_node<unsigned_int,void*>_> *)&DAT_00c5ab18,
(_Tree_node<unsigned_int,void*> *)mapHead[1]);
mapHead[1] = GHIDRA_INT(mapHead);
*mapHead = GHIDRA_INT(mapHead);
mapHead[2] = GHIDRA_INT(mapHead);
_DAT_00c5ab1c = 0;
}
else {
_Find_lower_bound<>(foundIter,&handle);
if (((*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(foundNode) + 0xd)) == '\0') && (GHIDRA_UINT(foundNode[4]) <= GHIDRA_UINT(iVar1))) &&
(foundNode != DAT_00c5ab18)) {
if (foundNode[5] != 0) {
FUN_008d0bc0(foundNode[5]);
foundNode[5] = 0;
}
pvVar2 = std_tree_extract(&DAT_00c5ab18,foundNode);
operator_delete(pvVar2,0x18);
}
}
local_8 = 2;
(**(code **)(DAT_00c5ab20 + 0x10))();
}
ExceptionList = local_10;
return;
}
+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;
}