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>
179 lines
6.6 KiB
C++
179 lines
6.6 KiB
C++
#include "classes.h"
|
|
|
|
// 0071ee90
|
|
void GridEntity_TNT::BeginBatches()
|
|
{
|
|
byte bVar1;
|
|
EntityConfig_Entity *entity;
|
|
byte *currentAnimChar;
|
|
char *ptr;
|
|
byte *idleAnimChar;
|
|
uint uVar2;
|
|
EntityConfig *entityConfig;
|
|
bool isLess;
|
|
undefined1 lowerBoundResult [8];
|
|
void *lowerBoundNode;
|
|
GridEntity_TNT *self;
|
|
undefined4 entityKey;
|
|
std_string anm2Path;
|
|
uint local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
uint local_8;
|
|
byte *animData;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af32ed;
|
|
local_10 = ExceptionList;
|
|
local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size);
|
|
ExceptionList = &local_10;
|
|
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 1000;
|
|
}
|
|
anm2Path._size = 0;
|
|
anm2Path._capacity = 0xf;
|
|
anm2Path._buf[0] = '\0';
|
|
anm2Path._buf[1] = '\0';
|
|
anm2Path._buf[2] = '\0';
|
|
anm2Path._buf[3] = '\0';
|
|
self = this;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = std::_Allocate(0x20);
|
|
anm2Path._size = 0x16;
|
|
anm2Path._capacity = 0x1f;
|
|
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/grid/grid_tnt.anm2",0x17);
|
|
local_8 = 0;
|
|
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Load(&anm2Path,1);
|
|
local_8 = 0xffffffff;
|
|
if (0xf < anm2Path._capacity) {
|
|
uVar2 = anm2Path._capacity + 1;
|
|
ptr = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
|
|
if (0xfff < uVar2) {
|
|
ptr = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
|
|
uVar2 = 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,uVar2);
|
|
}
|
|
anm2Path._size = 0;
|
|
entityConfig = &g_manager->_entityConfig;
|
|
anm2Path._capacity = 0xf;
|
|
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) & 0xffffff00;
|
|
entityKey = 0x3e801b00;
|
|
_Find_lower_bound<>(lowerBoundResult,&entityKey);
|
|
if (((*GHIDRA_CAST<char *>((GHIDRA_CAST<char *>(lowerBoundNode) + 0xd)) == '\0') &&
|
|
(*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(lowerBoundNode) + 0x10)) < 0x3e801b01)) &&
|
|
(lowerBoundNode != (entityConfig->_entities)._head)) {
|
|
entity = GHIDRA_CAST<EntityConfig_Entity *>((GHIDRA_INT(lowerBoundNode) + 0x18));
|
|
}
|
|
else {
|
|
entity = (GHIDRA_CAST<EntityConfig *>((entityConfig)))->EntityConfig::GetEntity(1000,0,0);
|
|
}
|
|
if (entity != GHIDRA_CAST<EntityConfig_Entity *>(0x0)) {
|
|
(GHIDRA_CAST<EntityConfig *>((entityConfig)))->EntityConfig::PreloadResources(entity);
|
|
}
|
|
animData = (this->_sprite)._animState._animData;
|
|
if (animData != GHIDRA_CAST<byte *>(0x0)) {
|
|
currentAnimChar = animData;
|
|
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
|
|
currentAnimChar = *GHIDRA_CAST<byte **>(animData);
|
|
}
|
|
idleAnimChar = s_Idle;
|
|
do {
|
|
bVar1 = *currentAnimChar;
|
|
isLess = bVar1 < *idleAnimChar;
|
|
if (bVar1 != *idleAnimChar) {
|
|
LAB_0071f028:
|
|
uVar2 = -GHIDRA_UINT(isLess) | 1;
|
|
goto LAB_0071f02d;
|
|
}
|
|
if (bVar1 == 0) break;
|
|
bVar1 = currentAnimChar[1];
|
|
isLess = bVar1 < idleAnimChar[1];
|
|
if (bVar1 != idleAnimChar[1]) goto LAB_0071f028;
|
|
currentAnimChar = currentAnimChar + 2;
|
|
idleAnimChar = idleAnimChar + 2;
|
|
} while (bVar1 != 0);
|
|
uVar2 = 0;
|
|
LAB_0071f02d:
|
|
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0))))
|
|
goto LAB_0071f059;
|
|
}
|
|
bVar1 = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(s_Idle,1);
|
|
if (bVar1 != 0) {
|
|
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
|
|
(this->_sprite)._animState._isPlaying = 1;
|
|
}
|
|
LAB_0071f059:
|
|
self->_frameCnt = GHIDRA_UINT(((self->_desc)._state < 4)) * 4 + -1;
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 0071f090
|
|
void GridEntity_TNT::Update()
|
|
{
|
|
byte isBlownPlaying;
|
|
int collisionClass;
|
|
uint seed;
|
|
Vector *gridPos;
|
|
undefined4 extraout_ECX;
|
|
Vector posBuf;
|
|
int state;
|
|
|
|
collisionClass = 2;
|
|
state = (this->_desc)._state;
|
|
if (3 < state) {
|
|
collisionClass = 0;
|
|
}
|
|
this->_collisionClass = collisionClass;
|
|
switch(state) {
|
|
case 0:
|
|
case 1:
|
|
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(s_Idle,0);
|
|
return;
|
|
case 2:
|
|
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("IdleMedium"),0);
|
|
return;
|
|
case 3:
|
|
goto LAB_0071f222;
|
|
case 4:
|
|
isBlownPlaying = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::IsPlaying(GHIDRA_CAST<byte *>("Blown"));
|
|
if (isBlownPlaying == 0) {
|
|
this->_frameCnt = this->_frameCnt + -1;
|
|
if (this->_frameCnt < 1) {
|
|
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("Blown"),0);
|
|
if (this->_frameCnt != 0) {
|
|
return;
|
|
}
|
|
seed = Random();
|
|
gridPos = (GHIDRA_CAST<GridEntity *>((GHIDRA_CAST<GridEntity *>(this))))->GridEntity::Position(&posBuf);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::SpawnEx(1000,1,gridPos,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,seed,0);
|
|
gridPos = (GHIDRA_CAST<GridEntity *>((GHIDRA_CAST<GridEntity *>(this))))->GridEntity::Position(&posBuf);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::spawn_bomb_crater(gridPos,GHIDRA_CAST<Entity *>(0x0),1.0);
|
|
gridPos = (GHIDRA_CAST<GridEntity *>((GHIDRA_CAST<GridEntity *>(this))))->GridEntity::Position(&posBuf);
|
|
(GHIDRA_CAST<Game *>((g_game)))->Game::BombDamage(gridPos,100.0,75.0,0,GHIDRA_CAST<Entity *>(0x0),g_tearFlagsNone,0x1004,0);
|
|
(GHIDRA_CAST<GridEntity *>((GHIDRA_CAST<GridEntity *>(this))))->GridEntity::Position(&posBuf);
|
|
spawn_rock_particles();
|
|
(GHIDRA_CAST<GridEntity *>((GHIDRA_CAST<GridEntity *>(this))))->GridEntity::Position(&posBuf);
|
|
FUN_0071f4b0((this->_desc)._spawnSeed,extraout_ECX);
|
|
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
|
|
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 900;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
else if (this->_frameCnt < 1) {
|
|
return;
|
|
}
|
|
LAB_0071f222:
|
|
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("ReadyToExplode"),0);
|
|
return;
|
|
default:
|
|
return;
|
|
}
|
|
}
|