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

794 lines
29 KiB
C++

#include "classes.h"
// 0071dfc0
void GridEntity_Spikes::BeginBatches()
{
int iVar1;
code *pcVar2;
byte isDisabled;
byte *curAnim;
std_string *psVar3;
Entity *bloodSplat;
byte extraout_CL;
byte extraout_CL_00;
byte extraout_CL_01;
byte *expectedAnim;
char *pcVar4;
uint uVar5;
bool bVar6;
float splatScaleY;
Vector local_34;
std_string local_2c;
uint local_14;
void *local_10;
undefined1 *puStack_c;
uint local_8;
void *animData;
Game *game;
int gridType;
ANM2 *sprite;
game = g_game;
local_8 = 0xffffffff;
puStack_c = &LAB_00afcc05;
local_10 = ExceptionList;
local_14 = __security_cookie ^ GHIDRA_UINT(&(&local_2c)[1]._size);
ExceptionList = &local_10;
this->_collisionClass = 0;
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(game->_room) + this->_gridIndex * 4 + 0x76c)) = 999;
}
sprite = &this->_sprite;
local_2c._size = 0;
local_2c._capacity = 0xf;
local_2c._buf[0] = '\0';
local_2c._buf[1] = '\0';
local_2c._buf[2] = '\0';
local_2c._buf[3] = '\0';
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) = std::_Allocate(0x20);
local_2c._size = 0x19;
local_2c._capacity = 0x1f;
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_2c._buf))) + 0x0))),"gfx/grid/grid_spikes.anm2",0x1a);
local_8 = 0;
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::Load(&local_2c,0);
local_8 = 0xffffffff;
isDisabled = extraout_CL;
if (0xf < local_2c._capacity) {
uVar5 = local_2c._capacity + 1;
pcVar4 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(local_2c._buf))) + 0x0)));
if (0xfff < uVar5) {
pcVar4 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) + -4));
uVar5 = local_2c._capacity + 0x24;
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar4))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(pcVar4,uVar5);
isDisabled = extraout_CL_00;
}
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(local_2c)) + 0xc))) = (*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(local_2c)) + 0xc))) & 0xffffffff;
local_2c._capacity = 0xf;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) & 0xffffff00;
local_34.y = 0.0;
if ((this->_sprite)._layerCount != 0) {
do {
Sprite::ReplaceSpritesheet
(GHIDRA_CAST<Sprite *>(sprite),GHIDRA_INT(local_34.y),
(std_string *)
(GHIDRA_INT(g_game->_room) + *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1d18)) * 0x13c + 0x1e3c));
local_34.y = (float)(GHIDRA_INT(local_34.y) + 1);
isDisabled = extraout_CL_01;
} while (GHIDRA_UINT(local_34.y) < GHIDRA_CAST<byte *>((this->_sprite)._layerCount));
}
(GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::LoadGraphics(isDisabled);
if (((this->_desc)._type == 8) && (GHIDRA_UINT((this->_desc)._variant) % 100 == 0)) {
uVar5 = (this->_desc)._spawnSeed;
local_2c._buf[0xc] = '\x05';
local_2c._buf[0xd] = '\0';
local_2c._buf[0xe] = '\0';
local_2c._buf[0xf] = '\0';
local_2c._size = 9;
local_34.y = (float)&DAT_00000007;
if (uVar5 == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
pcVar2 = (code *)swi(3);
(*pcVar2)();
return;
}
uVar5 = uVar5 >> 5 ^ uVar5;
uVar5 = uVar5 << 9 ^ uVar5;
uVar5 = uVar5 >> 7 ^ uVar5;
(this->_desc)._variant = (uVar5 & 3) + (this->_desc)._variant + 1;
if ((this->_desc)._initialized == 0) {
if (uVar5 == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
pcVar2 = (code *)swi(3);
(*pcVar2)();
return;
}
uVar5 = uVar5 >> 5 ^ uVar5;
uVar5 = uVar5 << 9 ^ uVar5;
(this->_desc)._variableSeed = uVar5 >> 7 ^ uVar5;
}
}
iVar1 = (this->_desc)._state;
(this->_rng)._seed = (this->_desc)._variableSeed;
(this->_rng)._shift1 = 5;
(this->_rng)._shift2 = 9;
(this->_rng)._shift3 = 7;
gridType = (this->_desc)._type;
this->_timeout = 0x1e;
(this->_desc)._state = 0;
if (gridType != 9) {
if (gridType == 0x1c) {
if (iVar1 == 1) {
curAnim = (this->_sprite)._animState._animData;
if (curAnim == GHIDRA_CAST<byte *>(0x0)) {
LAB_0071e528:
isDisabled = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("UnsummonPayment"),1);
if (isDisabled != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
}
else {
if (0xf < *GHIDRA_CAST<uint *>((curAnim + 0x14))) {
curAnim = *GHIDRA_CAST<byte **>(curAnim);
}
pcVar4 = "UnsummonPayment";
do {
isDisabled = *curAnim;
bVar6 = isDisabled < (byte)*pcVar4;
if (isDisabled != *pcVar4) {
LAB_0071e510:
uVar5 = -GHIDRA_UINT(bVar6) | 1;
goto LAB_0071e515;
}
if (isDisabled == 0) break;
isDisabled = curAnim[1];
bVar6 = isDisabled < (byte)pcVar4[1];
if (isDisabled != pcVar4[1]) goto LAB_0071e510;
curAnim = curAnim + 2;
pcVar4 = pcVar4 + 2;
} while (isDisabled != 0);
uVar5 = 0;
LAB_0071e515:
if ((uVar5 != 0) ||
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' &&
((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0071e528;
}
animData = (this->_sprite)._animState._animData;
if (animData == (void *)0x0) {
local_2c._capacity = 0xf;
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(local_2c)) + 0xc))) = (*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(local_2c)) + 0xc))) & 0xffffffff;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) = GHIDRA_CAST<std_string *>(0x0);
}
else {
(GHIDRA_CAST<std::string *>((local_2c._buf)))->std::string::string(animData);
}
local_8 = 1;
psVar3 = &local_2c;
if (0xf < local_2c._capacity) {
psVar3 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(local_2c._buf))) + 0x0)));
}
isDisabled = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(psVar3),1);
if ((isDisabled != 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;
}
}
local_8 = 0xffffffff;
if (0xf < local_2c._capacity) {
uVar5 = local_2c._capacity + 1;
psVar3 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<std_string *>(local_2c._buf))) + 0x0)));
if (0xfff < uVar5) {
psVar3 = GHIDRA_CAST<std_string *>((GHIDRA_CAST<std_string *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) + -0x18)))->_capacity);
uVar5 = local_2c._capacity + 0x24;
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) + (-4 - GHIDRA_INT(psVar3))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(psVar3,uVar5);
}
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(local_2c)) + 0xc))) = (*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(local_2c)) + 0xc))) & 0xffffffff;
local_2c._capacity = 0xf;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_2c._buf)) + 0x0))) & 0xffffff00;
if ((this->_sprite)._animState._animData != (void *)0x0) {
AnimationState::AdvancePosition
(&(this->_sprite)._animState,
*GHIDRA_CAST<int *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1);
}
(this->_desc)._state = 1;
goto LAB_0071e7e6;
}
if ((*GHIDRA_CAST<char *>(g_game->_room) == '\0') ||
(g_game->_frameCount - *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x11f0)) < 1)) {
curAnim = (this->_sprite)._animState._animData;
if (curAnim != GHIDRA_CAST<byte *>(0x0)) {
if (0xf < *GHIDRA_CAST<uint *>((curAnim + 0x14))) {
curAnim = *GHIDRA_CAST<byte **>(curAnim);
}
pcVar4 = "PaymentSpike";
do {
isDisabled = *curAnim;
bVar6 = isDisabled < (byte)*pcVar4;
if (isDisabled != *pcVar4) {
LAB_0071e6e2:
uVar5 = -GHIDRA_UINT(bVar6) | 1;
goto LAB_0071e6e7;
}
if (isDisabled == 0) break;
isDisabled = curAnim[1];
bVar6 = isDisabled < (byte)pcVar4[1];
if (isDisabled != pcVar4[1]) goto LAB_0071e6e2;
curAnim = curAnim + 2;
pcVar4 = pcVar4 + 2;
} while (isDisabled != 0);
uVar5 = 0;
LAB_0071e6e7:
if ((uVar5 == 0) &&
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' ||
((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6;
}
pcVar4 = "PaymentSpike";
}
else {
curAnim = (this->_sprite)._animState._animData;
if (curAnim != GHIDRA_CAST<byte *>(0x0)) {
if (0xf < *GHIDRA_CAST<uint *>((curAnim + 0x14))) {
curAnim = *GHIDRA_CAST<byte **>(curAnim);
}
pcVar4 = "SummonPayment";
do {
isDisabled = *curAnim;
bVar6 = isDisabled < (byte)*pcVar4;
if (isDisabled != *pcVar4) {
LAB_0071e680:
uVar5 = -GHIDRA_UINT(bVar6) | 1;
goto LAB_0071e685;
}
if (isDisabled == 0) break;
isDisabled = curAnim[1];
bVar6 = isDisabled < (byte)pcVar4[1];
if (isDisabled != pcVar4[1]) goto LAB_0071e680;
curAnim = curAnim + 2;
pcVar4 = pcVar4 + 2;
} while (isDisabled != 0);
uVar5 = 0;
LAB_0071e685:
if ((uVar5 == 0) &&
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' ||
((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6;
}
pcVar4 = "SummonPayment";
}
}
else {
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1d18));
if (((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) ||
((iVar1 == 0xd || (iVar1 == 0x22)))) ||
((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))) {
bVar6 = true;
}
else {
bVar6 = false;
}
pcVar4 = "Spikes%02u";
if (bVar6) {
pcVar4 = "WombSpikes%02u";
}
sprintf_s(&DAT_00c80fa8,0x20,GHIDRA_CAST<byte *>(pcVar4));
curAnim = (this->_sprite)._animState._animData;
if (curAnim != GHIDRA_CAST<byte *>(0x0)) {
if (0xf < *GHIDRA_CAST<uint *>((curAnim + 0x14))) {
curAnim = *GHIDRA_CAST<byte **>(curAnim);
}
expectedAnim = &DAT_00c80fa8;
do {
isDisabled = *curAnim;
bVar6 = isDisabled < *expectedAnim;
if (isDisabled != *expectedAnim) {
LAB_0071e7b0:
uVar5 = -GHIDRA_UINT(bVar6) | 1;
goto LAB_0071e7b5;
}
if (isDisabled == 0) break;
isDisabled = curAnim[1];
bVar6 = isDisabled < expectedAnim[1];
if (isDisabled != expectedAnim[1]) goto LAB_0071e7b0;
curAnim = curAnim + 2;
expectedAnim = expectedAnim + 2;
} while (isDisabled != 0);
uVar5 = 0;
LAB_0071e7b5:
if ((uVar5 == 0) &&
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' ||
((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6;
}
pcVar4 = &DAT_00c80fa8;
}
isDisabled = (GHIDRA_CAST<ANM2 *>((sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(pcVar4),1);
if (isDisabled != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
goto LAB_0071e7e6;
}
uVar5 = (this->_desc)._variant;
if (uVar5 == 0) {
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1d18));
if ((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) ||
(((iVar1 == 0xd || (iVar1 == 0x22)) ||
((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))))) {
bVar6 = true;
}
else {
bVar6 = false;
}
local_34.y = 1.6766631e-38;
if (!bVar6) {
local_34.y = (float)&DAT_00b69280;
}
curAnim = (this->_sprite)._animState._animData;
if (curAnim != GHIDRA_CAST<byte *>(0x0)) {
if (0xf < *GHIDRA_CAST<uint *>((curAnim + 0x14))) {
curAnim = *GHIDRA_CAST<byte **>(curAnim);
}
expectedAnim = GHIDRA_CAST<byte *>(local_34.y);
do {
isDisabled = *curAnim;
bVar6 = isDisabled < *expectedAnim;
if (isDisabled != *expectedAnim) {
LAB_0071e477:
uVar5 = -GHIDRA_UINT(bVar6) | 1;
goto LAB_0071e47c;
}
if (isDisabled == 0) break;
isDisabled = curAnim[1];
bVar6 = isDisabled < expectedAnim[1];
if (isDisabled != expectedAnim[1]) goto LAB_0071e477;
curAnim = curAnim + 2;
expectedAnim = expectedAnim + 2;
} while (isDisabled != 0);
uVar5 = 0;
LAB_0071e47c:
if ((uVar5 == 0) &&
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) == '\0' ||
((this->_sprite)._animState._isPlaying != 0)))) goto LAB_0071e7e6;
}
isDisabled = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(local_34.y),1);
if (isDisabled != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
goto LAB_0071e7e6;
}
if (5 < uVar5) {
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1d18));
if ((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) ||
(((iVar1 == 0xd || (iVar1 == 0x22)) ||
((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))))) {
bVar6 = true;
}
else {
bVar6 = false;
}
local_34.y = 1.6766631e-38;
if (!bVar6) {
local_34.y = (float)&DAT_00b69280;
}
curAnim = (this->_sprite)._animState._animData;
if (curAnim == GHIDRA_CAST<byte *>(0x0)) {
LAB_0071e3bb:
isDisabled = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(local_34.y),1);
if (isDisabled != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
}
else {
if (0xf < *GHIDRA_CAST<uint *>((curAnim + 0x14))) {
curAnim = *GHIDRA_CAST<byte **>(curAnim);
}
expectedAnim = GHIDRA_CAST<byte *>(local_34.y);
do {
isDisabled = *curAnim;
bVar6 = isDisabled < *expectedAnim;
if (isDisabled != *expectedAnim) {
LAB_0071e3a0:
uVar5 = -GHIDRA_UINT(bVar6) | 1;
goto LAB_0071e3a5;
}
if (isDisabled == 0) break;
isDisabled = curAnim[1];
bVar6 = isDisabled < expectedAnim[1];
if (isDisabled != expectedAnim[1]) goto LAB_0071e3a0;
curAnim = curAnim + 2;
expectedAnim = expectedAnim + 2;
} while (isDisabled != 0);
uVar5 = 0;
LAB_0071e3a5:
if ((uVar5 != 0) ||
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' &&
((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0071e3bb;
}
this->_timeout = ((this->_desc)._variant + -5) * 0xc;
goto LAB_0071e7e6;
}
(this->_desc)._state = 1;
this->_timeout = uVar5 * 0xc;
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0x1d18));
if (((((iVar1 == 10) || (iVar1 == 0xb)) || (iVar1 == 0xc)) || ((iVar1 == 0xd || (iVar1 == 0x22))))
|| ((iVar1 == 0x2b || ((iVar1 == 0x2c || (iVar1 == 0x30)))))) {
bVar6 = true;
}
else {
bVar6 = false;
}
local_34.y = 1.6734441e-38;
if (!bVar6) {
local_34.y = 1.6766497e-38;
}
curAnim = (this->_sprite)._animState._animData;
if (curAnim == GHIDRA_CAST<byte *>(0x0)) {
LAB_0071e2db:
isDisabled = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(local_34.y),1);
if (isDisabled != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
}
else {
if (0xf < *GHIDRA_CAST<uint *>((curAnim + 0x14))) {
curAnim = *GHIDRA_CAST<byte **>(curAnim);
}
expectedAnim = GHIDRA_CAST<byte *>(local_34.y);
do {
isDisabled = *curAnim;
bVar6 = isDisabled < *expectedAnim;
if (isDisabled != *expectedAnim) {
LAB_0071e2c0:
uVar5 = -GHIDRA_UINT(bVar6) | 1;
goto LAB_0071e2c5;
}
if (isDisabled == 0) break;
isDisabled = curAnim[1];
bVar6 = isDisabled < expectedAnim[1];
if (isDisabled != expectedAnim[1]) goto LAB_0071e2c0;
curAnim = curAnim + 2;
expectedAnim = expectedAnim + 2;
} while (isDisabled != 0);
uVar5 = 0;
LAB_0071e2c5:
if ((uVar5 != 0) ||
((*GHIDRA_CAST<char *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x34)) != '\0' &&
((this->_sprite)._animState._isPlaying == 0)))) goto LAB_0071e2db;
}
if ((this->_sprite)._animState._animData != (void *)0x0) {
AnimationState::AdvancePosition
(&(this->_sprite)._animState,
*GHIDRA_CAST<int *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1);
}
LAB_0071e7e6:
isDisabled = is_disabled(this);
if (isDisabled != 0) {
unsummon(this,1);
}
if (((this->_desc)._type == 8) && (99 < GHIDRA_UINT((this->_desc)._variant))) {
uVar5 = (this->_desc)._spawnSeed;
local_2c._buf[0xc] = '\x02';
local_2c._buf[0xd] = '\0';
local_2c._buf[0xe] = '\0';
local_2c._buf[0xf] = '\0';
local_2c._size = 7;
if (uVar5 == 0) {
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
pcVar2 = (code *)swi(3);
(*pcVar2)();
return;
}
uVar5 = uVar5 >> 2 ^ uVar5;
uVar5 = uVar5 << 7 ^ uVar5;
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
local_34.x = (float)(this->_gridIndex % iVar1) * 40.0 + 40.0;
local_34.y = (float)(this->_gridIndex / iVar1) * 40.0 + 120.0;
bloodSplat = (GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(1000,7,&local_34,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,
uVar5 >> 9 ^ uVar5);
splatScaleY = g_vectorOne.y * 1.8;
iVar1 = *GHIDRA_CAST<int *>(bloodSplat);
(bloodSplat->_sprite)._scale.x = g_vectorOne.x * 1.8;
(bloodSplat->_sprite)._scale.y = splatScaleY;
(**(code **)(iVar1 + 0xc))();
}
ExceptionList = local_10;
return;
}
// 0071e920
byte GridEntity_Spikes::is_disabled()
{
byte isFlatFileHeld;
RoomDescriptor *roomDesc;
Entity_Player *sanguineBondOwner;
if (1 < *GHIDRA_CAST<int *>(&g_game->_deathmatchManager)) {
return 0;
}
if ((this->_desc)._type == 0x1c) {
return 0;
}
roomDesc = (GHIDRA_CAST<Level *>((GHIDRA_CAST<Level *>(g_game))))->Level::GetRoomByIdx(g_game->_currentRoomIdx,
g_game->_currentDimensionIdx);
if (((GHIDRA_UINT(roomDesc->Flags) >> 1 & 1) != 0) ||
(isFlatFileHeld = (GHIDRA_CAST<PlayerManager *>((&g_game->_playerManager)))->PlayerManager::AnyoneHasTrinket(0x97),
isFlatFileHeld != 0)) {
return 1;
}
if ((GHIDRA_UINT((this->_desc)._variant) < 100) &&
((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 8)) == 0xe &&
(sanguineBondOwner =
PlayerManager::FirstCollectibleOwner
(&g_game->_playerManager,0x2b4,GHIDRA_CAST<RNG **>(&g_game->_playerManager),1),
sanguineBondOwner != GHIDRA_CAST<Entity_Player *>(0x0))))) {
return 1;
}
return 0;
}
// 0071e9b0
void GridEntity_Spikes::Update()
{
byte isCheck;
char isCheck;
int iVar2;
char *anim;
uint damageFlags;
ANM2 *this_00;
int extraout_EDX;
char *summonAnim;
if ((this->_desc)._state != 0) {
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 500;
}
goto LAB_0071ea6f;
}
damageFlags = 0x80;
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 8));
if ((((iVar2 == 0xd) || (99 < GHIDRA_UINT((this->_desc)._variant))) || ((this->_desc)._type == 0x1c)) &&
(damageFlags = 0x10000080, iVar2 == 0xd)) {
LAB_0071ea00:
isCheck = 1;
}
else {
iVar2 = (this->_desc)._type;
if (iVar2 != 8) {
if (iVar2 != 0x1c) goto LAB_0071ea4a;
goto LAB_0071ea00;
}
if (99 < GHIDRA_UINT((this->_desc)._variant)) goto LAB_0071ea00;
LAB_0071ea4a:
isCheck = 0;
}
GridEntity::hurt_surroundings(GHIDRA_CAST<GridEntity *>(this),11.0,11.0,8.0,2,(ulonglong)damageFlags,isCheck);
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 999;
}
LAB_0071ea6f:
isCheck = is_disabled(this);
if (isCheck == 0) {
if (((this->_desc)._type == 9) && (0 < this->_timeout)) {
iVar2 = this->_timeout + -1;
this->_timeout = iVar2;
if (iVar2 < 1) {
this->_timeout = 0x3c;
(this->_desc)._state = GHIDRA_UINT(((this->_desc)._state == 0));
}
else if (iVar2 == 5) {
isCheck = FUN_0071df80();
if (isCheck == '\0') {
anim = "Unsummon";
summonAnim = "Summon";
}
else {
anim = "UnsummonWomb";
summonAnim = "SummonWomb";
}
if (extraout_EDX != 0) {
anim = summonAnim;
}
(GHIDRA_CAST<ANM2 *>((this_00)))->ANM2::Play(GHIDRA_CAST<byte *>(anim),0);
}
}
}
else if (((this->_desc)._state == 0) ||
(((this->_sprite)._animState._animData != (void *)0x0 &&
((this->_sprite)._animState._isPlaying != 0)))) {
unsummon(this,0);
}
if ((this->_sprite)._loaded != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Update();
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._overlayAnimState)))->AnimationState::Update();
}
return;
}
// 0071eb30
void GridEntity_Spikes::unsummon(byte isInstant)
{
void *other;
char isWomb;
byte bVar1;
byte *curAnimChar;
uint uVar2;
byte *****curAnimNameData;
char *animName;
bool isLess;
byte *****curAnimName [4];
undefined4 curAnimNameSize;
uint curAnimNameCapacity;
uint securityCookie;
void *local_10;
undefined1 *puStack_c;
byte ****local_8;
byte *animData;
int gridType;
local_8 = GHIDRA_CAST<byte ****>(0xffffffff);
puStack_c = &LAB_00af18ad;
local_10 = ExceptionList;
securityCookie = __security_cookie ^ GHIDRA_UINT((curAnimName + 0xb));
ExceptionList = &local_10;
gridType = (this->_desc)._type;
(this->_desc)._state = 1;
this->_timeout = -1;
if (gridType == 0x1c) {
animData = (this->_sprite)._animState._animData;
if (animData != GHIDRA_CAST<byte *>(0x0)) {
curAnimChar = animData;
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
curAnimChar = *GHIDRA_CAST<byte **>(animData);
}
animName = "UnsummonPayment";
do {
bVar1 = *curAnimChar;
isLess = bVar1 < (byte)*animName;
if (bVar1 != *animName) {
LAB_0071ebb0:
uVar2 = -GHIDRA_UINT(isLess) | 1;
goto LAB_0071ebb5;
}
if (bVar1 == 0) break;
bVar1 = curAnimChar[1];
isLess = bVar1 < (byte)animName[1];
if (bVar1 != animName[1]) goto LAB_0071ebb0;
curAnimChar = curAnimChar + 2;
animName = animName + 2;
} while (bVar1 != 0);
uVar2 = 0;
LAB_0071ebb5:
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0))))
goto LAB_0071ecaa;
}
animName = "UnsummonPayment";
}
else {
isWomb = FUN_0071df80(securityCookie);
animData = (this->_sprite)._animState._animData;
if (isWomb == '\0') {
if (animData != GHIDRA_CAST<byte *>(0x0)) {
curAnimChar = animData;
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
curAnimChar = *GHIDRA_CAST<byte **>(animData);
}
animName = "Unsummon";
do {
bVar1 = *curAnimChar;
isLess = bVar1 < (byte)*animName;
if (bVar1 != *animName) {
LAB_0071ec72:
uVar2 = -GHIDRA_UINT(isLess) | 1;
goto LAB_0071ec77;
}
if (bVar1 == 0) break;
bVar1 = curAnimChar[1];
isLess = bVar1 < (byte)animName[1];
if (bVar1 != animName[1]) goto LAB_0071ec72;
curAnimChar = curAnimChar + 2;
animName = animName + 2;
} while (bVar1 != 0);
uVar2 = 0;
LAB_0071ec77:
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0))))
goto LAB_0071ecaa;
}
animName = "Unsummon";
}
else {
if (animData != GHIDRA_CAST<byte *>(0x0)) {
curAnimChar = animData;
if (0xf < *GHIDRA_CAST<uint *>((animData + 0x14))) {
curAnimChar = *GHIDRA_CAST<byte **>(animData);
}
animName = "UnsummonWomb";
do {
bVar1 = *curAnimChar;
isLess = bVar1 < (byte)*animName;
if (bVar1 != *animName) {
LAB_0071ec20:
uVar2 = -GHIDRA_UINT(isLess) | 1;
goto LAB_0071ec25;
}
if (bVar1 == 0) break;
bVar1 = curAnimChar[1];
isLess = bVar1 < (byte)animName[1];
if (bVar1 != animName[1]) goto LAB_0071ec20;
curAnimChar = curAnimChar + 2;
animName = animName + 2;
} while (bVar1 != 0);
uVar2 = 0;
LAB_0071ec25:
if ((uVar2 == 0) && ((animData[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0))))
goto LAB_0071ecaa;
}
animName = "UnsummonWomb";
}
}
bVar1 = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(animName),1);
if (bVar1 != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
LAB_0071ecaa:
if (isInstant != 0) {
other = (this->_sprite)._animState._animData;
if (other == (void *)0x0) {
curAnimNameCapacity = 0xf;
curAnimNameSize = 0;
curAnimName[0] = GHIDRA_CAST<byte *****>(0x0);
}
else {
(GHIDRA_CAST<std::string *>((GHIDRA_CAST<char *>(curAnimName))))->std::string::string(other);
}
local_8 = GHIDRA_CAST<byte ****>(0x0);
curAnimNameData = GHIDRA_CAST<byte *****>(curAnimName);
if (0xf < curAnimNameCapacity) {
curAnimNameData = curAnimName[0];
}
bVar1 = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(curAnimNameData),1);
if ((bVar1 != 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;
}
}
local_8 = GHIDRA_CAST<byte ****>(0xffffffff);
if (0xf < curAnimNameCapacity) {
uVar2 = curAnimNameCapacity + 1;
curAnimNameData = curAnimName[0];
if (0xfff < uVar2) {
curAnimNameData = GHIDRA_CAST<byte *****>(curAnimName[0][-1]);
uVar2 = curAnimNameCapacity + 0x24;
if (GHIDRA_CAST<byte *>(0x1f) < GHIDRA_CAST<byte *>((GHIDRA_INT(curAnimName[0]) + (-4 - GHIDRA_INT(curAnimNameData))))) {
/* WARNING: Subroutine does not return */
_invalid_parameter_noinfo_noreturn();
}
}
operator_delete(curAnimNameData,uVar2);
}
curAnimNameSize = 0;
curAnimNameCapacity = 0xf;
curAnimName[0] = GHIDRA_CAST<byte *****>((GHIDRA_UINT(curAnimName[0]) & 0xffffff00));
if ((this->_sprite)._animState._animData != (void *)0x0) {
AnimationState::AdvancePosition
(&(this->_sprite)._animState,
*GHIDRA_CAST<int *>((GHIDRA_INT((this->_sprite)._animState._animData) + 0x30)) + -1);
}
}
ExceptionList = local_10;
return;
}