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

258 lines
9.7 KiB
C++

#include "classes.h"
// 00838c30
void GridEntity_Teleporter::Update()
{
byte bVar1;
int iVar2;
byte *curAnimChar;
uint uVar3;
Entity_Player *player;
Vector *destPos;
char *wantAnimChar;
int cellsScanned;
bool bVar4;
int in_stack_ffffffc8;
undefined1 auVar5 [12];
undefined1 in_stack_ffffffd0 [16];
undefined1 auVar6 [16];
undefined1 auVar7 [16];
undefined1 auVar8 [16];
undefined1 auVar9 [16];
Vector local_10;
GridEntity *otherTeleporter;
auVar5 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(in_stack_ffffffd0)) + 0x0)));
iVar2 = (this->_desc)._state;
if (iVar2 == 1) {
iVar2 = FUN_00839070();
if (iVar2 == 0) {
(this->_desc)._state = 0;
}
goto LAB_00838e61;
}
curAnimChar = (this->_sprite)._animState._animData;
if (iVar2 == 2) {
if ((curAnimChar != GHIDRA_CAST<byte *>(0x0)) && ((this->_sprite)._animState._isPlaying != 0)) {
if (0xf < *GHIDRA_CAST<uint *>((curAnimChar + 0x14))) {
curAnimChar = *GHIDRA_CAST<byte **>(curAnimChar);
}
wantAnimChar = "TurnOff";
do {
bVar1 = *curAnimChar;
bVar4 = bVar1 < (byte)*wantAnimChar;
if (bVar1 != *wantAnimChar) {
LAB_00838ca0:
uVar3 = -GHIDRA_UINT(bVar4) | 1;
goto LAB_00838ca5;
}
if (bVar1 == 0) break;
bVar1 = curAnimChar[1];
bVar4 = bVar1 < (byte)wantAnimChar[1];
if (bVar1 != wantAnimChar[1]) goto LAB_00838ca0;
curAnimChar = curAnimChar + 2;
wantAnimChar = wantAnimChar + 2;
} while (bVar1 != 0);
uVar3 = 0;
LAB_00838ca5:
if (uVar3 == 0) goto LAB_00838e61;
}
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("IdleOff"),0);
goto LAB_00838e61;
}
if ((curAnimChar == GHIDRA_CAST<byte *>(0x0)) || ((this->_sprite)._animState._isPlaying == 0)) {
LAB_00838d09:
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar6)) + 0x8))) = "IdleOn";
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(auVar6)) + 0x0))) = 0x838d1800000000;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar6)) + 0xc))) = 0;
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Play(GHIDRA_CAST<byte *>("IdleOn"),0);
auVar5 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(auVar6)) + 0x0)));
}
else {
if (0xf < *GHIDRA_CAST<uint *>((curAnimChar + 0x14))) {
curAnimChar = *GHIDRA_CAST<byte **>(curAnimChar);
}
wantAnimChar = "TurnOn";
do {
bVar1 = *curAnimChar;
bVar4 = bVar1 < (byte)*wantAnimChar;
if (bVar1 != *wantAnimChar) {
LAB_00838d00:
uVar3 = -GHIDRA_UINT(bVar4) | 1;
goto LAB_00838d05;
}
if (bVar1 == 0) break;
bVar1 = curAnimChar[1];
bVar4 = bVar1 < (byte)wantAnimChar[1];
if (bVar1 != wantAnimChar[1]) goto LAB_00838d00;
curAnimChar = curAnimChar + 2;
wantAnimChar = wantAnimChar + 2;
} while (bVar1 != 0);
uVar3 = 0;
LAB_00838d05:
if (uVar3 != 0) goto LAB_00838d09;
}
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar7)) + 0xc))) = 0x838d1f;
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(auVar7)) + 0x0))) = auVar5;
player = GHIDRA_CAST<Entity_Player *>(FUN_00839070());
if (player != GHIDRA_CAST<Entity_Player *>(0x0)) {
uVar3 = this->_gridIndex;
local_10.x = (float)g_game->_room;
cellsScanned = 0;
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_10.x) + 0x10)) * *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_10.x) + 0xc));
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(auVar8)) + 0x0))) = (*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(auVar7)) + 0x0)));
if (0 < iVar2 + -2) {
do {
uVar3 = GHIDRA_INT((uVar3 + 1)) % iVar2;
if ((((uVar3 < 0x1c0) &&
(otherTeleporter = *GHIDRA_CAST<GridEntity **>((GHIDRA_CAST<char *>(local_10.x) + uVar3 * 4 + 0x24)),
otherTeleporter != GHIDRA_CAST<GridEntity *>(0x0))) && ((otherTeleporter->_desc)._type == 0x17)) &&
((otherTeleporter->_desc)._variant == (this->_desc)._variant)) {
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar8)) + 0x8))) = 1;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar8)) + 0xc))) = 1;
(*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x8))) = (*GHIDRA_CAST<undefined8 *>((GHIDRA_CAST<char *>(&(auVar8)) + 0x8)));
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x4))) = &local_10;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(auVar9)) + 0x0))) = 0x838dba;
destPos = (GHIDRA_CAST<GridEntity *>((otherTeleporter)))->GridEntity::Position(&local_10);
Entity_Player::Teleport(player,destPos,auVar9[8],auVar9[0xc]);
destPos = (GHIDRA_CAST<GridEntity *>((otherTeleporter)))->GridEntity::Position(&local_10);
Game::DamageRadius(destPos,GHIDRA_CAST<Entity *>(player),4,0,in_stack_ffffffc8,50.0,g_tearFlagsNone,
40.0,30.0);
if ((otherTeleporter->_desc)._state == 0) {
(otherTeleporter->_desc)._state = 1;
}
goto LAB_00838e61;
}
cellsScanned = cellsScanned + 1;
} while (cellsScanned < iVar2 + -2);
}
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_10.x) + 8));
if ((iVar2 == 0x19) || (iVar2 == 0x1a)) {
iVar2 = (GHIDRA_CAST<Level *>((GHIDRA_CAST<Level *>(g_game))))->Level::QueryRoomTypeIndex((iVar2 == 0x19) + 0x19,0,&this->_rng,1);
if (-1 < iVar2) {
Game::StartRoomTransition(g_game,iVar2,-1,3,player,-1);
*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&((g_game->_roomTransition))) + 0x20)))) = (this->_desc)._variant + 1;
}
}
else {
(this->_desc)._state = 2;
}
}
LAB_00838e61:
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 999;
}
if ((this->_sprite)._loaded != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Update();
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._overlayAnimState)))->AnimationState::Update();
}
return;
}
// 00838eb0
void GridEntity_Teleporter::BeginBatches()
{
byte *pbVar1;
byte bVar2;
uint uVar3;
undefined **anm2Paths;
byte *cursor;
void *ptr;
char *idleOnCursor;
bool isLess;
std_string anm2Path;
uint local_14;
void *local_10;
undefined1 *puStack_c;
undefined4 local_8;
Game *game;
game = g_game;
local_8 = 0xffffffff;
puStack_c = &LAB_00af6ebd;
local_10 = ExceptionList;
local_14 = __security_cookie ^ GHIDRA_INT(&anm2Path) + 0x28U;
ExceptionList = &local_10;
if (g_game->_challenge == 0x2c) {
uVar3 = (GHIDRA_CAST<Level *>((GHIDRA_CAST<Level *>(g_game))))->Level::GetRoomStageType(g_game->_currentRoomIdx);
LAB_00838f10:
uVar3 = RoomConfig::GetStageID(game->_stage,uVar3,-1);
}
else {
if (g_game->_currentDimensionIdx != 2) {
uVar3 = g_game->_stageType;
goto LAB_00838f10;
}
uVar3 = 0x23;
}
anm2Paths = &PTR_s_gfx_grid_grid_teleporter_gehenna_00c5c470;
anm2Path._size = 0;
if (uVar3 != 0x20) {
anm2Paths = &PTR_s_gfx_grid_grid_teleporter_anm2_00c5c454;
}
anm2Path._capacity = 0xf;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = (void *)0x0;
pbVar1 = anm2Paths[(this->_desc)._variant];
cursor = pbVar1;
do {
bVar2 = *cursor;
cursor = cursor + 1;
} while (bVar2 != 0);
(GHIDRA_CAST<std::string *>((anm2Path._buf)))->std::string::assign(pbVar1,GHIDRA_INT(cursor) - GHIDRA_INT((pbVar1 + 1)));
local_8 = 0;
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Load(&anm2Path,1);
local_8 = 0xffffffff;
if (0xf < anm2Path._capacity) {
uVar3 = anm2Path._capacity + 1;
ptr = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&((void *)anm2Path._buf)) + 0x0)));
if (0xfff < uVar3) {
ptr = *(void **)((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4);
uVar3 = anm2Path._capacity + 0x24;
if (0x1f < GHIDRA_UINT(((*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,uVar3);
}
pbVar1 = (this->_sprite)._animState._animData;
anm2Path._size = 0;
anm2Path._capacity = 0xf;
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) & 0xffffff00;
if (pbVar1 != GHIDRA_CAST<byte *>(0x0)) {
cursor = pbVar1;
if (0xf < *GHIDRA_CAST<uint *>((pbVar1 + 0x14))) {
cursor = *GHIDRA_CAST<byte **>(pbVar1);
}
idleOnCursor = "IdleOn";
do {
bVar2 = *cursor;
isLess = bVar2 < (byte)*idleOnCursor;
if (bVar2 != *idleOnCursor) {
LAB_00839000:
uVar3 = -GHIDRA_UINT(isLess) | 1;
goto LAB_00839005;
}
if (bVar2 == 0) break;
bVar2 = cursor[1];
isLess = bVar2 < (byte)idleOnCursor[1];
if (bVar2 != idleOnCursor[1]) goto LAB_00839000;
cursor = cursor + 2;
idleOnCursor = idleOnCursor + 2;
} while (bVar2 != 0);
uVar3 = 0;
LAB_00839005:
if ((uVar3 == 0) && ((pbVar1[0x34] == 0 || ((this->_sprite)._animState._isPlaying != 0))))
goto LAB_00839038;
}
bVar2 = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("IdleOn"),1);
if (bVar2 != 0) {
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
(this->_sprite)._animState._isPlaying = 1;
}
LAB_00839038:
*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(g_game->_room) + 0x11f5)) = 0;
ExceptionList = local_10;
return;
}