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>
176 lines
7.2 KiB
C++
176 lines
7.2 KiB
C++
#include "classes.h"
|
|
|
|
// 009efa10
|
|
RichText::~RichText()
|
|
{
|
|
undefined4 *this_00;
|
|
int iVar1;
|
|
int iVar2;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
ANM2 *iconSprite;
|
|
char *imageMap;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00b0feb0;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((GHIDRA_INT(this) + 0x18)))))->Font::Unload();
|
|
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 100));
|
|
if (iVar1 != 0) {
|
|
iVar2 = *GHIDRA_CAST<int *>((iVar1 + 0x120));
|
|
std::map<unsigned_int_ImagePtr>::_Erase_tree(iVar1 + 0x120,*GHIDRA_CAST<undefined4 *>((iVar2 + 4)));
|
|
*GHIDRA_CAST<int *>((iVar2 + 4)) = iVar2;
|
|
*GHIDRA_CAST<int *>(iVar2) = iVar2;
|
|
*GHIDRA_CAST<int *>((iVar2 + 8)) = iVar2;
|
|
*GHIDRA_CAST<undefined4 *>((iVar1 + 0x124)) = 0;
|
|
iconSprite = *GHIDRA_CAST<ANM2 **>((GHIDRA_CAST<char *>(this) + 100));
|
|
if (iconSprite != GHIDRA_CAST<ANM2 *>(0x0)) {
|
|
imageMap = iconSprite[1]._filename._buf + 0xc;
|
|
local_8 = 0;
|
|
iVar1 = *GHIDRA_CAST<int *>(imageMap);
|
|
std::map<unsigned_int_ImagePtr>::_Erase_tree(imageMap,*GHIDRA_CAST<undefined4 *>((iVar1 + 4)));
|
|
*GHIDRA_CAST<int *>((iVar1 + 4)) = iVar1;
|
|
*GHIDRA_CAST<int *>(iVar1) = iVar1;
|
|
*GHIDRA_CAST<int *>((iVar1 + 8)) = iVar1;
|
|
iconSprite[1]._filename._size = 0;
|
|
(GHIDRA_CAST<ANM2 *>((iconSprite)))->ANM2::Reset();
|
|
std::map<unsigned_int_ImagePtr>::_Erase_tree(imageMap,*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>(imageMap) + 4)));
|
|
operator_delete(*(void **)imageMap,0x1c);
|
|
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),1);
|
|
(GHIDRA_CAST<ANM2 *>((iconSprite)))->ANM2::Reset();
|
|
(GHIDRA_CAST<AnimationState *>((&iconSprite->_overlayAnimState)))->AnimationState::~AnimationState();
|
|
(GHIDRA_CAST<AnimationState *>((&iconSprite->_animState)))->AnimationState::~AnimationState();
|
|
(GHIDRA_CAST<std::string *>(((iconSprite->_animDefaultName)._buf)))->std::string::_Tidy_deallocate();
|
|
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(iconSprite))))->std::string::_Tidy_deallocate();
|
|
operator_delete(iconSprite,0x128);
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 100)) = 0;
|
|
}
|
|
}
|
|
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((GHIDRA_INT(this) + 0x18)))))->Font::Unload();
|
|
this_00 = GHIDRA_CAST<undefined4 *>((GHIDRA_INT(this) + 0x58));
|
|
FID_conflict__Erase_tree<fuzzer::fuzzer_allocator<std::_Tree_node<fuzzer::TracePC::PCTableEntry_const*,void*>_>_>
|
|
(this_00,(fuzzer_allocator<std::_Tree_node<unsigned_int,void*>_> *)this_00,
|
|
*(_Tree_node<unsigned_int,void*> **)(*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x58)) + 4));
|
|
operator_delete((void *)*this_00,0x18);
|
|
FUN_004b3950();
|
|
this->std::string::_Tidy_deallocate();
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 009efb60
|
|
void RichText::load_font(std_string *fontPath)
|
|
{
|
|
void *newIconsAnm = this;
|
|
ANM2 *pAVar1;
|
|
byte *pbVar2;
|
|
char extraout_AL;
|
|
ANM2 *newIconsAnm;
|
|
void *mapHead;
|
|
char *pcVar3;
|
|
int iconsAnm;
|
|
uint size;
|
|
std_string anmPath;
|
|
byte fontPathLocal [268];
|
|
uint local_24;
|
|
undefined1 *puStack_20;
|
|
void *local_1c;
|
|
undefined1 *puStack_18;
|
|
undefined4 local_14;
|
|
uint *srcSize;
|
|
|
|
puStack_20 = fontPathLocal + 300;
|
|
local_14 = 0xffffffff;
|
|
puStack_18 = &LAB_00b0ff00;
|
|
local_1c = ExceptionList;
|
|
local_24 = __security_cookie ^ GHIDRA_UINT((fontPathLocal + 0x120));
|
|
ExceptionList = &local_1c;
|
|
pbVar2 = fontPathLocal + 300;
|
|
if (newIconsAnm != fontPath) {
|
|
srcSize = &fontPath->_size;
|
|
if (0xf < fontPath->_capacity) {
|
|
fontPath = *GHIDRA_CAST<std_string **>(fontPath->_buf);
|
|
}
|
|
(GHIDRA_CAST<std::string *>((newIconsAnm)))->std::string::assign(GHIDRA_CAST<byte *>(fontPath),*srcSize);
|
|
pbVar2 = puStack_20;
|
|
}
|
|
puStack_20 = pbVar2;
|
|
sprintf_s(fontPathLocal,0x104,&DAT_00b62fdc);
|
|
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((GHIDRA_INT(newIconsAnm) + 0x18)))))->Font::Unload();
|
|
(GHIDRA_CAST<Font *>((GHIDRA_CAST<Font *>((GHIDRA_INT(newIconsAnm) + 0x18)))))->Font::Load(fontPathLocal,0);
|
|
if (extraout_AL == '\0') {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Failed to load font: %s \n"));
|
|
}
|
|
iconsAnm = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(newIconsAnm) + 100));
|
|
if (iconsAnm == 0) {
|
|
newIconsAnm = operator_new(0x128);
|
|
local_14 = 0;
|
|
if (newIconsAnm == GHIDRA_CAST<ANM2 *>(0x0)) {
|
|
newIconsAnm = GHIDRA_CAST<ANM2 *>(0x0);
|
|
}
|
|
else {
|
|
(GHIDRA_CAST<ANM2 *>((newIconsAnm)))->ANM2::constructor();
|
|
local_14 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),1);
|
|
newIconsAnm[1]._filename._buf[0] = '\0';
|
|
newIconsAnm[1]._filename._buf[1] = '\0';
|
|
newIconsAnm[1]._filename._buf[2] = '\0';
|
|
newIconsAnm[1]._filename._buf[3] = '\0';
|
|
pAVar1 = newIconsAnm + 1;
|
|
(pAVar1->_filename)._buf[4] = '\0';
|
|
(pAVar1->_filename)._buf[5] = '\0';
|
|
(pAVar1->_filename)._buf[6] = '\0';
|
|
(pAVar1->_filename)._buf[7] = '\0';
|
|
pAVar1 = newIconsAnm + 1;
|
|
(pAVar1->_filename)._buf[8] = '\0';
|
|
(pAVar1->_filename)._buf[9] = '\0';
|
|
(pAVar1->_filename)._buf[10] = '\0';
|
|
(pAVar1->_filename)._buf[0xb] = '\0';
|
|
pcVar3 = newIconsAnm[1]._filename._buf + 0xc;
|
|
pcVar3[0] = '\0';
|
|
pcVar3[1] = '\0';
|
|
pcVar3[2] = '\0';
|
|
pcVar3[3] = '\0';
|
|
newIconsAnm[1]._filename._size = 0;
|
|
mapHead = operator_new(0x1c);
|
|
*(void **)mapHead = mapHead;
|
|
*(void **)(GHIDRA_CAST<char *>(mapHead) + 4) = mapHead;
|
|
*(void **)(GHIDRA_CAST<char *>(mapHead) + 8) = mapHead;
|
|
*GHIDRA_CAST<undefined2 *>((GHIDRA_CAST<char *>(mapHead) + 0xc)) = 0x101;
|
|
*(void **)pcVar3 = mapHead;
|
|
}
|
|
local_14 = 0xffffffff;
|
|
*GHIDRA_CAST<ANM2 **>((GHIDRA_CAST<char *>(newIconsAnm) + 100)) = newIconsAnm;
|
|
anmPath._size = 0;
|
|
anmPath._capacity = 0xf;
|
|
anmPath._buf[0] = '\0';
|
|
anmPath._buf[1] = '\0';
|
|
anmPath._buf[2] = '\0';
|
|
anmPath._buf[3] = '\0';
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) = std::_Allocate(0x20);
|
|
anmPath._size = 0x16;
|
|
anmPath._capacity = 0x1f;
|
|
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anmPath._buf))) + 0x0))),"gfx/ui/text_icons.anm2",0x17);
|
|
local_14 = 2;
|
|
(GHIDRA_CAST<ANM2 *>((newIconsAnm)))->ANM2::Load(&anmPath,1);
|
|
if (0xf < anmPath._capacity) {
|
|
size = anmPath._capacity + 1;
|
|
pcVar3 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anmPath._buf))) + 0x0)));
|
|
if (0xfff < size) {
|
|
pcVar3 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) + -4));
|
|
size = anmPath._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar3))))) {
|
|
/* WARNING: Subroutine does not return */
|
|
_invalid_parameter_noinfo_noreturn();
|
|
}
|
|
}
|
|
operator_delete(pcVar3,size);
|
|
}
|
|
iconsAnm = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(newIconsAnm) + 100));
|
|
}
|
|
*GHIDRA_CAST<float *>((iconsAnm + 0x114)) = (float)*GHIDRA_CAST<ushort *>((GHIDRA_CAST<char *>(newIconsAnm) + 0x2c));
|
|
ExceptionList = local_1c;
|
|
return;
|
|
}
|