Fix mAng3_c copy assignment, clean up list node templates

This commit is contained in:
robojumper
2024-06-15 07:50:35 +02:00
parent 20ed99353a
commit 705703e10b
11 changed files with 67 additions and 44 deletions
+4 -4
View File
@@ -61,7 +61,7 @@ public:
/* 0xC0 */ mVec3_c position;
/* 0xCC */ mVec3_c scale;
/* 0xD8 */ u32 actor_properties;
/* 0xDC */ fLiNdBa_c actor_node;
/* 0xDC */ dAcRef_c<dAcBase_c> actor_node;
/* 0xE8 */ u32 field_0xe8;
/* 0xEC */ s8 roomid;
/* 0xED */ u8 actor_subtype;
@@ -117,7 +117,7 @@ public:
return position - other.position;
}
f32 getSquareDistanceTo(const mVec3_c &point) {
f32 getSquareDistanceTo(const mVec3_c &point) const {
mVec3_c diff = position - point;
return diff.x * diff.x + diff.z * diff.z;
}
@@ -155,7 +155,7 @@ public:
// same concept as above
/* 8002d290 */ bool getDistanceAndAngleToActor(dAcBase_c *actor, f32 distThresh, s16 yAngle, s16 xAngle,
f32 *outDist, s16 *outDiffAngleY, s16 *outDiffAngleX);
/* 8002d3e0 */ bool isWithinPlayerRadius(f32 radius);
/* 8002d3e0 */ bool isWithinPlayerRadius(f32 radius) const;
/* 8002d440 */ bool getDistanceAndAngleToPlayer(f32 distThresh, s16 yAngle, s16 xAngle, f32 *outDist,
s16 *outDiffAngleY, s16 *outDiffAngleX);
/* 8002d470 */ f32 getDistToPlayer();
@@ -183,7 +183,7 @@ public:
// End of SoundSource stuff
/* 8002d890 */ void FUN_8002d890();
/* 8002d920 */ void setActorRef(dBase_c *);
/* 8002d920 */ void setActorRef(dAcBase_c *);
// next three funcs are related
/* 8002d930 */ void setEnemyDefeatFlag();
/* 8002d940 */ void changeLoadedEntitiesWithSet();
+1 -1
View File
@@ -16,7 +16,7 @@ public:
/* 800508f0 */ virtual void postExecute(MAIN_STATE_e state);
/* 80050920 */ virtual int preDraw();
/* 80050860 */ virtual void postDraw(MAIN_STATE_e state);
/* 8002c530 */ virtual ~dBase_c();
/* 8002c530 */ virtual ~dBase_c() {}
public:
/* 80050980 */ static void resetFlags();
+3 -7
View File
@@ -6,12 +6,6 @@
#include <s/s_State.hpp>
#include <s/s_StateMgr.hpp>
class fLiNdTumbleweed_c : public fLiNdBaAutoUnlink_c {
public:
fLiNdTumbleweed_c(fBase_c *owner) : fLiNdBaAutoUnlink_c(owner) {}
u16 someField;
};
class dTgTumbleWeed_c : public dTg_c {
public:
dTgTumbleWeed_c() : mStateMgr(*this, sStateID::null), childTumbleweed(nullptr) {}
@@ -35,7 +29,9 @@ private:
u16 tumbleweedTimer;
u16 padding;
u16 windTimer;
fLiNdTumbleweed_c childTumbleweed;
// TODO dAcObjTumbleWeed
dAcRef_c<dAcBase_c> childTumbleweed;
u16 someField;
};
#endif
+23 -2
View File
@@ -28,10 +28,31 @@ public:
fBase_c *p_owner;
};
class fLiNdBaAutoUnlink_c : public fLiNdBa_c {
// TODO unofficial, move these to a more appropriate place
class fLiNdBaAutoUnlink_c : public fLiNdBa_c {
public:
fLiNdBaAutoUnlink_c(fBase_c *owner) : fLiNdBa_c(owner) {}
~fLiNdBaAutoUnlink_c() { unlink(); }
~fLiNdBaAutoUnlink_c() {
unlink();
}
};
template <typename T>
class dAcRef_c : fLiNdBaAutoUnlink_c {
public:
dAcRef_c(T *owner) : fLiNdBaAutoUnlink_c(owner) {}
dAcRef_c() : fLiNdBaAutoUnlink_c(nullptr) {}
~dAcRef_c() {}
void link(T *ref) {
p_owner = ref;
}
void unlink() {
fLiNdBa_c::unlink();
}
T *get() {
return static_cast<T *>(p_owner);
}
};
#endif
+15 -1
View File
@@ -6,7 +6,10 @@
struct mAng {
mAng() {}
mAng(s16 s) : mVal(s) {}
mAng(const mAng &other) : mVal(other.mVal) {}
operator s16() const {
return mVal;
}
s32 step(s16 target, s32 steps, s16 max, s16 min);
s16 mVal;
@@ -18,6 +21,17 @@ public:
mAng3_c(s16 fx, s16 fy, s16 fz) : x(fx), y(fy), z(fz) {}
mAng3_c(const mAng3_c &r) {
*this = r;
}
mAng3_c &operator=(const mAng3_c &r) {
x = r.x;
y = r.y;
z = r.z;
return *this;
}
void set(s16 fx, s16 fy, s16 fz) {
x = fx;
y = fy;