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>
207 lines
7.5 KiB
C++
207 lines
7.5 KiB
C++
#include "classes.h"
|
|
|
|
// 0069d290
|
|
void Menu_Mods::Update()
|
|
{
|
|
std_string *displayName;
|
|
byte *b;
|
|
void *freeBlock;
|
|
uint size;
|
|
undefined1 *nameSize;
|
|
Menu_Mods playersBegin;
|
|
byte *a;
|
|
int iVar2;
|
|
Menu_Mods playersEnd;
|
|
undefined1 local_74 [4];
|
|
uint playerIndex;
|
|
Menu_Mods *self;
|
|
undefined1 *nameMapHead;
|
|
undefined4 local_64;
|
|
undefined1 *local_60;
|
|
uint local_5c;
|
|
void *displayNameBuf [3];
|
|
undefined1 local_4c [8];
|
|
undefined1 *local_44;
|
|
void *nameKey;
|
|
undefined4 uStack_3c;
|
|
undefined4 uStack_38;
|
|
undefined4 uStack_34;
|
|
uint nameKeySize;
|
|
uint nameKeyCapacity;
|
|
uint local_28;
|
|
uint securityCookie;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
uint *nameSize;
|
|
EntityConfig_Player *playerConfig;
|
|
|
|
puStack_20 = local_4c + 0x48;
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00af9dbd;
|
|
local_1c = ExceptionList;
|
|
securityCookie = __security_cookie ^ GHIDRA_UINT((local_4c + 0x3c));
|
|
ExceptionList = &local_1c;
|
|
nameMapHead = GHIDRA_CAST<undefined1 *>(0x0);
|
|
local_64 = 0;
|
|
self = this;
|
|
nameMapHead = operator_new(0x2c);
|
|
*GHIDRA_CAST<undefined1 **>(nameMapHead) = nameMapHead;
|
|
*GHIDRA_CAST<undefined1 **>((nameMapHead + 4)) = nameMapHead;
|
|
*GHIDRA_CAST<undefined1 **>((nameMapHead + 8)) = nameMapHead;
|
|
*GHIDRA_CAST<undefined2 *>((nameMapHead + 0xc)) = 0x101;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 0;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))) = 0;
|
|
playersEnd = this[3];
|
|
playersBegin = this[2];
|
|
local_5c = 0x29;
|
|
local_60 = nameMapHead;
|
|
if (0x29 < GHIDRA_UINT(((GHIDRA_INT(playersEnd) - GHIDRA_INT(playersBegin)) / 0x148))) {
|
|
iVar2 = 0x3488;
|
|
do {
|
|
playerConfig = GHIDRA_CAST<EntityConfig_Player *>((iVar2 + GHIDRA_INT(playersBegin)));
|
|
if ((*GHIDRA_CAST<char *>((iVar2 + 0x128 + GHIDRA_INT(playersBegin))) == '\0') &&
|
|
((playerConfig->_bSkinParentName)._size == 0)) {
|
|
displayName = EntityConfig_Player::GetDisplayName
|
|
(playerConfig,GHIDRA_CAST<std_string *>(displayNameBuf),playerConfig);
|
|
nameKey = *(void **)displayName->_buf;
|
|
uStack_3c = *GHIDRA_CAST<undefined4 *>((displayName->_buf + 4));
|
|
uStack_38 = *GHIDRA_CAST<undefined4 *>((displayName->_buf + 8));
|
|
uStack_34 = *GHIDRA_CAST<undefined4 *>((displayName->_buf + 0xc));
|
|
nameKeySize = displayName->_size;
|
|
nameKeyCapacity = displayName->_capacity;
|
|
displayName->_size = 0;
|
|
displayName->_capacity = 0xf;
|
|
displayName->_buf[0] = '\0';
|
|
local_28 = local_5c;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 2;
|
|
FUN_006a00d0(local_74,&nameKey);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 1;
|
|
if (0xf < nameKeyCapacity) {
|
|
size = nameKeyCapacity + 1;
|
|
freeBlock = nameKey;
|
|
if (0xfff < size) {
|
|
freeBlock = *(void **)(GHIDRA_CAST<char *>(nameKey) + -4);
|
|
size = nameKeyCapacity + 0x24;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(nameKey) + (-4 - GHIDRA_INT(freeBlock))))) goto LAB_0069d502;
|
|
}
|
|
operator_delete(freeBlock,size);
|
|
}
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x0))) = 0;
|
|
if (&DAT_0000000f < local_44) {
|
|
nameSize = local_44 + 1;
|
|
freeBlock = displayNameBuf[0];
|
|
if (GHIDRA_CAST<undefined1 *>(0xfff) < nameSize) {
|
|
freeBlock = *(void **)(GHIDRA_INT(displayNameBuf[0]) + -4);
|
|
nameSize = local_44 + 0x24;
|
|
if (0x1f < GHIDRA_UINT((GHIDRA_INT(displayNameBuf[0]) + (-4 - GHIDRA_INT(freeBlock))))) {
|
|
LAB_0069d502:
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(freeBlock,GHIDRA_UINT(nameSize));
|
|
}
|
|
}
|
|
iVar2 = iVar2 + 0x148;
|
|
local_5c = local_5c + 1;
|
|
playersEnd = self[3];
|
|
playersBegin = self[2];
|
|
} while (local_5c < GHIDRA_UINT(((GHIDRA_INT(playersEnd) - GHIDRA_INT(playersBegin)) / 0x148)));
|
|
local_60 = nameMapHead;
|
|
}
|
|
playerIndex = 0x29;
|
|
nameSize = local_60;
|
|
nameMapHead = local_60;
|
|
if (0x29 < GHIDRA_UINT(((GHIDRA_INT(playersEnd) - GHIDRA_INT(playersBegin)) / 0x148))) {
|
|
local_5c = 0x3488;
|
|
do {
|
|
if ((*GHIDRA_CAST<char *>((local_5c + 0x128 + GHIDRA_INT(playersBegin))) == '\0') &&
|
|
(*GHIDRA_CAST<int *>((local_5c + 0x11c + GHIDRA_INT(playersBegin))) != 0)) {
|
|
a = GHIDRA_CAST<byte *>((GHIDRA_INT(playersBegin) + local_5c + 0x10c));
|
|
std::map<std::string>::_Find_lower_bound(local_4c,a);
|
|
nameSize = local_44;
|
|
if (local_44[0xd] == '\0') {
|
|
b = local_44 + 0x10;
|
|
if (0xf < *GHIDRA_CAST<uint *>((local_44 + 0x24))) {
|
|
b = *GHIDRA_CAST<byte **>(b);
|
|
}
|
|
nameSize = GHIDRA_CAST<uint *>((a + 0x10));
|
|
if (0xf < *GHIDRA_CAST<uint *>((a + 0x14))) {
|
|
a = *GHIDRA_CAST<byte **>(a);
|
|
}
|
|
iVar2 = string_compare(a,*nameSize,b,*GHIDRA_CAST<uint *>((local_44 + 0x20)));
|
|
if ((-1 < iVar2) && (nameSize != local_60)) {
|
|
*GHIDRA_CAST<uint *>((*GHIDRA_CAST<int *>((nameSize + 0x28)) * 0x148 + 0x124 + GHIDRA_INT(self[2]))) = playerIndex;
|
|
local_60 = nameMapHead;
|
|
}
|
|
}
|
|
nameSize = local_60;
|
|
}
|
|
local_5c = local_5c + 0x148;
|
|
playerIndex = playerIndex + 1;
|
|
playersBegin = self[2];
|
|
} while (playerIndex < GHIDRA_UINT(((GHIDRA_INT(self[3]) - GHIDRA_INT(playersBegin)) / 0x148)));
|
|
}
|
|
FUN_004235c0(&nameMapHead,*GHIDRA_CAST<undefined4 *>((nameSize + 4)));
|
|
operator_delete(nameMapHead,0x2c);
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|
|
|
|
// 008e4970
|
|
void Menu_Mods::reset()
|
|
{
|
|
byte bVar1;
|
|
Menu_Mods currentName;
|
|
uint compareResult;
|
|
byte *defaultName;
|
|
bool isLess;
|
|
Menu_Mods animData;
|
|
MenuManager *menuManager;
|
|
|
|
animData = this[0x11];
|
|
if (animData != (Menu_Mods)0x0) {
|
|
currentName = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(animData) + 0x14))) {
|
|
currentName = *GHIDRA_CAST<Menu_Mods *>(animData);
|
|
}
|
|
defaultName = &DAT_00b6767c;
|
|
do {
|
|
bVar1 = *GHIDRA_CAST<byte *>(currentName);
|
|
isLess = bVar1 < *defaultName;
|
|
if (bVar1 != *defaultName) {
|
|
LAB_008e49b0:
|
|
compareResult = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_008e49b5;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = *GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(currentName) + 1));
|
|
isLess = bVar1 < defaultName[1];
|
|
if (bVar1 != defaultName[1]) goto LAB_008e49b0;
|
|
currentName = (Menu_Mods)(GHIDRA_INT(currentName) + 2);
|
|
defaultName = defaultName + 2;
|
|
} while (bVar1 != 0);
|
|
compareResult = 0;
|
|
LAB_008e49b5:
|
|
if ((compareResult == 0) &&
|
|
((*GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(animData) + 0x34)) == 0 || (*GHIDRA_CAST<char *>((this + 0x15)) != '\0'))))
|
|
goto LAB_008e49e2;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((this + 4)))))->ANM2::SetAnimation(&DAT_00b6767c,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((this + 0x10)))))->AnimationState::Rewind();
|
|
*GHIDRA_CAST<undefined1 *>((this + 0x15)) = 1;
|
|
}
|
|
LAB_008e49e2:
|
|
menuManager = g_menuManager;
|
|
*this = (Menu_Mods)0x0;
|
|
this[1] = (Menu_Mods)0x0;
|
|
menuManager->_viewPositionSet[7].y = -216.0;
|
|
menuManager->_state = 1;
|
|
*GHIDRA_CAST<ModManager *>((this + 0x4a)) = g_manager->_modManager;
|
|
*GHIDRA_CAST<undefined1 *>((this + 0x49)) = 0;
|
|
return;
|
|
}
|