--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
231 lines
10 KiB
C++
231 lines
10 KiB
C++
#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;
|
|
uint8_t isAnimSet;
|
|
int belowRow;
|
|
char *freeBlock;
|
|
int column;
|
|
uint32_t uVar4;
|
|
ANM2 *floorSprite;
|
|
RNG rng;
|
|
uint32_t local_6c;
|
|
ANM2 *sprite;
|
|
std_string itemDungeonPath;
|
|
std_string tilesPath;
|
|
uint8_t floorAnimName [32];
|
|
uint32_t local_14;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t 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 = *GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((this)) + 0x14))));
|
|
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<uint32_t *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) = msvc::_Allocate(0x20);
|
|
tilesPath._size = 0x1a;
|
|
tilesPath._capacity = 0x1f;
|
|
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(tilesPath._buf))) + 0x0)));
|
|
if (0xfff < uVar4) {
|
|
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) + -4));
|
|
uVar4 = tilesPath._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((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<uint8_t *>("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<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) = msvc::_Allocate(0x30);
|
|
floorSprite = sprite;
|
|
tilesPath._size = 0x26;
|
|
tilesPath._capacity = 0x2f;
|
|
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(tilesPath._buf))) + 0x0)));
|
|
if (0xfff < uVar4) {
|
|
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) + -4));
|
|
uVar4 = tilesPath._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(tilesPath._buf)) + 0x0))) = (*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) = msvc::_Allocate(0x20);
|
|
floorSprite = sprite;
|
|
itemDungeonPath._size = 0x1f;
|
|
itemDungeonPath._capacity = 0x1f;
|
|
builtin_strncpy((*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(itemDungeonPath._buf))) + 0x0)));
|
|
if (0xfff < uVar4) {
|
|
freeBlock = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) + -4));
|
|
uVar4 = itemDungeonPath._capacity + 0x24;
|
|
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) = (*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(itemDungeonPath._buf)) + 0x0))) & 0xffffff00;
|
|
}
|
|
if (iVar2 == 0) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("RNG Seed is zero!\n"));
|
|
pcVar3 = (code *)swi(3);
|
|
(*pcVar3)();
|
|
return;
|
|
}
|
|
sprintf_s(floorAnimName,0x1f,GHIDRA_CAST<uint8_t *>("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;
|
|
uint32_t 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<uint8_t *>("(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<uint32_t *>((player + 0x168)) = *GHIDRA_CAST<uint32_t *>((player + 0x168)) | 0x8000;
|
|
*GHIDRA_CAST<uint32_t *>((player + 0x16c)) = *GHIDRA_CAST<uint32_t *>((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;
|
|
}
|