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>
150 lines
6.3 KiB
C++
150 lines
6.3 KiB
C++
#include "classes.h"
|
|
|
|
// 0090d360
|
|
void * KAGE::Filesys::BufferedStream::operator_assign(void *other)
|
|
{
|
|
uint dataSize;
|
|
void *dstData;
|
|
int *buffer;
|
|
void *srcData;
|
|
|
|
buffer = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0xc));
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 4));
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 8)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 8));
|
|
if (buffer != GHIDRA_CAST<int *>((GHIDRA_INT(other) + 0xc))) {
|
|
srcData = *(void **)(GHIDRA_CAST<char *>(other) + 0xc);
|
|
dstData = (void *)*buffer;
|
|
dataSize = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(other) + 0x10)) - GHIDRA_INT(srcData);
|
|
if (GHIDRA_UINT((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x14)) - GHIDRA_INT(dstData))) < dataSize) {
|
|
std::vector<char>::_Clear_and_reserve(dataSize);
|
|
dstData = (void *)*buffer;
|
|
}
|
|
memmove(dstData,srcData,dataSize);
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 0x10)) = dataSize + GHIDRA_INT(dstData);
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x18)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 0x18));
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 0x1c));
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 0x20));
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x24)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(other) + 0x24));
|
|
return this;
|
|
}
|
|
|
|
// 00a57fc0
|
|
byte KAGE::Filesys::BufferedStream::rebuffer()
|
|
{
|
|
uint remainingBytes;
|
|
uint readBytes;
|
|
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x18)) != 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Attempting to rebuffer data on a read-only buffer"));
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc));
|
|
remainingBytes = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x24)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
|
|
readBytes = 0;
|
|
if (-1 < GHIDRA_INT(remainingBytes)) {
|
|
readBytes = remainingBytes;
|
|
}
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
|
|
if (*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 8)) < readBytes) {
|
|
readBytes = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 8));
|
|
}
|
|
if (readBytes == 0) {
|
|
return 0;
|
|
}
|
|
FUN_007dccd0(readBytes);
|
|
this->vfunc_9(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)));
|
|
this->vfunc_10(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)),1,readBytes);
|
|
return 1;
|
|
}
|
|
|
|
// 00a58040
|
|
KAGE::Filesys::BufferedStream::BufferedStream(int bufferSize)
|
|
{
|
|
uint available;
|
|
uint fillSize;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
|
|
puStack_c = &LAB_00b12b18;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 8)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x24)) = 0;
|
|
*GHIDRA_CAST<undefined ***>((GHIDRA_CAST<char *>(this) + 0x28)) = StreamBase::vftable;
|
|
local_8 = 1;
|
|
*GHIDRA_CAST<undefined ***>(this) = vftable;
|
|
*GHIDRA_CAST<undefined ***>((GHIDRA_CAST<char *>(this) + 0x28)) = vftable;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 8)) = 0xffffffff;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 4)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = *GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc));
|
|
available = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x24)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x20));
|
|
fillSize = 0;
|
|
if (-1 < GHIDRA_INT(available)) {
|
|
fillSize = available;
|
|
}
|
|
if (*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 8)) < fillSize) {
|
|
fillSize = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(this) + 8));
|
|
}
|
|
if (fillSize != 0) {
|
|
FUN_007dccd0(fillSize);
|
|
if (*(code **)(*GHIDRA_CAST<int *>(this) + 0x24) != GridEntity_Statue::Render) {
|
|
this->vfunc_9(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x20)));
|
|
}
|
|
if (*(code **)(*GHIDRA_CAST<int *>(this) + 0x28) != FUN_00a584b0) {
|
|
this->vfunc_10(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)),1,fillSize);
|
|
}
|
|
}
|
|
if (bufferSize != 0) {
|
|
FUN_007dccd0(bufferSize);
|
|
}
|
|
ExceptionList = local_10;
|
|
return this;
|
|
}
|
|
|
|
// 00a58270
|
|
void KAGE::Filesys::BufferedStream::seek_base2(int param_1, int param_2)
|
|
{
|
|
int in_ECX;
|
|
uint streamSize;
|
|
uint bufferStart;
|
|
uint position;
|
|
|
|
if (param_2 != 0) {
|
|
if (param_2 == 1) {
|
|
*GHIDRA_CAST<int *>((in_ECX + -8)) = *GHIDRA_CAST<int *>((in_ECX + -8)) + param_1;
|
|
goto LAB_00a582a0;
|
|
}
|
|
if (param_2 != 2) goto LAB_00a582a0;
|
|
param_1 = *GHIDRA_CAST<int *>((in_ECX + -0x24)) + param_1;
|
|
}
|
|
*GHIDRA_CAST<int *>((in_ECX + -8)) = param_1;
|
|
LAB_00a582a0:
|
|
if (*GHIDRA_CAST<int *>((in_ECX + -0x10)) == 0) {
|
|
streamSize = *GHIDRA_CAST<int *>((in_ECX + -0x18)) - *GHIDRA_CAST<int *>((in_ECX + -0x1c));
|
|
}
|
|
else {
|
|
streamSize = *GHIDRA_CAST<uint *>((in_ECX + -0x24));
|
|
}
|
|
position = *GHIDRA_CAST<uint *>((in_ECX + -8));
|
|
bufferStart = *GHIDRA_CAST<uint *>((in_ECX + -4));
|
|
if ((position < bufferStart) || (streamSize < position - bufferStart)) {
|
|
rebuffer((void *)(in_ECX + -0x28));
|
|
position = *GHIDRA_CAST<uint *>((in_ECX + -8));
|
|
bufferStart = *GHIDRA_CAST<uint *>((in_ECX + -4));
|
|
}
|
|
*GHIDRA_CAST<uint *>((in_ECX + -0xc)) = position - bufferStart;
|
|
return;
|
|
}
|