Files
isaac-port/generated-src/anm_file_data.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

154 lines
6.6 KiB
C++

#include "classes.h"
// 0040d850
void AnmFileData::Clear()
{
int iVar1;
void *pvVar2;
int frameOffset;
qword *allocCounter;
int animOffset;
uint animIdx;
uint frameIdx;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
uint *blockHeader;
uint blockSize;
void *frameArray;
int frameData;
qword prevAllocated;
puStack_c = &LAB_00af0df0;
local_10 = ExceptionList;
ExceptionList = &local_10;
pvVar2 = *(void **)(GHIDRA_CAST<char *>(this) + 4);
if (pvVar2 != (void *)0x0) {
blockHeader = GHIDRA_CAST<uint *>((GHIDRA_INT(pvVar2) + -4));
local_8 = 0;
_eh_vector_destructor_iterator_(pvVar2,0x38,*blockHeader,FUN_0040db70);
operator_delete(blockHeader,*blockHeader * 0x38 + 4);
}
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
animIdx = 0;
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x10)) != 0) {
animOffset = 0;
pvVar2 = g_mainHeap;
do {
local_8 = 0xffffffff;
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc));
frameIdx = 0;
if (*GHIDRA_CAST<int *>((iVar1 + 0x1c + animOffset)) != 0) {
frameOffset = 0;
do {
frameData = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((animOffset + 0x18 + iVar1)) + 4 + frameOffset));
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(pvVar2) + 0x30));
if (pvVar2 == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
if (frameData != 0) {
blockHeader = GHIDRA_CAST<uint *>((frameData + -4));
blockSize = *blockHeader;
prevAllocated = *allocCounter;
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(prevAllocated) < blockSize));
free(blockHeader);
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc));
pvVar2 = g_mainHeap;
}
frameOffset = frameOffset + 0x10;
frameIdx = frameIdx + 1;
} while (frameIdx < *GHIDRA_CAST<uint *>((animOffset + 0x1c + iVar1)));
}
frameArray = *(void **)(animOffset + 0x18 + iVar1);
if (frameArray != (void *)0x0) {
blockHeader = GHIDRA_CAST<uint *>((GHIDRA_INT(frameArray) + -4));
local_8 = 2;
_eh_vector_destructor_iterator_(frameArray,0x10,*blockHeader,guard_check_icall);
operator_delete(blockHeader,*blockHeader * 0x10 + 4);
pvVar2 = g_mainHeap;
}
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc));
frameIdx = 0;
if (*GHIDRA_CAST<int *>((iVar1 + 0x24 + animOffset)) != 0) {
frameOffset = 0;
do {
frameData = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((animOffset + 0x20 + iVar1)) + 8 + frameOffset));
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(pvVar2) + 0x30));
if (pvVar2 == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
if (frameData != 0) {
blockHeader = GHIDRA_CAST<uint *>((frameData + -4));
blockSize = *blockHeader;
prevAllocated = *allocCounter;
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(prevAllocated) < blockSize));
free(blockHeader);
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc));
pvVar2 = g_mainHeap;
}
frameOffset = frameOffset + 0x10;
frameIdx = frameIdx + 1;
} while (frameIdx < *GHIDRA_CAST<uint *>((animOffset + 0x24 + iVar1)));
}
frameArray = *(void **)(animOffset + 0x20 + iVar1);
if (frameArray != (void *)0x0) {
blockHeader = GHIDRA_CAST<uint *>((GHIDRA_INT(frameArray) + -4));
local_8 = 4;
_eh_vector_destructor_iterator_(frameArray,0x10,*blockHeader,guard_check_icall);
operator_delete(blockHeader,*blockHeader * 0x10 + 4);
pvVar2 = g_mainHeap;
}
iVar1 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0xc)) + 0x28 + animOffset));
allocCounter = GHIDRA_CAST<qword *>((GHIDRA_INT(pvVar2) + 0x30));
if (pvVar2 == (void *)0x0) {
allocCounter = &g_allocatedBytesNoHeap;
}
if (iVar1 != 0) {
blockSize = *GHIDRA_CAST<uint *>((iVar1 + -4));
prevAllocated = *allocCounter;
*GHIDRA_CAST<uint *>(allocCounter) = GHIDRA_UINT(*allocCounter) - blockSize;
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) =
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(allocCounter) + 4)) - GHIDRA_UINT((GHIDRA_UINT(prevAllocated) < blockSize));
free((void *)(iVar1 + -4));
pvVar2 = g_mainHeap;
}
animOffset = animOffset + 0x13c;
animIdx = animIdx + 1;
} while (animIdx < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x10)));
}
pvVar2 = *(void **)(GHIDRA_CAST<char *>(this) + 0xc);
if (pvVar2 != (void *)0x0) {
blockHeader = GHIDRA_CAST<uint *>((GHIDRA_INT(pvVar2) + -4));
local_8 = 6;
_eh_vector_destructor_iterator_(pvVar2,0x13c,*blockHeader,std::string::_Tidy_deallocate);
operator_delete(blockHeader,*blockHeader * 0x13c + 4);
}
pvVar2 = *(void **)(GHIDRA_CAST<char *>(this) + 0x14);
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0;
if (pvVar2 != (void *)0x0) {
blockHeader = GHIDRA_CAST<uint *>((GHIDRA_INT(pvVar2) + -4));
local_8 = 7;
_eh_vector_destructor_iterator_(pvVar2,0x18,*blockHeader,std::string::_Tidy_deallocate);
operator_delete(blockHeader,*blockHeader * 0x18 + 4);
}
pvVar2 = *(void **)(GHIDRA_CAST<char *>(this) + 0x1c);
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0;
if (pvVar2 != (void *)0x0) {
blockHeader = GHIDRA_CAST<uint *>((GHIDRA_INT(pvVar2) + -4));
local_8 = 8;
_eh_vector_destructor_iterator_(pvVar2,0x18,*blockHeader,std::string::_Tidy_deallocate);
operator_delete(blockHeader,*blockHeader * 0x18 + 4);
}
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
ExceptionList = local_10;
return;
}