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

226 lines
9.4 KiB
C++

#include "classes.h"
// 00721540
void GridEntity_Web::BeginBatches()
{
byte bVar1;
byte *curAnimName;
uint startFrame;
void *animData;
char *pcVar2;
uint startFrame;
bool bVar4;
std_string anmPath;
uint local_14;
void *local_10;
undefined1 *puStack_c;
uint local_8;
local_8 = 0xffffffff;
puStack_c = &LAB_00afc99d;
local_10 = ExceptionList;
local_14 = __security_cookie ^ GHIDRA_UINT(&(&anmPath)[1]._size);
ExceptionList = &local_10;
this->_collisionClass = 0;
anmPath._size = 0;
anmPath._capacity = 0xf;
anmPath._buf[0] = '\0';
anmPath._buf[1] = '\0';
anmPath._buf[2] = '\0';
anmPath._buf[3] = '\0';
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) = std::_Allocate(0x20);
anmPath._size = 0x16;
anmPath._capacity = 0x1f;
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anmPath._buf))) + 0x0))),"gfx/grid/grid_web.anm2",0x17);
local_8 = 0;
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Load(&anmPath,1);
local_8 = 0xffffffff;
if (0xf < anmPath._capacity) {
startFrame = anmPath._capacity + 1;
pcVar2 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anmPath._buf))) + 0x0)));
if (0xfff < startFrame) {
pcVar2 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) + -4));
startFrame = anmPath._capacity + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar2))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(pcVar2,startFrame);
}
anmPath._size = 0;
anmPath._capacity = 0xf;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anmPath._buf)) + 0x0))) & 0xffffff00;
if ((this->_desc)._state != 0) {
bVar1 = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Bombed"),1);
if (bVar1 == 0) {
ExceptionList = local_10;
return;
}
if ((this->_sprite)._animState._animData == (void *)0x0) {
ExceptionList = local_10;
return;
}
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::SetFrameFloat(0.0);
if ((this->_sprite)._animState._animData == (void *)0x0) {
ExceptionList = local_10;
return;
}
(this->_sprite)._animState._isPlaying = 0;
ExceptionList = local_10;
return;
}
curAnimName = (this->_sprite)._animState._animData;
if (curAnimName != GHIDRA_CAST<byte *>(0x0)) {
if (0xf < *GHIDRA_CAST<uint *>((curAnimName + 0x14))) {
curAnimName = *GHIDRA_CAST<byte **>(curAnimName);
}
pcVar2 = "Swaying";
do {
bVar1 = *curAnimName;
bVar4 = bVar1 < (byte)*pcVar2;
if (bVar1 != *pcVar2) {
LAB_00721670:
startFrame = -GHIDRA_UINT(bVar4) | 1;
goto LAB_00721675;
}
if (bVar1 == 0) break;
bVar1 = curAnimName[1];
bVar4 = bVar1 < (byte)pcVar2[1];
if (bVar1 != pcVar2[1]) goto LAB_00721670;
curAnimName = curAnimName + 2;
pcVar2 = pcVar2 + 2;
} while (bVar1 != 0);
startFrame = 0;
LAB_00721675:
if ((startFrame == 0) &&
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' ||
((this->_sprite)._animState._isPlaying != 0)))) goto LAB_007216ad;
}
bVar1 = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Swaying"),1);
if (bVar1 != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
LAB_007216ad:
animData = (this->_sprite)._animState._animData;
if ((animData == (void *)0x0) || (startFrame = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(animData) + 0x30)), startFrame == 0)) {
startFrame = 0;
}
else {
startFrame = Random();
startFrame = startFrame % startFrame;
animData = (this->_sprite)._animState._animData;
}
if ((animData != (void *)0x0) &&
((GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::SetFrameFloat((float)GHIDRA_INT(startFrame)),
(this->_sprite)._animState._animData != (void *)0x0)) {
(this->_sprite)._animState._isPlaying = 0;
}
startFrame = Random();
(this->_sprite)._flipX = ~(byte)startFrame & 1;
startFrame = Random();
(this->_sprite)._rotation = ((float)(startFrame & 3) + 0.0) * 90.0;
ExceptionList = local_10;
return;
}
// 00721780
void GridEntity_Web::Update()
{
int iVar1;
ColorMod color;
undefined1 auVar2 [32];
byte isHasEvilCharm;
uint uVar3;
float *maxAxisDistance;
undefined4 *puVar4;
PlayerManager *playerManager;
bool isEveryFourthFrame;
float distanceY;
float distanceX;
EntityRef sourceRef;
Entity_Player *player;
void *playersEnd;
if ((this->_desc)._state == 0) {
uVar3 = g_game->_frameCount & 0x80000003;
isEveryFourthFrame = uVar3 == 0;
if (GHIDRA_INT(uVar3) < 0) {
isEveryFourthFrame = (uVar3 - 1 | 0xfffffffc) == 0xffffffff;
}
if (isEveryFourthFrame) {
playerManager = &g_game->_playerManager;
uVar3 = 0;
if (GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT((playerManager->_playerList)._begin)
>> 2 != 0) {
do {
playersEnd = (playerManager->_playerList)._end;
puVar4 = (playerManager->_playerList)._begin;
if (GHIDRA_INT(playersEnd) - GHIDRA_INT(puVar4) >> 2 == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("(GHIDRA_CAST<PlayerManager *>(()))->PlayerManager::GetPlayer() : There are no players! \n"));
playersEnd = (playerManager->_playerList)._end;
puVar4 = (playerManager->_playerList)._begin;
}
if (uVar3 < GHIDRA_UINT((GHIDRA_INT(playersEnd) - GHIDRA_INT(puVar4) >> 2))) {
puVar4 = puVar4 + uVar3;
}
player = GHIDRA_CAST<Entity_Player *>(*puVar4);
iVar1 = player->_entityGridCollisionClass;
if ((((iVar1 != 0) && (iVar1 != 3)) && (iVar1 != 1)) && (iVar1 != 2)) {
isHasEvilCharm = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::HasCollectible(0x278,0);
if ((isHasEvilCharm != 0) ||
(isHasEvilCharm =
(GHIDRA_CAST<TemporaryEffects *>((&player->_temporaryeffects)))->TemporaryEffects::HasCollectibleEffect(0x278),
isHasEvilCharm != 0)) {
if ((this->_desc)._type == 10) goto LAB_007219cb;
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((player)) + 0x26d4))) = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((player)) + 0x26d4))) != '\0';
}
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
distanceY = ABS((player->_pos).y - ((float)(this->_gridIndex / iVar1) * 40.0 + 120.0));
distanceX = ABS((player->_pos).x - ((float)(this->_gridIndex % iVar1) * 40.0 + 40.0));
maxAxisDistance = &distanceY;
if (distanceY <= distanceX) {
maxAxisDistance = &distanceX;
}
if (*maxAxisDistance <= 21.0 && *maxAxisDistance != 21.0) {
sourceRef._type = 0;
sourceRef._variant = 0;
sourceRef._spawnerType = 0;
sourceRef._spawnerVariant = 0;
sourceRef._position.x = g_vectorZero.x;
sourceRef._position.y = g_vectorZero.y;
sourceRef._velocity.x = g_vectorZero.x;
sourceRef._velocity.y = g_vectorZero.y;
sourceRef._flags = 0;
sourceRef._entity = (void *)0x0;
auVar2 = ZEXT1632(CONCAT412(0x3f800000,CONCAT48(0x3fa66666,0x3f8000003f800000)));
color._offset[0] = 0.15686275;
color._tint[0] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0x0)));
color._tint[1] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0x4)));
color._tint[2] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0x8)));
color._tint[3] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0xc)));
color._colorize[0] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0x10)));
color._colorize[1] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0x14)));
color._colorize[2] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0x18)));
color._colorize[3] = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((float)auVar2)) + 0x1c)));
color._offset[1] = 0.15686275;
color._offset[2] = 0.15686275;
(GHIDRA_CAST<Entity *>((GHIDRA_CAST<Entity *>(player))))->Entity::AddSlowing(&sourceRef,4,0.75,color,0);
}
}
LAB_007219cb:
uVar3 = uVar3 + 1;
playerManager = &g_game->_playerManager;
} while (uVar3 < 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;
}