Skip to content

Commit

Permalink
Clean up special item drop mgr (#87)
Browse files Browse the repository at this point in the history
* Clean up special item drop mgr

* Progress

* Mostly matching

* Docs
  • Loading branch information
robojumper authored Nov 6, 2024
1 parent 9334796 commit aaf88fa
Show file tree
Hide file tree
Showing 11 changed files with 548 additions and 87 deletions.
2 changes: 1 addition & 1 deletion config/SOUE01/rels/d_t_reactionNP/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ checkForSlingBellowsItem__13dTgReaction_cFv = .text:0x00000C50; // type:function
onDelete__13dTgReaction_cFv = .text:0x00000D60; // type:function size:0x44
fn_578_DB0 = .text:0x00000DB0; // type:function size:0xB4
spawnHearts__13dTgReaction_cFlRC7mVec3_cl4mAng = .text:0x00000E70; // type:function size:0x184
rndRange<4mAng>__F4mAng4mAng_4mAng = .text:0x00001000; // type:function size:0xA4
rndRange<4mAng>__2cMF4mAng4mAng_4mAng = .text:0x00001000; // type:function size:0xA4
__dt__13dTgReaction_cFv = .text:0x000010B0; // type:function size:0xD8
getStateID__82sStateMgr_c<13dTgReaction_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00001190; // type:function size:0x10
build__29sFStateFct_c<13dTgReaction_c>FRC12sStateIDIf_c = .text:0x000011A0; // type:function size:0x60
Expand Down
3 changes: 3 additions & 0 deletions config/SOUE01/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ d/flag/flag_managers.cpp:

toBeSorted/special_item_drop_mgr.cpp:
.text start:0x800C7B60 end:0x800C82B0
.rodata start:0x804E4CC8 end:0x804E4EE0
.data start:0x80511C50 end:0x80511C60
.sbss start:0x80575438 end:0x80575440
.sdata2 start:0x805799B8 end:0x80579AD0

d/lyt/meter/d_lyt_meter.cpp:
.text start:0x800C8950 end:0x800DF8A8
Expand Down
20 changes: 10 additions & 10 deletions config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4416,12 +4416,12 @@ Timekeeper__doCount = .text:0x800C7A20; // type:function size:0x130
fn_800C7B50 = .text:0x800C7B50; // type:function size:0x8
__ct__18SpecialItemDropMgrFv = .text:0x800C7B60; // type:function size:0x14
SpecialItemDropMgr__ctor = .text:0x800C7B80; // type:function size:0x30
fn_800C7BB0__FP18SpecialItemDropMgri = .text:0x800C7BB0; // type:function size:0x150
fn_800C7D00__FP18SpecialItemDropMgri = .text:0x800C7D00; // type:function size:0x1C
fn_800C7D20__FP18SpecialItemDropMgri = .text:0x800C7D20; // type:function size:0x1C
giveSpecialDropItem__FP18SpecialItemDropMgriiP7mVec3_ciPsi = .text:0x800C7D40; // type:function size:0x1A8
spawnSpecialDropItem__FP18SpecialItemDropMgriiP7mVec3_ciPs = .text:0x800C7EF0; // type:function size:0x2D8
fn_800C81D0__Fsss = .text:0x800C81D0; // type:function size:0x98
fn_800C7BB0__18SpecialItemDropMgrFi = .text:0x800C7BB0; // type:function size:0x150
shouldTryExtraHearts__18SpecialItemDropMgrFi = .text:0x800C7D00; // type:function size:0x1C
shouldTryExtraRupees__18SpecialItemDropMgrFi = .text:0x800C7D20; // type:function size:0x1C
giveSpecialDropItem__18SpecialItemDropMgrFiiP7mVec3_ci4mAngl = .text:0x800C7D40; // type:function size:0x1A8
spawnSpecialDropItem__18SpecialItemDropMgrFiiP7mVec3_ci4mAng = .text:0x800C7EF0; // type:function size:0x2D8
rndRange<4mAng>__2cMF4mAng4mAng_4mAng = .text:0x800C81D0; // type:function size:0x98
__dt__18SpecialItemDropMgrFv = .text:0x800C8270; // type:function size:0x40
isShortNegative = .text:0x800C82B0; // type:function size:0x18
0x3FFFMask = .text:0x800C82D0; // type:function size:0x18
Expand Down Expand Up @@ -13546,7 +13546,7 @@ fn_80251940 = .text:0x80251940; // type:function size:0xA8
AcItem__getCurrentOffset = .text:0x802519F0; // type:function size:0xA0
AcItem__getPositionOffset = .text:0x80251A90; // type:function size:0x5C
fn_80251AF0 = .text:0x80251AF0; // type:function size:0x78
AcItem__checkFlag = .text:0x80251B70; // type:function size:0x128
checkFlag__9dAcItem_cFUl = .text:0x80251B70; // type:function size:0x128
AcItem__setFlag = .text:0x80251CA0; // type:function size:0xC0
AcItem__checkFlagForItem = .text:0x80251D60; // type:function size:0x34
AcItem__checkItemFlag = .text:0x80251DA0; // type:function size:0x48
Expand Down Expand Up @@ -28233,7 +28233,7 @@ lbl_804E4CB8 = .rodata:0x804E4CB8; // type:object size:0x10 data:float
lbl_804E4CC8 = .rodata:0x804E4CC8; // type:object size:0x10
lbl_804E4CD8 = .rodata:0x804E4CD8; // type:object size:0x1B0
lbl_804E4E88 = .rodata:0x804E4E88; // type:object size:0x20 data:4byte
SPECIAL_ITEM_ARRAY = .rodata:0x804E4EA8; // type:object size:0x38
SPECIAL_ITEM_ARRAY = .rodata:0x804E4EA8; // type:object size:0x32
btn1BrlanMap = .rodata:0x804E4EE0; // type:object size:0x18 scope:local data:4byte
lbl_804E4EF8 = .rodata:0x804E4EF8; // type:object size:0x18 data:4byte
lbl_804E4F10 = .rodata:0x804E4F10; // type:object size:0x110 data:4byte
Expand Down Expand Up @@ -31041,7 +31041,7 @@ lbl_80511C00 = .data:0x80511C00; // type:object size:0x10
lbl_80511C10 = .data:0x80511C10; // type:object size:0x10
lbl_80511C20 = .data:0x80511C20; // type:object size:0x10
Timekeeper__vtable = .data:0x80511C30; // type:object size:0x20
SpecialItemDropMgr__vtable = .data:0x80511C50; // type:object size:0x10
__vt__18SpecialItemDropMgr = .data:0x80511C50; // type:object size:0xC
lbl_80511C60 = .data:0x80511C60; // type:object size:0x14
lbl_80511C74 = .data:0x80511C74; // type:object size:0xC
lbl_80511C80 = .data:0x80511C80; // type:object size:0x1C
Expand Down Expand Up @@ -39954,7 +39954,7 @@ lbl_80575418 = .sbss:0x80575418; // type:object size:0x8
lbl_80575420 = .sbss:0x80575420; // type:object size:0x8 data:byte
lbl_80575428 = .sbss:0x80575428; // type:object size:0x8 data:byte
lbl_80575430 = .sbss:0x80575430; // type:object size:0x8 data:4byte
SpecialItemDropMgr__sInstance = .sbss:0x80575438; // type:object size:0x8 data:4byte
sInstance__18SpecialItemDropMgr = .sbss:0x80575438; // type:object size:0x4 data:4byte
FOR_LOADED_PARTICLES = .sbss:0x80575440; // type:object size:0x8 data:4byte
sInstance__20dLytMeterContainer_c = .sbss:0x80575448; // type:object size:0x8 data:4byte
lbl_80575450 = .sbss:0x80575450; // type:object size:0x8 data:4byte
Expand Down
9 changes: 8 additions & 1 deletion include/c/c_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ int rndInt(int max);
f32 rndF(f32 max);
f32 rndFX(f32 amp);

template <typename T>
template <typename T>
T rndRange(T min, T max) {
f32 r = cM::rndF(max - min);
f32 m = min;
m += r;
return m;
}

inline T minMaxLimit(T val, T min, T max) {
return (T)((T)val < (T)min ? (T)min : ((T)val > (T)max ? (T)max : (T)val));
}
Expand Down
2 changes: 1 addition & 1 deletion include/d/a/d_a_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class dAcPy_c : public dAcObjBase_c {
/* vt 0x144 */ virtual void setActorLinkToSomething();
/* vt 0x148 */ virtual void applyDamageWithIFrames();
/* vt 0x14C */ virtual void vt_0x14C();
/* vt 0x150 */ virtual void hasLessThanQuarterHealth();
/* vt 0x150 */ virtual bool hasLessThanQuarterHealth(bool);
/* vt 0x154 */ virtual void vt_0x154();
/* vt 0x158 */ virtual void vt_0x158();
/* vt 0x15C */ virtual void vt_0x15C();
Expand Down
2 changes: 2 additions & 0 deletions include/d/a/obj/d_a_obj_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class dAcItem_c : public dAcObjBase_c {

static void spawnItem(u16 item, u32 room, const mVec3_c &pos, const mAng3_c &rot, u32 params, u32 arg);
static void spawnDrop(u16 item, u32 room, const mVec3_c &pos, const mAng3_c &rot);

static u32 checkFlag(u32 flag);
};

#endif
20 changes: 10 additions & 10 deletions include/toBeSorted/special_item_drop_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
#define SPECIAL_ITEM_DROP_MGR_H

#include "common.h"
#include "m/m_angle.h"
#include "m/m_vec.h"

class SpecialItemDropMgr {
public:
static SpecialItemDropMgr *sInstance;

SpecialItemDropMgr();
static int fn_800C7BB0(SpecialItemDropMgr *mgr, int specialItemId);
static short fn_800C7D00(SpecialItemDropMgr *mgr, int specialItemId);
static short fn_800C7D20(SpecialItemDropMgr *mgr, int specialItemId);
static int giveSpecialDropItem(
SpecialItemDropMgr *mgr, int specialItemId, int roomid, mVec3_c *pos, int subtype, s16 *rot, s32 unused
);
static bool
spawnSpecialDropItem(SpecialItemDropMgr *mgr, int specialItemId, int roomid, mVec3_c *pos, int subtype, s16 *rot);
static void fn_800C81D0(s16, s16, s16);
~SpecialItemDropMgr();
virtual ~SpecialItemDropMgr() {}

static SpecialItemDropMgr *create();

int fn_800C7BB0(int specialItemId);
bool shouldTryExtraHearts(int specialItemId);
bool shouldTryExtraRupees(int specialItemId);
int giveSpecialDropItem(int specialItemId, int roomid, mVec3_c *pos, int subtype, mAng rot, s32 unused);
bool spawnSpecialDropItem(int specialItemId, int roomid, mVec3_c *pos, int subtype, mAng rot);
};

#endif
4 changes: 2 additions & 2 deletions src/REL/d/a/obj/d_a_obj_toD3_stone_figure.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "d/a/obj/d_a_obj_toD3_stone_figure.h"

#include "d/col/cc/d_cc_s.h"
#include "d/a/obj/d_a_obj_item.h"
#include "d/flag/storyflag_manager.h"
#include "toBeSorted/attention.h"
#include "toBeSorted/event.h"
Expand Down Expand Up @@ -163,7 +164,6 @@ void dAcOtoD3StoneFigure_c::doInteraction(s32 arg) {
}
}

extern "C" s32 AcItem__checkFlag(s32);
bool dAcOtoD3StoneFigure_c::hasStoneOfTrials() const {
return AcItem__checkFlag(0xB4);
return dAcItem_c::checkFlag(0xB4);
}
18 changes: 4 additions & 14 deletions src/REL/d/t/d_t_reaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,17 @@ void dTgReaction_c::checkForBubble() {
dCcS::GetInstance()->Set(&mCollision);
}

// TODO move this somewhere
template <typename T>
T rndRange(T min, T max) {
f32 r = cM::rndF(max - min);
f32 m = min;
m += r;
return m;
}

void dTgReaction_c::checkForSlingBellowsItem() {
if (mCollision.ChkTgHit()) {
u8 p = getParam0x08();
u32 uVar3;
if (p == 0) {
uVar3 = 6;
} else if (uVar3 == 0xFF) {
uVar3 = 5;
} else {
uVar3 = 6;
if ((int)p == 0xFF) {
uVar3 = 5;
}
}
mVec3_c spawnPos = position;
spawnPos.y += field_0x4E4;
Expand Down Expand Up @@ -287,9 +279,7 @@ bool dTgReaction_c::spawnHearts(s32 params, const mVec3_c &pos, s32 arg, mAng an
tmp2 = mAng(tmp2 / 2);

for (int i = 0; i < numHearts; i++) {
// Note: This is a (presumably templated) rndRange function
// that takes and returns a struct mAng
mAng offset = rndRange(-tmp2, tmp2);
mAng offset = cM::rndRange(-tmp2, tmp2);
ang.y = mAng(step) + offset;
if (arg == 5) {
dAcItem_c::spawnItem(/* HEART */ 0x6, roomid, pos, ang, 0xFFFFFFFF, 1);
Expand Down
5 changes: 2 additions & 3 deletions src/d/a/d_a_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ u32 dAcBase_c::itemDroppingAndGivingRelated(mVec3_c *spawnPos, int subtype) {
u32 param2Copy = params2;
params2 = param2Copy | 0xFF000000;
// mAng3_c rot = {};
s16 rot = 0;
return SpecialItemDropMgr::giveSpecialDropItem(
SpecialItemDropMgr::sInstance, param2Copy >> 0x18, roomid, spawnPos, subtype, &rot, -1
return SpecialItemDropMgr::sInstance->giveSpecialDropItem(
param2Copy >> 0x18, roomid, spawnPos, subtype, 0, -1
);
}

Expand Down
Loading

0 comments on commit aaf88fa

Please sign in to comment.