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>
This commit is contained in:
1 parent
2ff2d5d87f
commit
3ce74c6e2d
331 files changed
+485
-7835
No files matched your search
@@ -0,0 +1,340 @@
|
||||
#include "classes.h"
|
||||
|
||||
// 00711780
|
||||
void GridEntity_Lock::BeginBatches()
|
||||
{
|
||||
byte isAnimSet;
|
||||
Entity_Player *payToPlayOwner;
|
||||
char *pcVar1;
|
||||
uint size;
|
||||
std_string anm2Path;
|
||||
uint local_14;
|
||||
void *local_10;
|
||||
undefined1 *puStack_c;
|
||||
uint local_8;
|
||||
int state;
|
||||
|
||||
local_8 = 0xffffffff;
|
||||
puStack_c = &LAB_00afc99d;
|
||||
local_10 = ExceptionList;
|
||||
local_14 = __security_cookie ^ GHIDRA_UINT(&(&anm2Path)[1]._size);
|
||||
ExceptionList = &local_10;
|
||||
anm2Path._size = 0;
|
||||
anm2Path._capacity = 0xf;
|
||||
anm2Path._buf[0] = '\0';
|
||||
anm2Path._buf[1] = '\0';
|
||||
anm2Path._buf[2] = '\0';
|
||||
anm2Path._buf[3] = '\0';
|
||||
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) = std::_Allocate(0x20);
|
||||
anm2Path._size = 0x18;
|
||||
anm2Path._capacity = 0x1f;
|
||||
builtin_strncpy((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0))),"gfx/grid/grid_locks.anm2",0x19);
|
||||
local_8 = 0;
|
||||
(GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::Load(&anm2Path,1);
|
||||
local_8 = 0xffffffff;
|
||||
if (0xf < anm2Path._capacity) {
|
||||
size = anm2Path._capacity + 1;
|
||||
pcVar1 = (*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(GHIDRA_CAST<char *>(anm2Path._buf))) + 0x0)));
|
||||
if (0xfff < size) {
|
||||
pcVar1 = *GHIDRA_CAST<char **>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + -4));
|
||||
size = anm2Path._capacity + 0x24;
|
||||
if (GHIDRA_CAST<char *>(0x1f) < GHIDRA_CAST<char *>(((*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(anm2Path._buf)) + 0x0))) + (-4 - GHIDRA_INT(pcVar1))))) {
|
||||
/* WARNING: Subroutine does not return */
|
||||
_invalid_parameter_noinfo_noreturn();
|
||||
}
|
||||
}
|
||||
operator_delete(pcVar1,size);
|
||||
}
|
||||
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;
|
||||
payToPlayOwner =
|
||||
PlayerManager::FirstCollectibleOwner
|
||||
(&g_game->_playerManager,0x17c,GHIDRA_CAST<RNG **>(&g_game->_playerManager),1);
|
||||
state = (this->_desc)._state;
|
||||
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x154))) = payToPlayOwner != GHIDRA_CAST<Entity_Player *>(0x0);
|
||||
if (state == 0) {
|
||||
pcVar1 = "IdleCoin";
|
||||
if (payToPlayOwner == GHIDRA_CAST<Entity_Player *>(0x0)) {
|
||||
pcVar1 = GHIDRA_CAST<char *>(s_Idle);
|
||||
}
|
||||
isAnimSet = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(pcVar1),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;
|
||||
}
|
||||
}
|
||||
this->_collisionClass = 4;
|
||||
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 4000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
isAnimSet = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>("Broken"),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;
|
||||
}
|
||||
}
|
||||
this->_collisionClass = 0;
|
||||
}
|
||||
ExceptionList = local_10;
|
||||
return;
|
||||
}
|
||||
|
||||
// 00711950
|
||||
void GridEntity_Lock::Update()
|
||||
{
|
||||
Entity_Player *player_00;
|
||||
byte isBreakTriggered;
|
||||
undefined4 *playerSlot;
|
||||
void *playerListEnd;
|
||||
Game *game;
|
||||
PlayerManager *playerManager;
|
||||
uint i;
|
||||
float dx;
|
||||
float dy;
|
||||
Entity_Player *player;
|
||||
int roomWidth;
|
||||
|
||||
if (((this->_sprite)._animState._animData != (void *)0x0) &&
|
||||
(isBreakTriggered =
|
||||
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::IsEventTriggered(GHIDRA_CAST<byte *>("Break")),
|
||||
isBreakTriggered != 0)) {
|
||||
this->_collisionClass = 0;
|
||||
game = g_game;
|
||||
if (GHIDRA_UINT(this->_gridIndex) < 0x1c0) {
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(g_game->_room) + this->_gridIndex * 4 + 0x76c)) = 0;
|
||||
goto LAB_007119ac;
|
||||
}
|
||||
}
|
||||
game = g_game;
|
||||
LAB_007119ac:
|
||||
if ((this->_desc)._state == 0) {
|
||||
playerManager = &game->_playerManager;
|
||||
i = 0;
|
||||
if (GHIDRA_INT((game->_playerManager)._playerList._end) - GHIDRA_INT((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<byte *>("(GHIDRA_CAST<PlayerManager *>(()))->PlayerManager::GetPlayer() : There are no players! \n"));
|
||||
playerListEnd = (playerManager->_playerList)._end;
|
||||
game = g_game;
|
||||
}
|
||||
playerSlot = (playerManager->_playerList)._begin;
|
||||
if (i < GHIDRA_UINT((GHIDRA_INT(playerListEnd) - GHIDRA_INT(playerSlot) >> 2))) {
|
||||
playerSlot = playerSlot + i;
|
||||
}
|
||||
player_00 = GHIDRA_CAST<Entity_Player *>(*playerSlot);
|
||||
if ((player_00->_variant == 0) &&
|
||||
(roomWidth = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(game->_room) + 0xc)),
|
||||
dx = (player_00->_pos).x - ((float)(this->_gridIndex % roomWidth) * 40.0 + 40.0),
|
||||
dy = (player_00->_pos).y - ((float)(this->_gridIndex / roomWidth) * 40.0 + 120.0),
|
||||
dy * dy + dx * dx < 961.0)) {
|
||||
try_unlock(this,player_00,0);
|
||||
game = g_game;
|
||||
}
|
||||
playerManager = &game->_playerManager;
|
||||
i = i + 1;
|
||||
} while (i < GHIDRA_UINT((GHIDRA_INT((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;
|
||||
}
|
||||
|
||||
// 00711af0
|
||||
void GridEntity_Lock::try_unlock(Entity_Player *player, byte isForce)
|
||||
{
|
||||
byte isKeyUsed;
|
||||
int paperClipMultiplier;
|
||||
GridEntity_Lock *soundId [2];
|
||||
Manager *manager;
|
||||
|
||||
if ((this->_desc)._state == 0) {
|
||||
if (isForce == 0) {
|
||||
soundId[0] = this;
|
||||
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x154))) == '\0') {
|
||||
paperClipMultiplier = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::GetTrinketMultiplier(0x13);
|
||||
if ((paperClipMultiplier < 2) &&
|
||||
(isKeyUsed = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::TryUseKey(), isKeyUsed == 0)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (player->_numCoins < 1) {
|
||||
return;
|
||||
}
|
||||
(GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::AddCoins(-1);
|
||||
}
|
||||
}
|
||||
manager = g_manager;
|
||||
soundId[0] = GHIDRA_CAST<GridEntity_Lock *>(0x9c);
|
||||
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x154))) != '\0') {
|
||||
soundId[0] = GHIDRA_CAST<GridEntity_Lock *>(0x2d);
|
||||
}
|
||||
seed_fart_sound_override(GHIDRA_CAST<int *>(soundId));
|
||||
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(soundId[0]),1.0,2,0,1.0,0.0);
|
||||
break_open(this,player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 00711bb0
|
||||
void GridEntity_Lock::break_open(Entity_Player *player)
|
||||
{
|
||||
byte bVar1;
|
||||
int iVar2;
|
||||
uint uVar3;
|
||||
int gridX;
|
||||
void *trinketRngEnd;
|
||||
uint *trinketRng;
|
||||
undefined4 *playerIt;
|
||||
uint variant;
|
||||
char *anim;
|
||||
RNG dropRng;
|
||||
GridEntity_Lock *lock;
|
||||
Vector local_10;
|
||||
code *debugBreak;
|
||||
Game *game;
|
||||
Manager *manager;
|
||||
void *trinketRngBegin;
|
||||
|
||||
manager = g_manager;
|
||||
local_10.y = 3.20897e-43;
|
||||
lock = this;
|
||||
seed_fart_sound_override(GHIDRA_CAST<int *>(&local_10.y));
|
||||
(GHIDRA_CAST<SoundEffects *>((&manager->_sfxManager)))->SoundEffects::Play(GHIDRA_INT(local_10.y),1.0,2,0,1.0,0.0);
|
||||
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x154))) == '\0') {
|
||||
if ((player == GHIDRA_CAST<Entity_Player *>(0x0)) || (anim = "BreakingGolden", player->_hasGoldenKey == 0)) {
|
||||
anim = "Breaking";
|
||||
}
|
||||
}
|
||||
else {
|
||||
anim = "BreakingCoin";
|
||||
}
|
||||
bVar1 = (GHIDRA_CAST<ANM2 *>((&this->_sprite)))->ANM2::SetAnimation(GHIDRA_CAST<byte *>(anim),1);
|
||||
if (bVar1 != 0) {
|
||||
(GHIDRA_CAST<AnimationState *>((&(this->_sprite)._animState)))->AnimationState::Rewind();
|
||||
(this->_sprite)._animState._isPlaying = 1;
|
||||
}
|
||||
uVar3 = (this->_desc)._spawnSeed;
|
||||
(this->_desc)._state = 1;
|
||||
game = g_game;
|
||||
dropRng._shift1 = 1;
|
||||
dropRng._shift2 = 5;
|
||||
dropRng._shift3 = 0x10;
|
||||
if (uVar3 == 0) {
|
||||
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
||||
debugBreak = (code *)swi(3);
|
||||
(*debugBreak)();
|
||||
return;
|
||||
}
|
||||
uVar3 = uVar3 >> 1 ^ uVar3;
|
||||
uVar3 = uVar3 << 5 ^ uVar3;
|
||||
local_10.y = (float)(uVar3 >> 0x10 ^ uVar3);
|
||||
if (0.1 <= (float)((double)GHIDRA_INT(local_10.y) + __uint_to_double_fixup[-(GHIDRA_INT(local_10.y) >> 0x1f)]) *
|
||||
2.3283062e-10) {
|
||||
return;
|
||||
}
|
||||
if (player == GHIDRA_CAST<Entity_Player *>(0x0)) {
|
||||
playerIt = (g_game->_playerManager)._playerList._begin;
|
||||
if (playerIt != (g_game->_playerManager)._playerList._end) {
|
||||
do {
|
||||
player = GHIDRA_CAST<Entity_Player *>(*playerIt);
|
||||
if ((player->_variant == 0) &&
|
||||
(bVar1 = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::HasTrinket(0x16,0), bVar1 != 0)) goto LAB_00711d1a;
|
||||
playerIt = playerIt + 1;
|
||||
} while (playerIt != (game->_playerManager)._playerList._end);
|
||||
}
|
||||
player = GHIDRA_CAST<Entity_Player *>(0x0);
|
||||
}
|
||||
LAB_00711d1a:
|
||||
if (local_10.y == 0.0) {
|
||||
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
||||
debugBreak = (code *)swi(3);
|
||||
(*debugBreak)();
|
||||
return;
|
||||
}
|
||||
uVar3 = GHIDRA_UINT(local_10.y) >> ((byte)dropRng._shift1 & 0x1f) ^ GHIDRA_UINT(local_10.y);
|
||||
uVar3 = uVar3 << ((byte)dropRng._shift2 & 0x1f) ^ uVar3;
|
||||
dropRng._seed = uVar3 >> 0x10 ^ uVar3;
|
||||
local_10.y = (float)dropRng._seed;
|
||||
if (0.25 <= (float)((double)dropRng._seed + __uint_to_double_fixup[-(dropRng._seed >> 0x1f)]) *
|
||||
2.3283062e-10) {
|
||||
LAB_00711e7c:
|
||||
if (local_10.y == 0.0) {
|
||||
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
||||
debugBreak = (code *)swi(3);
|
||||
(*debugBreak)();
|
||||
return;
|
||||
}
|
||||
uVar3 = GHIDRA_UINT(local_10.y) >> ((byte)dropRng._shift1 & 0x1f) ^ GHIDRA_UINT(local_10.y);
|
||||
uVar3 = uVar3 << ((byte)dropRng._shift2 & 0x1f) ^ uVar3;
|
||||
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
||||
gridX = lock->_gridIndex % iVar2;
|
||||
iVar2 = lock->_gridIndex / iVar2;
|
||||
uVar3 = uVar3 >> 0x10 ^ uVar3;
|
||||
variant = 0x14;
|
||||
}
|
||||
else {
|
||||
if (player != GHIDRA_CAST<Entity_Player *>(0x0)) {
|
||||
trinketRngEnd = (player->_trinketRNGs)._end;
|
||||
if (GHIDRA_INT((GHIDRA_INT(trinketRngEnd) - GHIDRA_INT((player->_trinketRNGs)._begin) & 0xfffffff0U)) < 0x161) {
|
||||
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Trinket ID out of bounds!\n"));
|
||||
trinketRngEnd = (player->_trinketRNGs)._end;
|
||||
}
|
||||
trinketRngBegin = (player->_trinketRNGs)._begin;
|
||||
uVar3 = (GHIDRA_INT(trinketRngEnd) - GHIDRA_INT(trinketRngBegin) >> 4) - 1;
|
||||
if (0x16 < uVar3) {
|
||||
uVar3 = 0x16;
|
||||
}
|
||||
trinketRng = GHIDRA_CAST<uint *>((uVar3 * 0x10 + GHIDRA_INT(trinketRngBegin)));
|
||||
uVar3 = *trinketRng;
|
||||
if (uVar3 == 0) {
|
||||
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("RNG Seed is zero!\n"));
|
||||
uVar3 = *trinketRng;
|
||||
if (uVar3 == 0) {
|
||||
debugBreak = (code *)swi(3);
|
||||
(*debugBreak)();
|
||||
return;
|
||||
}
|
||||
}
|
||||
uVar3 = uVar3 >> ((byte)trinketRng[1] & 0x1f) ^ uVar3;
|
||||
uVar3 = uVar3 << ((byte)trinketRng[2] & 0x1f) ^ uVar3;
|
||||
uVar3 = uVar3 >> ((byte)trinketRng[3] & 0x1f) ^ uVar3;
|
||||
*trinketRng = uVar3;
|
||||
if (uVar3 != (uVar3 / 5) * 5) goto LAB_00711e7c;
|
||||
}
|
||||
uVar3 = (GHIDRA_CAST<RNG *>((&dropRng)))->RNG::Next();
|
||||
iVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(g_game->_room) + 0xc));
|
||||
gridX = lock->_gridIndex % iVar2;
|
||||
iVar2 = lock->_gridIndex / iVar2;
|
||||
variant = 10;
|
||||
}
|
||||
local_10.x = (float)gridX * 40.0 + 40.0;
|
||||
local_10.y = (float)iVar2 * 40.0 + 120.0;
|
||||
(GHIDRA_CAST<Game *>((g_game)))->Game::Spawn(5,variant,&local_10,&g_vectorZero,GHIDRA_CAST<Entity *>(0x0),0,uVar3);
|
||||
return;
|
||||
}
|
||||
|
||||
// 00712090
|
||||
void * GridEntity_Lock::GetWaterClipInfo(void *outInfo)
|
||||
{
|
||||
undefined4 clipValue;
|
||||
|
||||
clipValue = 0x26;
|
||||
if (this->_collisionClass != 0) {
|
||||
clipValue = 0x39;
|
||||
}
|
||||
*GHIDRA_CAST<undefined4 *>(outInfo) = clipValue;
|
||||
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(outInfo) + 4)) = 0;
|
||||
return outInfo;
|
||||
}
|
||||
Reference in new issue
Block a user