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>
This commit is contained in:
1 parent
2ff2d5d87f
commit
3ce74c6e2d
331 files changed
+485
-7835
No files matched your search
@@ -0,0 +1,230 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 0099b510
|
||||
void GridEntity_Gravity::BeginBatches()
|
||||
{
|
||||
this->_collisionClass = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// 0099b520
|
||||
void GridEntity_Gravity::guard_check_icall()
|
||||
{
|
||||
void *pvVar1;
|
||||
int iVar2;
|
||||
code *pcVar3;
|
||||
byte isAnimSet;
|
||||
int belowRow;
|
||||
char *freeBlock;
|
||||
int column;
|
||||
uint uVar4;
|
||||
ANM2 *floorSprite;
|
||||
RNG rng;
|
||||
undefined4 local_6c;
|
||||
ANM2 *sprite;
|
||||
std_string itemDungeonPath;
|
||||
std_string tilesPath;
|
||||
byte floorAnimName [32];
|
||||
uint local_14;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
undefined4 local_8;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00b0d90d;
|
||||
local_10 = ExceptionList;
|
||||
local_14 = __security_cookie ^ GHIDRA_UINT((floorAnimName + 0x30));
|
||||
ExceptionList = &local_10;
|
||||
pvVar1 = g_game->_room;
|
||||
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0xc));
|
||||
column = GHIDRA_INT(((((float)(this->_gridIndex % iVar2) * 40.0 + 40.0 + 0.0) - 40.0) / 40.0 + 0.5));
|
||||
belowRow = GHIDRA_INT(((((float)(this->_gridIndex / iVar2) * 40.0 + 120.0 + 40.0) - 120.0) / 40.0 + 0.5))
|
||||
;
|
||||
if (((((-1 < column) && (column < iVar2)) && (-1 < belowRow)) &&
|
||||
((belowRow < *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x10)) &&
|
||||
(uVar4 = iVar2 * belowRow + column, uVar4 < 0x1c0)))) &&
|
||||
((iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + uVar4 * 4 + 0x24)), iVar2 != 0 &&
|
||||
((iVar2 = *GHIDRA_CAST<int *>((iVar2 + 4)), iVar2 == 3 || (iVar2 == 0xf)))))) {
|
||||
iVar2 = (this->_desc)._spawnSeed;
|
||||
local_6c = 0xc;
|
||||
rng._shift3 = 0xc;
|
||||
sprite = &this->_sprite;
|
||||
rng._shift1 = 5;
|
||||
rng._shift2 = 0x15;
|
||||
rng._seed = iVar2;
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x1d18)) == 0x38) {
|
||||
tilesPath._size = 0;
|
||||
tilesPath._capacity = 0xf;
|
||||
tilesPath._buf[0] = '\0';
|
||||
tilesPath._buf[1] = '\0';
|
||||
tilesPath._buf[2] = '\0';
|
||||
tilesPath._buf[3] = '\0';
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) = std::_Allocate(0x20);
|
||||
tilesPath._size = 0x1a;
|
||||
tilesPath._capacity = 0x1f;
|
||||
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(tilesPath._buf))) + 0x0))),"gfx/grid/Tiles_Rotgut.anm2",0x1b);
|
||||
local_8 = 0;
|
||||
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Load(&tilesPath,1);
|
||||
local_8 = 0xffffffff;
|
||||
if (0xf < tilesPath._capacity) {
|
||||
uVar4 = tilesPath._capacity + 1;
|
||||
freeBlock = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(tilesPath._buf))) + 0x0)));
|
||||
if (0xfff < uVar4) {
|
||||
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) + -4));
|
||||
uVar4 = tilesPath._capacity + 0x24;
|
||||
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(freeBlock,uVar4);
|
||||
}
|
||||
isAnimSet = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Floor"),1);
|
||||
if ((isAnimSet != 0) && ((this->_sprite)._animState._animData != (void *)0x0)) {
|
||||
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::SetFrameFloat(0.0);
|
||||
if ((this->_sprite)._animState._animData != (void *)0x0) {
|
||||
(this->_sprite)._animState._isPlaying = 0;
|
||||
}
|
||||
}
|
||||
pvVar1 = (this->_sprite)._animState._animData;
|
||||
if (pvVar1 == (void *)0x0) {
|
||||
uVar4 = 0;
|
||||
}
|
||||
else {
|
||||
uVar4 = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(pvVar1) + 0x30));
|
||||
}
|
||||
uVar4 = (GHIDRA_CAST<RNG *>((&rng)))->RNG::RandomInt(uVar4);
|
||||
if ((this->_sprite)._animState._animData != (void *)0x0) {
|
||||
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::SetFrameFloat((float)GHIDRA_INT(uVar4));
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0x1d18)) == 0x37) {
|
||||
tilesPath._size = 0;
|
||||
tilesPath._capacity = 0xf;
|
||||
tilesPath._buf[0] = '\0';
|
||||
tilesPath._buf[1] = '\0';
|
||||
tilesPath._buf[2] = '\0';
|
||||
tilesPath._buf[3] = '\0';
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) = std::_Allocate(0x30);
|
||||
floorSprite = sprite;
|
||||
tilesPath._size = 0x26;
|
||||
tilesPath._capacity = 0x2f;
|
||||
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(tilesPath._buf))) + 0x0))),"gfx/grid/Tiles_Itemdungeon_Gideon.anm2",0x27);
|
||||
local_8 = 1;
|
||||
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Load(&tilesPath,1);
|
||||
local_8 = 0xffffffff;
|
||||
if (0xf < tilesPath._capacity) {
|
||||
uVar4 = tilesPath._capacity + 1;
|
||||
freeBlock = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(tilesPath._buf))) + 0x0)));
|
||||
if (0xfff < uVar4) {
|
||||
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) + -4));
|
||||
uVar4 = tilesPath._capacity + 0x24;
|
||||
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(freeBlock,uVar4);
|
||||
}
|
||||
tilesPath._size = 0;
|
||||
tilesPath._capacity = 0xf;
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) & 0xffffff00;
|
||||
}
|
||||
else {
|
||||
itemDungeonPath._size = 0;
|
||||
itemDungeonPath._capacity = 0xf;
|
||||
itemDungeonPath._buf[0] = '\0';
|
||||
itemDungeonPath._buf[1] = '\0';
|
||||
itemDungeonPath._buf[2] = '\0';
|
||||
itemDungeonPath._buf[3] = '\0';
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) = std::_Allocate(0x20);
|
||||
floorSprite = sprite;
|
||||
itemDungeonPath._size = 0x1f;
|
||||
itemDungeonPath._capacity = 0x1f;
|
||||
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(itemDungeonPath._buf))) + 0x0))),"gfx/grid/Tiles_Itemdungeon.anm2",0x20);
|
||||
local_8 = 2;
|
||||
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Load(&itemDungeonPath,1);
|
||||
local_8 = 0xffffffff;
|
||||
if (0xf < itemDungeonPath._capacity) {
|
||||
uVar4 = itemDungeonPath._capacity + 1;
|
||||
freeBlock = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(itemDungeonPath._buf))) + 0x0)));
|
||||
if (0xfff < uVar4) {
|
||||
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) + -4));
|
||||
uVar4 = itemDungeonPath._capacity + 0x24;
|
||||
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(freeBlock))))) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(freeBlock,uVar4);
|
||||
}
|
||||
itemDungeonPath._size = 0;
|
||||
itemDungeonPath._capacity = 0xf;
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) & 0xffffff00;
|
||||
}
|
||||
if (iVar2 == 0) {
|
||||
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
||||
pcVar3 = (code *)swi(3);
|
||||
(*pcVar3)();
|
||||
return;
|
||||
}
|
||||
sprintf_s(floorAnimName,0x1f,GHIDRA_CAST<byte *>("Floor%u"));
|
||||
(GHIDRA_CAST<ANM2 *>((floorSprite)))->ANM2::Play(floorAnimName,0);
|
||||
}
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
|
||||
// 0099b980
|
||||
void GridEntity_Gravity::Update()
|
||||
{
|
||||
int *playerSlot;
|
||||
void *playerListEnd;
|
||||
int gridY;
|
||||
PlayerManager *playerManager;
|
||||
int player;
|
||||
uint i;
|
||||
int gridWidth;
|
||||
int player;
|
||||
|
||||
playerManager = &g_game->_playerManager;
|
||||
i = 0;
|
||||
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
||||
GHIDRA_INT((g_game->_playerManager)._playerList._begin) >> 2 != 0) {
|
||||
do {
|
||||
playerListEnd = (playerManager->_playerList)._end;
|
||||
if (GHIDRA_INT(playerListEnd) - GHIDRA_INT((playerManager->_playerList)._begin) >> 2 == 0) {
|
||||
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("(GHIDRA_CAST<PlayerManager *>(()))->PlayerManager::GetPlayer() : There are no players! \n"));
|
||||
playerListEnd = (playerManager->_playerList)._end;
|
||||
}
|
||||
playerSlot = (playerManager->_playerList)._begin;
|
||||
if (i < GHIDRA_UINT((GHIDRA_INT(playerListEnd) - GHIDRA_INT(playerSlot) >> 2))) {
|
||||
playerSlot = playerSlot + i;
|
||||
}
|
||||
player = *playerSlot;
|
||||
player = GHIDRA_INT(((*GHIDRA_CAST<float *>((player + 0x33c)) - 40.0) / 40.0 + 0.5));
|
||||
gridY = GHIDRA_INT(((*GHIDRA_CAST<float *>((player + 0x340)) - 120.0) / 40.0 + 0.5));
|
||||
if ((((player < 0) || (gridWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc)), gridWidth <= player)) ||
|
||||
(gridY < 0)) || (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x10)) <= gridY)) {
|
||||
player = -1;
|
||||
}
|
||||
else {
|
||||
player = gridWidth * gridY + player;
|
||||
}
|
||||
if (player == this->_gridIndex) {
|
||||
*GHIDRA_CAST<uint *>((player + 0x168)) = *GHIDRA_CAST<uint *>((player + 0x168)) | 0x8000;
|
||||
*GHIDRA_CAST<undefined4 *>((player + 0x16c)) = *GHIDRA_CAST<undefined4 *>((player + 0x16c));
|
||||
}
|
||||
i = i + 1;
|
||||
playerManager = &g_game->_playerManager;
|
||||
} while (i < GHIDRA_UINT((GHIDRA_INT((g_game->_playerManager)._playerList._end) -
|
||||
GHIDRA_INT((playerManager->_playerList)._begin) >> 2)));
|
||||
}
|
||||
if ((this->_sprite)._loaded != 0) {
|
||||
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Update();
|
||||
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._overlayAnimState)))->AnimationState::Update();
|
||||
}
|
||||
return;
|
||||
}
|
||||
Reference in new issue
Block a user