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

344 lines
11 KiB
C++

#include "classes.h"
// 009fed90
void Weapon_Bone::Reset()
{
this->ClearReferences();
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0x41200000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0x3f800000;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x38)) = 0;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x20)) = g_vectorZero.x;
*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x24)) = g_vectorZero.y;
*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(this) + 0x5c)) = 0;
return;
}
// 009fedf0
void Weapon_Bone::ClearReferences()
{
int *entitySlot;
int remaining;
int *local_8;
entitySlot = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 8));
local_8 = this;
if (*GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 8)) != GHIDRA_CAST<int *>(0x0)) {
(**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 8)) + 0x28))();
if (*entitySlot != 0) {
local_8 = entitySlot;
std::multiset<unsigned_int>::erase(&local_8);
*entitySlot = 0;
}
}
entitySlot = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0x44));
remaining = 4;
do {
if (GHIDRA_CAST<int *>(*entitySlot) != GHIDRA_CAST<int *>(0x0)) {
(**(code **)(*GHIDRA_CAST<int *>(*entitySlot) + 0x28))();
(**(code **)(*GHIDRA_CAST<int *>(*entitySlot) + 0x44))();
}
entitySlot = entitySlot + 1;
remaining = remaining + -1;
} while (remaining != 0);
entitySlot = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0x58));
if (*GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x58)) != GHIDRA_CAST<int *>(0x0)) {
(**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x58)) + 0x28))();
if (*entitySlot != 0) {
local_8 = entitySlot;
std::multiset<unsigned_int>::erase(&local_8);
*entitySlot = 0;
}
}
entitySlot = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0x54));
if (*GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x54)) != GHIDRA_CAST<int *>(0x0)) {
(**(code **)(**GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0x54)) + 0x28))();
if (*entitySlot != 0) {
local_8 = entitySlot;
std::multiset<unsigned_int>::erase(&local_8);
*entitySlot = 0;
}
}
return;
}
// 009feeb0
float10 Weapon_Bone::GetMaxCharge()
{
int in_ECX;
float fireDelay;
if (((*GHIDRA_CAST<uint *>((in_ECX + 0x34)) & 0x80e) == 0) || ((*GHIDRA_CAST<uint *>((in_ECX + 0x34)) & 1) != 0)) {
fireDelay = *GHIDRA_CAST<float *>((in_ECX + 0x10));
if (fireDelay < 0.001) {
fireDelay = 0.001;
}
return (float10)fireDelay * (float10)3.0;
}
fireDelay = *GHIDRA_CAST<float *>((in_ECX + 0x10));
if (fireDelay < 0.001) {
fireDelay = 0.001;
}
return (float10)fireDelay + (float10)fireDelay;
}
// 009fef20
void Weapon_Bone::guard_check_icall()
{
byte bVar1;
byte *pbVar2;
uint uVar3;
byte *pbVar4;
byte *idleName;
int *knifeSlot;
bool isLess;
int *eraseKey;
int slotsLeft;
int knife;
int *targetRef;
knifeSlot = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0x44));
slotsLeft = 4;
do {
knife = *knifeSlot;
if (knife != 0) {
targetRef = GHIDRA_CAST<int *>((knife + 0x3c4));
*GHIDRA_CAST<float *>((knife + 0x334)) = g_vectorZero.x;
*GHIDRA_CAST<float *>((knife + 0x338)) = g_vectorZero.y;
if (*targetRef != 0) {
eraseKey = targetRef;
std::multiset<unsigned_int>::erase(&eraseKey);
}
*targetRef = 0;
*GHIDRA_CAST<undefined4 *>((knife + 0x444)) = 0;
*GHIDRA_CAST<undefined1 *>((knife + 0x464)) = 0;
*GHIDRA_CAST<undefined4 *>((knife + 0x448)) = 0;
*GHIDRA_CAST<undefined2 *>((knife + 0x4e5)) = 0;
switch(*GHIDRA_CAST<int *>((knife + 0x2c))) {
case 2:
case 3:
case 4:
case 8:
case 9:
code_r0x009fefcb:
if ((*GHIDRA_CAST<int *>((knife + 0x7c)) != 0) && (*GHIDRA_CAST<char *>((knife + 0x8c)) != '\0')) {
pbVar2 = *GHIDRA_CAST<byte **>((knife + 0x7c));
if (0xf < *GHIDRA_CAST<uint *>((pbVar2 + 0x14))) {
pbVar2 = *GHIDRA_CAST<byte **>(pbVar2);
}
pbVar4 = &DAT_00b602e8;
do {
bVar1 = *pbVar2;
isLess = bVar1 < *pbVar4;
if (bVar1 != *pbVar4) {
LAB_009ff012:
uVar3 = -GHIDRA_UINT(isLess) | 1;
goto LAB_009ff017;
}
if (bVar1 == 0) break;
bVar1 = pbVar2[1];
isLess = bVar1 < pbVar4[1];
if (bVar1 != pbVar4[1]) goto LAB_009ff012;
pbVar2 = pbVar2 + 2;
pbVar4 = pbVar4 + 2;
} while (bVar1 != 0);
uVar3 = 0;
LAB_009ff017:
if (uVar3 == 0) {
pbVar2 = *GHIDRA_CAST<byte **>((knife + 0x7c));
if (pbVar2 != GHIDRA_CAST<byte *>(0x0)) {
pbVar4 = pbVar2;
if (0xf < *GHIDRA_CAST<uint *>((pbVar2 + 0x14))) {
pbVar4 = *GHIDRA_CAST<byte **>(pbVar2);
}
idleName = s_Idle;
do {
bVar1 = *pbVar4;
isLess = bVar1 < *idleName;
if (bVar1 != *idleName) {
LAB_009ff054:
uVar3 = -GHIDRA_UINT(isLess) | 1;
goto LAB_009ff059;
}
if (bVar1 == 0) break;
bVar1 = pbVar4[1];
isLess = bVar1 < idleName[1];
if (bVar1 != idleName[1]) goto LAB_009ff054;
pbVar4 = pbVar4 + 2;
idleName = idleName + 2;
} while (bVar1 != 0);
uVar3 = 0;
LAB_009ff059:
if ((uVar3 == 0) && ((pbVar2[0x34] == 0 || (*GHIDRA_CAST<char *>((knife + 0x8c)) != '\0')))) break;
}
bVar1 = (GHIDRA_CAST<ANM2 *>((GHIDRA_CAST<ANM2 *>((knife + 0x48)))))->ANM2::SetAnimation(s_Idle,1);
if (bVar1 != 0) {
(GHIDRA_CAST<AnimationState *>((GHIDRA_CAST<AnimationState *>((knife + 0x78)))))->AnimationState::Rewind();
*GHIDRA_CAST<undefined1 *>((knife + 0x8c)) = 1;
}
}
}
break;
case 5:
case 0xb:
break;
default:
if (*GHIDRA_CAST<int *>((knife + 0x2c)) == 1) goto code_r0x009fefcb;
}
}
knifeSlot = knifeSlot + 1;
slotsLeft = slotsLeft + -1;
if (slotsLeft == 0) {
return;
}
} while( true );
}
// 009ff0c0
void Weapon_Bone::init_club(int *param_1)
{
int iVar1;
qword qVar2;
ColorMod *pCVar3;
BitSet128 *tearFlags;
Weapon *in_ECX;
float damage;
int iVar4;
int iVar5;
Weapon *this;
undefined1 local_50 [4];
BitSet128 local_4c;
ColorMod tearColor;
uint local_c;
code *setDamageFn;
local_c = __security_cookie ^ GHIDRA_UINT(local_50);
(*GHIDRA_CAST<undefined4 *>((GHIDRA_CAST<char *>(&(local_4c._l)) + 0x0))) = *param_1;
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<undefined1 *>((GHIDRA_CAST<char *>((in_ECX)) + 0x30)))) == 0xb) {
(**(code **)(GHIDRA_CAST<char *>(local_4c._l) + 0x40))();
return;
}
pCVar3 = (GHIDRA_CAST<Weapon *>((in_ECX)))->Weapon::get_tear_color(&tearColor);
this = GHIDRA_CAST<Weapon *>(0xff);
iVar5 = -1;
(**(code **)(GHIDRA_CAST<char *>(local_4c._l) + 0x3c))(pCVar3,0xffffffff,0xff,0);
tearFlags = (GHIDRA_CAST<Weapon *>((in_ECX)))->Weapon::get_owner_tear_flags(GHIDRA_CAST<BitSet128 *>((local_50 + -0xc)));
iVar4 = *GHIDRA_CAST<int *>((GHIDRA_INT(&tearFlags->_l) + 4));
qVar2 = tearFlags->_h;
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_INT(&tearFlags->_h) + 4));
param_1[0x104] = GHIDRA_INT(tearFlags->_l);
param_1[0x105] = iVar4;
param_1[0x106] = GHIDRA_INT(qVar2);
param_1[0x107] = iVar1;
setDamageFn = *(code **)(*param_1 + 0x40);
damage = this->Weapon::get_damage();
(*setDamageFn)(damage);
if ((*GHIDRA_CAST<uint *>((iVar5 + 0x34)) >> 7 & 1) == 0) {
iVar4 = 0x40400000;
}
else {
iVar4 = 0x3f000000;
}
param_1[0xdf] = iVar4;
return;
}
// 009ff1a0
undefined1 Weapon_Bone::CanTriggerCursedEyeTeleport()
{
int iVar1;
float minChargeTime;
if (((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x30)) != 0xb) && (iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)), iVar1 != 0)) &&
(*GHIDRA_CAST<int *>((iVar1 + 0x28)) == 1)) {
if ((*GHIDRA_CAST<int *>((iVar1 + 0x140c)) != 0) &&
(iVar1 = this->GetMarkedTargetVariant(), iVar1 != 0)) {
return 0;
}
if (0.0 < *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x14))) {
minChargeTime = *GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x10));
if (minChargeTime < 0.001) {
minChargeTime = 0.001;
}
if (*GHIDRA_CAST<float *>((GHIDRA_CAST<char *>(this) + 0x14)) < minChargeTime + minChargeTime) {
return 1;
}
}
}
return 0;
}
// 009ff210
undefined1 Weapon_Bone::CanTriggerKidneyStone()
{
if ((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x30)) == 0xb) ||
((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x44)) != 0 && (*GHIDRA_CAST<char *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 0x44)) + 0x464)) != '\0'))))
{
return 0;
}
return 1;
}
// 009ff230
undefined1 Weapon_Bone::CanOverrideForgottenThrow()
{
void *player = this;
int iVar1;
bool bVar2;
byte isDrFetusOnly;
Entity_Player *player;
Entity_Player *ownerPlayer;
bool isDrFetusOnly;
byte modifierBits;
uint modifiers;
ownerPlayer = *GHIDRA_CAST<Entity_Player **>((GHIDRA_CAST<char *>(player) + 4));
iVar1 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(player) + 0x30));
if (ownerPlayer == GHIDRA_CAST<Entity_Player *>(0x0)) {
LAB_009ff265:
player = GHIDRA_CAST<Entity_Player *>(0x0);
if ((ownerPlayer == GHIDRA_CAST<Entity_Player *>(0x0)) || (ownerPlayer->_type != 1)) {
LAB_009ff273:
ownerPlayer = GHIDRA_CAST<Entity_Player *>(0x0);
}
}
else {
if (ownerPlayer->_type != 1) {
if (ownerPlayer->_type != 3) goto LAB_009ff265;
player = *GHIDRA_CAST<Entity_Player **>(&ownerPlayer->_isControlsEnabled);
goto LAB_009ff273;
}
player = ownerPlayer;
}
modifierBits = *GHIDRA_CAST<byte *>((GHIDRA_CAST<char *>(player) + 0x34));
modifiers = *GHIDRA_CAST<uint *>((GHIDRA_CAST<char *>(player) + 0x34));
if ((((iVar1 == 0xb) || (player == GHIDRA_CAST<Entity_Player *>(0x0))) ||
(isDrFetusOnly = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::HasCollectible(0x34,0), isDrFetusOnly == 0)) ||
(isDrFetusOnly = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::HasCollectible(0xa8,0), isDrFetusOnly != 0)) {
isDrFetusOnly = false;
if ((iVar1 != 0xb) && (player != GHIDRA_CAST<Entity_Player *>(0x0))) goto LAB_009ff2f1;
}
else {
isDrFetusOnly = true;
LAB_009ff2f1:
isDrFetusOnly = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::HasCollectible(0xa8,0);
if (isDrFetusOnly != 0) {
bVar2 = true;
goto LAB_009ff309;
}
}
bVar2 = false;
LAB_009ff309:
if (((((modifierBits & 1) == 0) && ((modifiers >> 1 & 1) == 0)) &&
(((modifiers >> 2 & 1) == 0 && ((modifiers >> 3 & 1) == 0)))) &&
(((((!isDrFetusOnly && (!bVar2)) || (ownerPlayer == GHIDRA_CAST<Entity_Player *>(0x0))) ||
(ownerPlayer->_heldEntity == (void *)0x0)) &&
((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(player) + 0x44)) == 0 || (*GHIDRA_CAST<char *>((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(player) + 0x44)) + 0x466)) == '\0')))
))) {
return 0;
}
return 1;
}