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>
278 lines
9.8 KiB
C++
278 lines
9.8 KiB
C++
#include "classes.h"
|
|
|
|
// 00429550
|
|
bool DeathmatchManager::is_active()
|
|
{
|
|
int *in_ECX;
|
|
|
|
return 1 < *in_ECX;
|
|
}
|
|
|
|
// 00429560
|
|
bool DeathmatchManager::is_mode_4()
|
|
{
|
|
int *in_ECX;
|
|
|
|
return *in_ECX == 4;
|
|
}
|
|
|
|
// 00429570
|
|
void DeathmatchManager::enter_arena()
|
|
{
|
|
char cVar1;
|
|
int iVar2;
|
|
uint listCount;
|
|
int dstCount;
|
|
Game *game;
|
|
uint j;
|
|
uint i;
|
|
KColor fadeColor;
|
|
DeathmatchManager *self;
|
|
void *local_14;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 uStack_8;
|
|
void *curRoom;
|
|
|
|
uStack_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af1b00;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
cVar1 = (*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this[1])) + 0x8)));
|
|
*GHIDRA_CAST<undefined4 *>(this) = 2;
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((this)) + 0x4)))) = 0;
|
|
self = this;
|
|
if (cVar1 == '\0') {
|
|
(GHIDRA_CAST<SoundEffects *>((&g_manager->_sfxManager)))->SoundEffects::Play(0x341,1.0,1,0,1.0,0.0);
|
|
}
|
|
local_14 = g_game->_room;
|
|
game = g_game;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_14) + 0x1254)) != 0) {
|
|
do {
|
|
curRoom = game->_room;
|
|
i = 0;
|
|
iVar2 = **GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(local_14) + 0x124c));
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x1254)) != 0) {
|
|
do {
|
|
if (iVar2 == *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x124c)) + i * 4))) {
|
|
listCount = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(curRoom) + 0x1254));
|
|
if (listCount <= i) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("EL: invalid index for remove\n"));
|
|
listCount = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(curRoom) + 0x1254));
|
|
}
|
|
j = i;
|
|
if (i < listCount - 1) {
|
|
do {
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x124c)) + j * 4)) =
|
|
*GHIDRA_CAST<undefined4 *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x124c)) + 4 + j * 4));
|
|
j = j + 1;
|
|
listCount = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(curRoom) + 0x1254));
|
|
} while (j < listCount - 1);
|
|
}
|
|
*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(curRoom) + 0x1254)) = listCount - 1;
|
|
dstCount = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x1244));
|
|
if (*GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(curRoom) + 0x1240)) < dstCount + 1U) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("EL: not enough space for push_back\n"));
|
|
dstCount = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x1244));
|
|
}
|
|
*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x123c)) + dstCount * 4)) = iVar2;
|
|
*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x1244)) = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x1244)) + 1;
|
|
}
|
|
i = i + 1;
|
|
} while (i < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(curRoom) + 0x1254)));
|
|
game = g_game;
|
|
}
|
|
} while (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(local_14) + 0x1254)) != 0);
|
|
this = self;
|
|
}
|
|
curRoom = game->_room;
|
|
i = 0;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x1264)) != 0) {
|
|
do {
|
|
iVar2 = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(curRoom) + 0x125c)) + i * 4));
|
|
i = i + 1;
|
|
*GHIDRA_CAST<uint *>((iVar2 + 0x16c)) = *GHIDRA_CAST<uint *>((iVar2 + 0x16c)) & 0xffffffdf;
|
|
*GHIDRA_CAST<undefined4 *>((iVar2 + 0x168)) = *GHIDRA_CAST<undefined4 *>((iVar2 + 0x168));
|
|
} while (i < *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(curRoom) + 0x1264)));
|
|
game = g_game;
|
|
}
|
|
Game::StartRoomTransition(game,-0x13,-1,0x15,GHIDRA_CAST<Entity_Player *>(0x0),-1);
|
|
(GHIDRA_CAST<RoomTransition *>((&g_game->_roomTransition)))->RoomTransition::Update();
|
|
game = g_game;
|
|
iVar2 = 0;
|
|
fadeColor._unk = 0;
|
|
fadeColor._alpha = 1.0;
|
|
(g_game->_roomTransition)._frame = 0;
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&((game->_roomTransition))) + 0xc)))) = 0;
|
|
*GHIDRA_CAST<undefined4 *>(&game->_roomTransition) = 0;
|
|
(game->_roomTransition)._direction = 0;
|
|
(game->_roomTransition)._animation = 0;
|
|
*GHIDRA_CAST<undefined4 *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&((game->_roomTransition))) + 0x20)))) = 0;
|
|
(game->_roomTransition)._flags = 0;
|
|
(game->_playerManager)._roomTransitionPlayer = (void *)0x0;
|
|
if ((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(this[1])) + 0x8))) != '\0') {
|
|
iVar2 = 0xff;
|
|
}
|
|
fadeColor._red = ((float)iVar2 + 0.0) / 255.0;
|
|
fadeColor._green = fadeColor._red;
|
|
fadeColor._blue = fadeColor._red;
|
|
(GHIDRA_CAST<Game *>((game)))->Game::Fadein(0.0,0,&fadeColor);
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|
|
|
|
// 00429be0
|
|
void DeathmatchManager::set_type(int type)
|
|
{
|
|
char isLastRef;
|
|
void *loadedImage;
|
|
undefined4 *deathmatchType;
|
|
undefined1 imageResult [4];
|
|
int *imageResultRefCount;
|
|
void *local_10;
|
|
undefined1 *puStack_c;
|
|
undefined4 local_8;
|
|
int *ludovicoImage;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af1c45;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
if (this->_type != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
(*(code *)**GHIDRA_CAST<undefined4 **>(this->_type))(1,__security_cookie ^ GHIDRA_UINT((imageResult + 0x18)));
|
|
this->_type = (void *)0x0;
|
|
}
|
|
switch(type) {
|
|
case 1:
|
|
deathmatchType = operator_new(0x34);
|
|
local_8 = 0;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeNormal::vftable;
|
|
deathmatchType[0xb] = 0xb4;
|
|
deathmatchType[0xc] = 6;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 2:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 1;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeIpecac::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 3:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 2;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeBomberman::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 4:
|
|
deathmatchType = operator_new(0x34);
|
|
local_8 = 3;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeLudovico::vftable;
|
|
deathmatchType[0xb] = 0;
|
|
deathmatchType[0xc] = 0;
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 5;
|
|
loadedImage = Manager::LoadImage(imageResult,
|
|
(byte *)
|
|
"gfx/Items/Collectibles/collectibles_329_theludovicotechnique.png"
|
|
);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 6;
|
|
(GHIDRA_CAST<KAGE::SmartPointer *>((deathmatchType + 0xb)))->KAGE::SmartPointer::operator_assign(loadedImage);
|
|
(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x0))) = 7;
|
|
if (((imageResultRefCount != GHIDRA_CAST<int *>(0x0)) &&
|
|
(isLastRef = (**(code **)(*imageResultRefCount + 0xc))(), isLastRef != '\0')) &&
|
|
(g_imageReleaseFn != (void *)0x0)) {
|
|
(*g_imageReleaseFn)(imageResult);
|
|
}
|
|
local_8 = CONCAT31((*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>(&(local_8)) + 0x1))),5);
|
|
ludovicoImage = GHIDRA_CAST<int *>(deathmatchType[0xb]);
|
|
if ((ludovicoImage[0xc] != 1) || (ludovicoImage[0xd] != 1)) {
|
|
(**(code **)(*ludovicoImage + 0x44))(1,1);
|
|
ludovicoImage[0xc] = 1;
|
|
ludovicoImage[0xd] = 1;
|
|
}
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 5:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 8;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeSumo::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 6:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 9;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeKnockout::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 7:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 10;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeSwordFight::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 8:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 0xb;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeMachineGun::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 9:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 0xc;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeIndigestion::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 10:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 0xd;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeKnifeFight::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
case 0xb:
|
|
deathmatchType = operator_new(0x2c);
|
|
local_8 = 0xe;
|
|
if (deathmatchType != GHIDRA_CAST<undefined4 *>(0x0)) {
|
|
FUN_0042a350();
|
|
*deathmatchType = IsaacRepentancePlus::DeathmatchTypeVenom::vftable;
|
|
goto LAB_00429ed1;
|
|
}
|
|
break;
|
|
default:
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<byte *>("Unknown type specified\n"));
|
|
}
|
|
deathmatchType = GHIDRA_CAST<undefined4 *>(0x0);
|
|
LAB_00429ed1:
|
|
this->_type = deathmatchType;
|
|
ExceptionList = local_10;
|
|
return;
|
|
}
|