Files
isaac-port/generated-src/achievement_overlay.cpp
T
shweetandClaude Opus 5.5 3ce74c6e2d 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>
2026-11-19 21:10:23 -05:00

481 lines
18 KiB
C++

#include "classes.h"
// 009314c0
AchievementOverlay::~AchievementOverlay()
{
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
local_8 = 0xffffffff;
puStack_c = &LAB_00af09f0;
local_10 = ExceptionList;
ExceptionList = &local_10;
_eh_vector_destructor_iterator_(this->_entries,0x34,0x282,FUN_00420b00);
local_8 = 0;
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Reset();
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._overlayAnimState)))->AnimationState::~AnimationState();
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::~AnimationState();
(GHIDRA_CAST<std::string *>(((this->_sprite)._animDefaultName._buf)))->std::string::_Tidy_deallocate();
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(&this->_sprite))))->std::string::_Tidy_deallocate();
std::deque<4byte>::~deque();
ExceptionList = local_10;
return;
}
// 00931550
void AchievementOverlay::load_graphics()
{
char *ptr;
uint size;
std_string anm2Path;
uint local_24;
undefined1 *puStack_20;
void *local_1c;
undefined1 *puStack_18;
undefined4 local_14;
puStack_20 = GHIDRA_CAST<undefined1 *>((GHIDRA_INT(register0x00000010) + -4));
local_14 = 0xffffffff;
puStack_18 = &LAB_00af18ad;
local_1c = ExceptionList;
local_24 = __security_cookie ^ GHIDRA_INT(register0x00000010) - 0x10U;
ExceptionList = &local_1c;
anm2Path._size = 0;
anm2Path._capacity = 0xf;
anm2Path._buf[0] = '\0';
anm2Path._buf[1] = '\0';
anm2Path._buf[2] = '\0';
anm2Path._buf[3] = '\0';
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = std::_Allocate(0x30);
anm2Path._size = 0x24;
anm2Path._capacity = 0x2f;
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/ui/achievement/Achievements.anm2",0x25);
local_14 = 0;
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Load(&anm2Path,1);
if (0xf < anm2Path._capacity) {
size = anm2Path._capacity + 1;
ptr = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
if (0xfff < size) {
ptr = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
size = anm2Path._capacity + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(ptr))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(ptr,size);
}
this->_state = 0;
this->_frame = 0;
this->_isPopupBlocked = 0;
ExceptionList = local_1c;
return;
}
// 00931670
byte AchievementOverlay::load_xml(byte *path)
{
qword qVar1;
byte bVar2;
uint uVar3;
int *file;
int iVar4;
byte *text;
void *node;
void *gfxRootAttribute;
byte *****pppppbVar5;
byte *pbVar6;
byte *pbVar7;
std_string *gfxLength;
uint uVar8;
qword *allocatedBytes;
bool isLess;
byte *pbVar9;
uint achievementId;
byte *****textString [4];
uint textStringSize;
uint textStringCapacity;
byte *****gfxPath;
undefined4 uStack_100b4;
undefined4 uStack_100b0;
undefined4 uStack_100ac;
uint gfxPathSize;
uint gfxPathCapacity;
undefined1 doc [48];
undefined1 auStack_10070 [65564];
byte *****fullGfxPath;
undefined4 uStack_50;
undefined4 uStack_4c;
undefined4 uStack_48;
uint fullGfxPathSize;
uint fullGfxPathCapacity;
byte *****gfxRoot [4];
uint gfxRootSize;
uint gfxRootCapacity;
uint local_24;
undefined1 *puStack_20;
void *local_1c;
undefined1 *puStack_18;
byte ****local_14;
undefined4 *attribute;
puStack_20 = GHIDRA_CAST<undefined1 *>((gfxRoot + 0xe));
local_14 = GHIDRA_CAST<byte ****>(0xffffffff);
puStack_18 = &LAB_00b0ad43;
local_1c = ExceptionList;
uVar3 = __security_cookie ^ GHIDRA_UINT((gfxRoot + 0xb));
ExceptionList = &local_1c;
local_24 = uVar3;
file = (GHIDRA_CAST<FileSystem *>((&PTR_vftable_00c37a10)))->FileSystem::Open(path,GHIDRA_CAST<int *>(0x0));
if (file == GHIDRA_CAST<int *>(0x0)) {
bVar2 = 0;
}
else {
iVar4 = (**(code **)(*file + 4))(uVar3);
text = operator_new_tracked(iVar4 + 1);
(**(code **)(*file + 0x14))(text,1,iVar4);
text[iVar4] = 0;
(**(code **)*file)(1);
FUN_00413b90();
local_14 = GHIDRA_CAST<byte ****>(0x0);
pbVar9 = GHIDRA_CAST<byte *>(0x93173f);
pbVar6 = text;
(GHIDRA_CAST<rapidxml::xml_document *>((doc)))->rapidxml::xml_document::parse(text);
bVar2 = (byte)pbVar6;
node = (GHIDRA_CAST<xml_node *>((doc)))->xml_node::first_node(GHIDRA_CAST<byte *>("achievements"),GHIDRA_INT(pbVar9),bVar2);
gfxRootSize = 0;
gfxRootCapacity = 0xf;
gfxRoot[0] = GHIDRA_CAST<byte *****>(0x0);
local_14 = GHIDRA_CAST<byte ****>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),1));
gfxRootAttribute = (GHIDRA_CAST<xml_node *>((node)))->xml_node::first_attribute(&DAT_00b6987c,GHIDRA_UINT(pbVar9),bVar2);
if (gfxRootAttribute != (void *)0x0) {
pbVar9 = &g_xmlNullStr;
if (*GHIDRA_CAST<byte **>((GHIDRA_CAST<char *>(gfxRootAttribute) + 4)) != GHIDRA_CAST<byte *>(0x0)) {
pbVar9 = *GHIDRA_CAST<byte **>((GHIDRA_CAST<char *>(gfxRootAttribute) + 4));
}
pbVar6 = pbVar9;
do {
bVar2 = *pbVar6;
pbVar6 = pbVar6 + 1;
} while (bVar2 != 0);
uVar3 = GHIDRA_INT(pbVar6) - GHIDRA_INT((pbVar9 + 1));
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(gfxRoot))))->std::string::assign(pbVar9,uVar3);
bVar2 = (byte)uVar3;
}
for (node = (GHIDRA_CAST<xml_node *>((node)))->xml_node::first_node(GHIDRA_CAST<byte *>("achievement"),GHIDRA_INT(pbVar9),bVar2);
node != (void *)0x0; node = *(void **)(GHIDRA_CAST<char *>(node) + 0x2c)) {
textStringSize = 0;
textStringCapacity = 0xf;
textString[0] = GHIDRA_CAST<byte *****>(0x0);
gfxPathSize = 0;
gfxPathCapacity = 0xf;
gfxPath = GHIDRA_CAST<byte *****>(0x0);
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))) = (undefined3)(GHIDRA_UINT(local_14) >> 8);
local_14 = GHIDRA_CAST<byte ****>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),2));
for (attribute = *GHIDRA_CAST<undefined4 **>((GHIDRA_CAST<char *>(node) + 0x20)); attribute != GHIDRA_CAST<undefined4 *>(0x0);
attribute = GHIDRA_CAST<undefined4 *>(attribute[6])) {
pbVar9 = GHIDRA_CAST<byte *>(*attribute);
pbVar7 = s_id;
pbVar6 = &g_xmlNullStr;
if (pbVar9 != GHIDRA_CAST<byte *>(0x0)) {
pbVar6 = pbVar9;
}
do {
bVar2 = *pbVar6;
isLess = bVar2 < *pbVar7;
if (bVar2 != *pbVar7) {
LAB_00931851:
uVar3 = -GHIDRA_UINT(isLess) | 1;
goto LAB_00931856;
}
if (bVar2 == 0) break;
bVar2 = pbVar6[1];
isLess = bVar2 < pbVar7[1];
if (bVar2 != pbVar7[1]) goto LAB_00931851;
pbVar6 = pbVar6 + 2;
pbVar7 = pbVar7 + 2;
} while (bVar2 != 0);
uVar3 = 0;
LAB_00931856:
if (uVar3 == 0) {
pbVar9 = &g_xmlNullStr;
if (GHIDRA_CAST<byte *>(attribute[1]) != GHIDRA_CAST<byte *>(0x0)) {
pbVar9 = GHIDRA_CAST<byte *>(attribute[1]);
}
achievementId = atoi(GHIDRA_CAST<char *>(pbVar9));
}
else {
pbVar7 = &DAT_00b6e37c;
pbVar6 = &g_xmlNullStr;
if (pbVar9 != GHIDRA_CAST<byte *>(0x0)) {
pbVar6 = pbVar9;
}
do {
bVar2 = *pbVar6;
isLess = bVar2 < *pbVar7;
if (bVar2 != *pbVar7) {
LAB_009318b0:
uVar3 = -GHIDRA_UINT(isLess) | 1;
goto LAB_009318b5;
}
if (bVar2 == 0) break;
bVar2 = pbVar6[1];
isLess = bVar2 < pbVar7[1];
if (bVar2 != pbVar7[1]) goto LAB_009318b0;
pbVar7 = pbVar7 + 2;
pbVar6 = pbVar6 + 2;
} while (bVar2 != 0);
uVar3 = 0;
LAB_009318b5:
if (uVar3 == 0) {
pbVar9 = &g_xmlNullStr;
if (GHIDRA_CAST<byte *>(attribute[1]) != GHIDRA_CAST<byte *>(0x0)) {
pbVar9 = GHIDRA_CAST<byte *>(attribute[1]);
}
pbVar6 = pbVar9;
do {
bVar2 = *pbVar6;
pbVar6 = pbVar6 + 1;
} while (bVar2 != 0);
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(textString))))->std::string::assign(pbVar9,GHIDRA_INT(pbVar6) - GHIDRA_INT((pbVar9 + 1)));
}
else {
pbVar7 = &DAT_00b66fec;
pbVar6 = &g_xmlNullStr;
if (pbVar9 != GHIDRA_CAST<byte *>(0x0)) {
pbVar6 = pbVar9;
}
do {
bVar2 = *pbVar6;
isLess = bVar2 < *pbVar7;
if (bVar2 != *pbVar7) {
LAB_00931920:
uVar3 = -GHIDRA_UINT(isLess) | 1;
goto LAB_00931925;
}
if (bVar2 == 0) break;
bVar2 = pbVar6[1];
isLess = bVar2 < pbVar7[1];
if (bVar2 != pbVar7[1]) goto LAB_00931920;
pbVar7 = pbVar7 + 2;
pbVar6 = pbVar6 + 2;
} while (bVar2 != 0);
uVar3 = 0;
LAB_00931925:
if (uVar3 == 0) {
pbVar9 = &g_xmlNullStr;
if (GHIDRA_CAST<byte *>(attribute[1]) != GHIDRA_CAST<byte *>(0x0)) {
pbVar9 = GHIDRA_CAST<byte *>(attribute[1]);
}
pbVar6 = pbVar9;
do {
bVar2 = *pbVar6;
pbVar6 = pbVar6 + 1;
} while (bVar2 != 0);
gfxLength = GHIDRA_CAST<std_string *>((pbVar6 + -GHIDRA_INT((pbVar9 + 1))));
if (GHIDRA_CAST<std_string *>((0x7fffffff - gfxRootSize)) < gfxLength) {
/* WARNING: Subroutine does not return */
std::string::_Xlen();
}
pppppbVar5 = GHIDRA_CAST<byte *****>(gfxRoot);
if (0xf < gfxRootCapacity) {
pppppbVar5 = gfxRoot[0];
}
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(&fullGfxPath))))->std::string::concat(GHIDRA_INT(this),gfxLength,GHIDRA_CAST<byte *>(pppppbVar5),
gfxRootSize,pbVar9,GHIDRA_UINT(gfxLength));
if (0xf < gfxPathCapacity) {
uVar3 = gfxPathCapacity + 1;
pppppbVar5 = gfxPath;
if (0xfff < uVar3) {
pppppbVar5 = GHIDRA_CAST<byte *****>(gfxPath[-1]);
uVar3 = gfxPathCapacity + 0x24;
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(gfxPath) + (-4 - GHIDRA_INT(pppppbVar5)))))
goto LAB_00931b16;
}
operator_delete(pppppbVar5,uVar3);
}
gfxPath = fullGfxPath;
uStack_100b4 = uStack_50;
uStack_100b0 = uStack_4c;
uStack_100ac = uStack_48;
gfxPathSize = fullGfxPathSize;
gfxPathCapacity = fullGfxPathCapacity;
}
}
}
if (attribute[4] == 0) break;
}
if (achievementId < 0x282) {
this->_entries[achievementId]._id = achievementId;
gfxLength = &this->_entries[achievementId]._name;
if (gfxLength != GHIDRA_CAST<std_string *>(textString)) {
pppppbVar5 = GHIDRA_CAST<byte *****>(textString);
if (0xf < textStringCapacity) {
pppppbVar5 = textString[0];
}
(GHIDRA_CAST<std::string *>((gfxLength->_buf)))->std::string::assign(GHIDRA_CAST<byte *>(pppppbVar5),textStringSize);
}
gfxLength = &this->_entries[achievementId]._gfx;
if (gfxLength != GHIDRA_CAST<std_string *>(&gfxPath)) {
pppppbVar5 = GHIDRA_CAST<byte *****>(&gfxPath);
if (0xf < gfxPathCapacity) {
pppppbVar5 = gfxPath;
}
(GHIDRA_CAST<std::string *>((gfxLength->_buf)))->std::string::assign(GHIDRA_CAST<byte *>(pppppbVar5),gfxPathSize);
}
}
uVar3 = textStringCapacity;
local_14 = GHIDRA_CAST<byte ****>(CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_14)) + 0x1))),1));
if (0xf < gfxPathCapacity) {
uVar8 = gfxPathCapacity + 1;
pppppbVar5 = gfxPath;
if (0xfff < uVar8) {
pppppbVar5 = GHIDRA_CAST<byte *****>(gfxPath[-1]);
uVar8 = gfxPathCapacity + 0x24;
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(gfxPath) + (-4 - GHIDRA_INT(pppppbVar5))))) goto LAB_00931b16;
}
operator_delete(pppppbVar5,uVar8);
}
if (0xf < uVar3) {
uVar8 = uVar3 + 1;
pppppbVar5 = textString[0];
if (0xfff < uVar8) {
pppppbVar5 = GHIDRA_CAST<byte *****>(textString[0][-1]);
uVar8 = uVar3 + 0x24;
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(textString[0]) + (-4 - GHIDRA_INT(pppppbVar5)))))
goto LAB_00931b16;
}
operator_delete(pppppbVar5,uVar8);
}
}
local_14 = GHIDRA_CAST<byte ****>((GHIDRA_UINT(local_14) & 0xffffff00));
if (0xf < gfxRootCapacity) {
uVar3 = gfxRootCapacity + 1;
pppppbVar5 = gfxRoot[0];
if (0xfff < uVar3) {
pppppbVar5 = GHIDRA_CAST<byte *****>(gfxRoot[0][-1]);
uVar3 = gfxRootCapacity + 0x24;
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(gfxRoot[0]) + (-4 - GHIDRA_INT(pppppbVar5))))) {
LAB_00931b16:
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(pppppbVar5,uVar3);
}
local_14 = GHIDRA_CAST<byte ****>(0x3);
(GHIDRA_CAST<xml_memory_pool *>((auStack_10070)))->xml_memory_pool::clear();
if (g_mainHeap == (void *)0x0) {
allocatedBytes = &g_allocatedBytesNoHeap;
}
else {
allocatedBytes = GHIDRA_CAST<qword *>((GHIDRA_INT(g_mainHeap) + 0x30));
}
if (text != GHIDRA_CAST<byte *>(0x0)) {
uVar3 = *GHIDRA_CAST<uint *>((text + -4));
qVar1 = *allocatedBytes;
*GHIDRA_CAST<uint *>(allocatedBytes) = GHIDRA_UINT(*allocatedBytes) - uVar3;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) =
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocatedBytes) + 4)) - GHIDRA_UINT((GHIDRA_UINT(qVar1) < uVar3));
free(text + -4);
}
bVar2 = 1;
}
ExceptionList = local_1c;
return bVar2;
}
// 00931ba0
void AchievementOverlay::Update()
{
byte bVar1;
uint queueOffset;
LayerState *layer;
std_string *pngFilename;
byte unk;
int iVar2;
float spriteScale;
AchievementOverlay *local_c [2];
Manager *manager;
uint queueSize;
iVar2 = this->_state;
local_c[0] = this;
if ((((iVar2 != 0) && (this->_isPopupBlocked == 0)) && ((g_manager->_framecount & 1) == 0)) &&
((this->_sprite)._loaded != 0)) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Update();
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._overlayAnimState)))->AnimationState::Update();
iVar2 = this->_state;
}
if (iVar2 == 1) {
if (((this->_sprite)._animState._animData == (void *)0x0) ||
((this->_sprite)._animState._isPlaying == 0)) {
this->_frame = 0;
this->_state = 2;
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(s_Idle,0);
manager = g_manager;
local_c[0] = GHIDRA_CAST<AchievementOverlay *>(&DAT_00000008);
seed_fart_sound_override(GHIDRA_CAST<int *>(local_c));
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_c[0]),1.0,2,0,1.0,0.0);
}
}
else if (iVar2 == 2) {
iVar2 = this->_frame;
this->_frame = iVar2 + 1;
if ((0x5a < iVar2) || (bVar1 = input_is_action_pressed(0xe,-1,GHIDRA_CAST<Entity *>(0x0),iVar2), bVar1 != 0))
{
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("Dissapear"),0);
this->_state = 3;
}
}
else if ((iVar2 == 3) &&
(((this->_sprite)._animState._animData == (void *)0x0 ||
((this->_sprite)._animState._isPlaying == 0)))) {
this->_state = 0;
}
spriteScale = 1.0;
if ((this->_state == 0) && (queueSize = (this->_queue)._size, queueSize != 0)) {
queueOffset = (this->_queue)._offset;
this->_currentEntry =
*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_INT((this->_queue)._map) +
(queueOffset >> 2 & (this->_queue)._mapSize - 1) * 4)) +
(queueOffset & 3) * 4));
queueSize = queueSize - 1;
(this->_queue)._size = queueSize;
queueOffset = 0;
if (queueSize != 0) {
queueOffset = (this->_queue)._offset + 1;
}
(this->_queue)._offset = queueOffset;
manager = g_manager;
this->_state = 1;
if (((manager->_optionsConfig)._popupsMode == 2) ||
(manager->_netplayManager != *GHIDRA_CAST<NetplayManager *>((manager + 1)))) {
spriteScale = 0.3;
bVar1 = 0;
}
else {
bVar1 = 1;
}
(this->_sprite)._scale.x = spriteScale;
(this->_sprite)._scale.y = spriteScale;
layer = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x0));
layer->_visible = bVar1;
pngFilename = &this->_entries[this->_currentEntry]._gfx;
if (pngFilename->_size == 0) {
layer = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x3));
layer->_visible = 0;
KAGE_LogMessage(8,GHIDRA_CAST<byte *>("No sprite for achievement %d (%s)\n"));
}
else {
(GHIDRA_CAST<Sprite *>((GHIDRA_CAST<Sprite *>(&this->_sprite))))->Sprite::ReplaceSpritesheet(3,pngFilename);
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::LoadGraphics(unk);
layer = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::GetLayer(GHIDRA_CAST<byte *>(0x3));
layer->_visible = 1;
}
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("Appear"),0);
}
return;
}