- anm2.h/.cpp take over ANM2, AnimationState, LayerState, AnmCache and the frame data. They read Anm2Ed's JSON documents with simdjson and play them as the game does (interpolation baked at load). src/anm2/ and msvc.h are retired. - font, formatted_text, string_table and rich_text take over the text classes. FormattedText::parse is still bit-exact against its assembly. - options_config and challenge_params take over OptionsConfig, ChallengeParams and the .ini helpers. The tests include Save's exact bytes. - platform.h/.cpp and main.cpp run IsaacMain on SDL3: the window and GL context open, and the run stops at the first built-in shader (FUN_00a13fa0). - source_tree.py: a taken-over parent stays bytes, taken-over methods are not re-emitted as a namespace, and every address in a (a, b, c to d) list on a comment counts as taken over. - log.h: reconstruction_missing() for a taken-over class's methods that are not written yet. 206 functions taken over, boot path 89/615. The full build waits for wave B: item_config, entity_config and mod_manager still use the old APIs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
344 lines
11 KiB
C++
344 lines
11 KiB
C++
#include "classes.h"
|
|
|
|
// 009fed90
|
|
void Weapon_Bone::Reset()
|
|
{
|
|
this->ClearReferences();
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x1c)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0xc)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x10)) = 0x41200000;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x14)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(this) + 0x18)) = 0x3f800000;
|
|
*GHIDRA_CAST<uint32_t *>((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<uint32_t *>((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;
|
|
msvc::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;
|
|
msvc::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;
|
|
msvc::multiset<unsigned_int>::erase(&local_8);
|
|
*entitySlot = 0;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 009feeb0
|
|
long double Weapon_Bone::GetMaxCharge()
|
|
{
|
|
int in_ECX;
|
|
float fireDelay;
|
|
|
|
if (((*GHIDRA_CAST<uint32_t *>((in_ECX + 0x34)) & 0x80e) == 0) || ((*GHIDRA_CAST<uint32_t *>((in_ECX + 0x34)) & 1) != 0)) {
|
|
fireDelay = *GHIDRA_CAST<float *>((in_ECX + 0x10));
|
|
if (fireDelay < 0.001) {
|
|
fireDelay = 0.001;
|
|
}
|
|
return (long double)fireDelay * (long double)3.0;
|
|
}
|
|
fireDelay = *GHIDRA_CAST<float *>((in_ECX + 0x10));
|
|
if (fireDelay < 0.001) {
|
|
fireDelay = 0.001;
|
|
}
|
|
return (long double)fireDelay + (long double)fireDelay;
|
|
}
|
|
|
|
// 009fef20
|
|
void Weapon_Bone::guard_check_icall()
|
|
{
|
|
uint8_t bVar1;
|
|
uint8_t *pbVar2;
|
|
uint32_t uVar3;
|
|
uint8_t *pbVar4;
|
|
uint8_t *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;
|
|
msvc::multiset<unsigned_int>::erase(&eraseKey);
|
|
}
|
|
*targetRef = 0;
|
|
*GHIDRA_CAST<uint32_t *>((knife + 0x444)) = 0;
|
|
*GHIDRA_CAST<uint8_t *>((knife + 0x464)) = 0;
|
|
*GHIDRA_CAST<uint32_t *>((knife + 0x448)) = 0;
|
|
*GHIDRA_CAST<uint16_t *>((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<uint8_t **>((knife + 0x7c));
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((pbVar2 + 0x14))) {
|
|
pbVar2 = *GHIDRA_CAST<uint8_t **>(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<uint8_t **>((knife + 0x7c));
|
|
if (pbVar2 != GHIDRA_CAST<uint8_t *>(0x0)) {
|
|
pbVar4 = pbVar2;
|
|
if (0xf < *GHIDRA_CAST<uint32_t *>((pbVar2 + 0x14))) {
|
|
pbVar4 = *GHIDRA_CAST<uint8_t **>(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 = ANM2::SetAnimation(GHIDRA_CAST<ANM2 *>((knife + 0x48)),s_Idle,1);
|
|
if (bVar1 != 0) {
|
|
AnimationState::Rewind(GHIDRA_CAST<AnimationState *>((knife + 0x78)));
|
|
*GHIDRA_CAST<uint8_t *>((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;
|
|
uint64_t qVar2;
|
|
ColorMod *pCVar3;
|
|
BitSet128 *tearFlags;
|
|
Weapon *in_ECX;
|
|
float damage;
|
|
int iVar4;
|
|
int iVar5;
|
|
Weapon *this;
|
|
uint8_t local_50 [4];
|
|
BitSet128 local_4c;
|
|
ColorMod tearColor;
|
|
uint32_t local_c;
|
|
code *setDamageFn;
|
|
|
|
local_c = __security_cookie ^ GHIDRA_UINT(local_50);
|
|
(*GHIDRA_CAST<uint32_t *>((GHIDRA_CAST<char *>(&(local_4c._l)) + 0x0))) = *param_1;
|
|
if (*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((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<uint32_t *>((iVar5 + 0x34)) >> 7 & 1) == 0) {
|
|
iVar4 = 0x40400000;
|
|
}
|
|
else {
|
|
iVar4 = 0x3f000000;
|
|
}
|
|
param_1[0xdf] = iVar4;
|
|
return;
|
|
}
|
|
|
|
// 009ff1a0
|
|
uint8_t 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
|
|
uint8_t 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
|
|
uint8_t Weapon_Bone::CanOverrideForgottenThrow()
|
|
{
|
|
void *player = this;
|
|
int iVar1;
|
|
bool bVar2;
|
|
uint8_t isDrFetusOnly;
|
|
Entity_Player *player;
|
|
Entity_Player *ownerPlayer;
|
|
bool isDrFetusOnly;
|
|
uint8_t modifierBits;
|
|
uint32_t 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<uint8_t *>((GHIDRA_CAST<char *>(player) + 0x34));
|
|
modifiers = *GHIDRA_CAST<uint32_t *>((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;
|
|
}
|