diff --git a/include/SSystem/SComponent/c_bg_s_lin_chk.h b/include/SSystem/SComponent/c_bg_s_lin_chk.h index 1c0b26c4a5..bf71667131 100644 --- a/include/SSystem/SComponent/c_bg_s_lin_chk.h +++ b/include/SSystem/SComponent/c_bg_s_lin_chk.h @@ -36,7 +36,7 @@ public: void SetHit() { mStts |= STTS_HIT; } u32 ChkHit() const { return mStts & STTS_HIT; } void SetCross(const cXyz& pos) { mLin.SetEnd(pos); } - cXyz* GetCrossP() { return &mLin.GetEndP(); } + cXyz* GetCrossP() { return mLin.GetEndP(); } cM3dGLin* GetLinP() { return &mLin; } bool ChkBackFlag() const { return mBackFlag; } void OnBackFlag() { mBackFlag = true; } @@ -45,13 +45,17 @@ public: bool GetPreWallChk() const { return mPreWallChk; } bool GetPreGroundChk() const { return mPreGroundChk; } bool GetPreRoofChk() const { return mPreRoofChk; } - cXyz* GetStartP() { return &mLin.GetStartP(); } + cXyz* GetStartP() { return mLin.GetStartP(); } void ClrSttsRoofOff() { mStts &= ~STTS_ROOF_OFF; } void SetSttsRoofOff() { mStts |= STTS_ROOF_OFF; } void ClrSttsWallOff() { mStts &= ~STTS_WALL_OFF; } void SetSttsWallOff() { mStts |= STTS_WALL_OFF; } void ClrSttsGroundOff() { mStts &= ~STTS_GROUND_OFF; } void SetSttsGroundOff() { mStts |= STTS_GROUND_OFF; } + void ClearCheckIndex() { ClearPi(); } + bool ChkSttsWallOff() const { return (mStts & STTS_WALL_OFF); } + bool ChkSttsGroundOff() const { return (mStts & STTS_GROUND_OFF); } + bool ChkSttsRoofOff() const { return (mStts & STTS_ROOF_OFF); } }; #endif /* C_BG_S_LIN_CHK_H */ diff --git a/include/SSystem/SComponent/c_cc_d.h b/include/SSystem/SComponent/c_cc_d.h index 141dd33bad..66c71a4ead 100644 --- a/include/SSystem/SComponent/c_cc_d.h +++ b/include/SSystem/SComponent/c_cc_d.h @@ -188,6 +188,7 @@ public: cXyz* GetCCMoveP() { return &m_cc_move; } fpc_ProcID GetApid() const { return m_apid; } u8 GetDmg() const { return m_dmg; } + void ClrCo() { ClrCcMove(); } }; // Size = 0x1C STATIC_ASSERT(0x1C == sizeof(cCcD_Stts)); @@ -213,7 +214,7 @@ public: void ct(); void SetSPrm(u32 sprm) { mSPrm = sprm; } s32 getSPrm() const { return mSPrm; } - void setRPrm(s32 rprm) { mRPrm = rprm; } + void SetRPrm(u32 rprm) { mRPrm = rprm; } s32 getRPrm() const { return mRPrm; } cCcD_Obj* GetHitObj() { return mHitObj; } const cCcD_Obj* GetHitObj() const { return mHitObj; } @@ -222,6 +223,9 @@ public: void OnSPrmBit(u32 flag) { mSPrm |= flag; } void OffSPrmBit(u32 flag) { mSPrm &= ~flag; } u32 ChkSPrm(u32 prm) const { return MskSPrm(prm) != 0; } + void SetHitObj(cCcD_Obj* pobj) { mHitObj = pobj; } + void ClrRPrm(u32 prm) { mRPrm &= ~prm; } + void ClrObj() { mHitObj = NULL; } void Set(cCcD_SrcObjCommonBase const& src) { mSPrm = src.mSPrm; } }; @@ -240,7 +244,7 @@ public: void ClrHit(); int GetType() const { return mType; } u32 GetGrp() const { return MskSPrm(0x1E); } - bool ChkSet() const { return MskSPrm(1); } + BOOL ChkSet() const { return MskSPrm(1); } u8 GetAtp() const { return mAtp; } u32 MskType(u32 msk) const { return mType & msk; } void SetType(u32 type) { mType = type; } @@ -269,7 +273,7 @@ public: int GetType() const { return mType; } void SetType(u32 type) { mType = type; } u32 GetGrp() const { return MskSPrm(0x1E); } - bool ChkSet() const { return MskSPrm(1); } + BOOL ChkSet() const { return MskSPrm(1); } void ClrSet() { OffSPrmBit(1); } u32 ChkHit() const { return MskRPrm(1); } @@ -289,7 +293,7 @@ public: void SetIGrp(u32); void SetVsGrp(u32); u32 GetGrp() const { return MskSPrm(0x1E); } - bool ChkSet() const { return MskSPrm(1); } + BOOL ChkSet() const { return MskSPrm(1); } u32 GetVsGrp() const { return MskSPrm(0x70); } u32 GetIGrp() const { return MskSPrm(0xE); } u32 ChkNoCrr() const { return MskSPrm(0x100); } @@ -323,10 +327,10 @@ public: u32 GetCoGrp() const { return mObjCo.GetGrp(); } int GetTgType() const { return mObjTg.GetType(); } u32 GetAtType() const { return mObjAt.GetType(); } - bool ChkTgSet() const { return mObjTg.ChkSet(); } - bool ChkAtSet() const { return mObjAt.ChkSet(); } - bool ChkCoSet() const { return mObjCo.ChkSet(); } - u32 ChkCoSameActorHit() const { return mObjCo.ChkCoSameActorHit(); } + BOOL ChkTgSet() const { return mObjTg.ChkSet(); } + BOOL ChkAtSet() const { return mObjAt.ChkSet(); } + BOOL ChkCoSet() const { return mObjCo.ChkSet(); } + u32 ChkCoSameActorHit() { return mObjCo.MskSPrm(0x400); } void OnCoSameActorHit() { mObjCo.OnCoSameActorHit(); } void OffCoSameActorHit() { mObjCo.OffCoSameActorHit(); } u32 GetCoVsGrp() const { return mObjCo.GetVsGrp(); } @@ -334,8 +338,8 @@ public: u8 GetAtAtp() const { return mObjAt.GetAtp(); } u32 ChkAtNoTgHitInfSet() const { return mObjAt.MskSPrm(0x20); } u32 ChkTgNoAtHitInfSet() const { return mObjTg.MskSPrm(0x20); } - u32 ChkCoNoCoHitInfSet() const { return mObjCo.MskSPrm(0x200); } - bool ChkTgNoSlingHitInfSet() const { return mObjTg.MskSPrm(0x40); } + u32 ChkCoNoCoHitInfSet() { return mObjCo.MskSPrm(0x200); } + BOOL ChkTgNoSlingHitInfSet() { return mObjTg.MskSPrm(0x40); } void SetAtHit(cCcD_Obj* obj) { mObjAt.SetHit(obj); } void SetTgHit(cCcD_Obj* obj) { mObjTg.SetHit(obj); } void SetCoHit(cCcD_Obj* obj) { mObjCo.SetHit(obj); } @@ -430,7 +434,6 @@ public: /* vt[21]*/ virtual void getShapeAccess(cCcD_ShapeAttr::Shape*) const; cM3dGAab& GetWorkAab() { return mAab; } - cM3dGAab const& GetWorkAab() const { return mAab; } static cXyz m_virtual_center; }; @@ -456,7 +459,7 @@ public: void SetStts(cCcD_Stts* stts) { mStts = stts; } cCcD_DivideInfo& GetDivideInfo() { return mDivideInfo; } cCcD_DivideInfo* GetPDivideInfo() { return &mDivideInfo; } - int ChkBsRevHit() const { return mFlags & 2; } + int ChkBsRevHit() { return mFlags & 2; } private: /* 0x040 */ int mFlags; diff --git a/include/SSystem/SComponent/c_cc_s.h b/include/SSystem/SComponent/c_cc_s.h index 334f7351d8..4bdf70efd5 100644 --- a/include/SSystem/SComponent/c_cc_s.h +++ b/include/SSystem/SComponent/c_cc_s.h @@ -16,7 +16,7 @@ public: /* 0x1000 */ cCcD_Obj* mpObjCo[0x100]; /* 0x1400 */ cCcD_Obj* mpObj[0x500]; #if DEBUG - /* 0x2800 */ int m_debug_code; + /* 0x2800 */ u32 m_debug_code; #endif /* 0x2800 */ u16 mObjAtCount; /* 0x2802 */ u16 mObjTgCount; diff --git a/include/SSystem/SComponent/c_m3d_g_aab.h b/include/SSystem/SComponent/c_m3d_g_aab.h index b070e776eb..a685efb007 100644 --- a/include/SSystem/SComponent/c_m3d_g_aab.h +++ b/include/SSystem/SComponent/c_m3d_g_aab.h @@ -18,25 +18,25 @@ public: bool CrossY(const cXyz*) const; bool UnderPlaneYUnder(f32) const; bool TopPlaneYUnder(f32) const; - void ClearForMinMax(void); + void ClearForMinMax(); void SetMinMax(const cXyz&); void SetMinMax(const cM3dGAab&); void SetMin(const cXyz&); void SetMax(const cXyz&); void CalcCenter(cXyz*) const; void PlusR(f32); - const cXyz* GetMaxP(void) const { return &mMax; } - cXyz* GetMaxP(void) { return &mMax; } - const cXyz* GetMinP(void) const { return &mMin; } - cXyz* GetMinP(void) { return &mMin; } - const f32 GetMaxX(void) const { return mMax.x; } - const f32 GetMaxY(void) const { return mMax.y; } - const f32 GetMaxZ(void) const { return mMax.z; } - const f32 GetMinX(void) const { return mMin.x; } - const f32 GetMinY(void) const { return mMin.y; } - const f32 GetMinZ(void) const { return mMin.z; } + const cXyz* GetMaxP() const { return &mMax; } + cXyz* GetMaxP() { return &mMax; } + const cXyz* GetMinP() const { return &mMin; } + cXyz* GetMinP() { return &mMin; } + const f32 GetMaxX() const { return mMax.x; } + const f32 GetMaxY() const { return mMax.y; } + const f32 GetMaxZ() const { return mMax.z; } + const f32 GetMinX() const { return mMin.x; } + const f32 GetMinY() const { return mMin.y; } + const f32 GetMinZ() const { return mMin.z; } bool Cross(const cM3dGLin *param_1) const { - return cM3d_Cross_MinMaxBoxLine(GetMinP(), GetMaxP(), (Vec*)¶m_1->GetStartP(), (Vec*)¶m_1->GetEndP()); + return cM3d_Cross_MinMaxBoxLine(GetMinP(), GetMaxP(), param_1->GetStartP(), param_1->GetEndP()); } bool Cross(const cM3dGAab *param_1) const { return cM3d_Cross_AabAab(this, param_1); diff --git a/include/SSystem/SComponent/c_m3d_g_cps.h b/include/SSystem/SComponent/c_m3d_g_cps.h index 5147e02114..f24b352dae 100644 --- a/include/SSystem/SComponent/c_m3d_g_cps.h +++ b/include/SSystem/SComponent/c_m3d_g_cps.h @@ -3,6 +3,7 @@ #include "SSystem/SComponent/c_m3d.h" #include "SSystem/SComponent/c_m3d_g_lin.h" +#include "SSystem/SComponent/c_m3d_g_tri.h" struct cM3dGCpsS { /* 0x00 */ Vec mStart; @@ -14,8 +15,8 @@ class cM3dGCps : public cM3dGLin { public: /* 0x1C */ f32 mRadius; - cM3dGCps(void); - virtual ~cM3dGCps(void); + cM3dGCps(); + virtual ~cM3dGCps(); void Set(const cXyz&, const cXyz&, f32); void Set(const cM3dGCpsS&); void SetCps(const cM3dGCps&); @@ -24,6 +25,7 @@ public: } bool Cross(cM3dGCyl const* cyl, cXyz* xyz) const { return cM3d_Cross_CpsCyl(*this, *cyl, xyz); } bool Cross(cM3dGSph const* sph, cXyz* xyz) const { return cM3d_Cross_CpsSph(*this, *sph, xyz); } + bool Cross(cM3dGTri const& tri, cXyz* xyz) const { return cM3d_Cross_CpsTri(*this, tri, xyz); } void SetR(f32 r) { mRadius = r; } f32 GetR() const { return mRadius; } diff --git a/include/SSystem/SComponent/c_m3d_g_cyl.h b/include/SSystem/SComponent/c_m3d_g_cyl.h index 5d5f3a395b..4983084d83 100644 --- a/include/SSystem/SComponent/c_m3d_g_cyl.h +++ b/include/SSystem/SComponent/c_m3d_g_cyl.h @@ -40,8 +40,8 @@ public: bool Cross(const cM3dGCps* cps, cXyz* xyz) const { return cM3d_Cross_CpsCyl(*cps, *this, xyz); } bool Cross(const cM3dGTri& tri, cXyz* xyz) const { return cM3d_Cross_CylTri(this, &tri, xyz); } - bool Cross(const cM3dGCyl* other, f32* f) const { return cM3d_Cross_CylCyl(this, other, f); } - bool Cross(const cM3dGSph* sph, f32* f) const { return cM3d_Cross_CylSph(this, sph, f); } + bool cross(const cM3dGCyl* other, f32* f) const { return cM3d_Cross_CylCyl(this, other, f); } + bool cross(const cM3dGSph* sph, f32* f) const { return cM3d_Cross_CylSph(this, sph, f); } }; // Size = 0x18 STATIC_ASSERT(0x18 == sizeof(cM3dGCyl)); diff --git a/include/SSystem/SComponent/c_m3d_g_lin.h b/include/SSystem/SComponent/c_m3d_g_lin.h index d6b86ebcf0..fbe65d9b33 100644 --- a/include/SSystem/SComponent/c_m3d_g_lin.h +++ b/include/SSystem/SComponent/c_m3d_g_lin.h @@ -22,13 +22,13 @@ public: void SetEnd(const cXyz&); void set(const Vec& i_start, const Vec& i_end) { SetStartEnd(i_start, i_end); } - const cXyz& GetStartP(void) const { return mStart; } - cXyz& GetStartP(void) { return mStart; } + const cXyz* GetStartP() const { return &mStart; } + cXyz* GetStartP() { return &mStart; } cXyz& GetStart() { return mStart; } const cXyz& GetStart() const { return mStart; } - const cXyz& GetEndP(void) const { return mEnd; } - cXyz& GetEndP(void) { return mEnd; } + const cXyz* GetEndP() const { return &mEnd; } + cXyz* GetEndP() { return &mEnd; } cXyz& GetEnd() { return mEnd; } const cXyz& GetEnd() const { return mEnd; } f32 GetLen() const { return PSVECDistance(&mStart, &mEnd); } diff --git a/include/SSystem/SComponent/c_m3d_g_sph.h b/include/SSystem/SComponent/c_m3d_g_sph.h index b8f868b8a5..9a9248d0a4 100644 --- a/include/SSystem/SComponent/c_m3d_g_sph.h +++ b/include/SSystem/SComponent/c_m3d_g_sph.h @@ -39,9 +39,10 @@ public: f32 GetCY(void) const { return mCenter.y; } f32 GetCZ(void) const { return mCenter.z; } - bool Cross(const cM3dGSph* other, f32* f) const { return cM3d_Cross_SphSph(this, other, f); } + bool cross(const cM3dGSph* other, f32* f) const { return cM3d_Cross_SphSph(this, other, f); } bool Cross(const cM3dGCps* cps, cXyz* xyz) const { return cM3d_Cross_CpsSph(*cps, *this, xyz); } - bool Cross(const cM3dGCyl* cyl, f32* f) const { return cM3d_Cross_CylSph(cyl, this, f); } + bool cross(const cM3dGCyl* cyl, f32* f) const { return cM3d_Cross_CylSph(cyl, this, f); } + bool Cross(const cM3dGTri& tri, cXyz* xyz) const { return cM3d_Cross_SphTri(this, &tri, xyz); } }; // Size = 0x14 STATIC_ASSERT(0x14 == sizeof(cM3dGSph)); diff --git a/include/SSystem/SComponent/c_m3d_g_tri.h b/include/SSystem/SComponent/c_m3d_g_tri.h index ff780046b8..cac178e064 100644 --- a/include/SSystem/SComponent/c_m3d_g_tri.h +++ b/include/SSystem/SComponent/c_m3d_g_tri.h @@ -26,10 +26,10 @@ public: void setPos(const Vec*, const Vec*, const Vec*); void setBg(const Vec*, const Vec*, const Vec*, const cM3dGPla*); void set(const Vec*, const Vec*, const Vec*, const Vec*); - bool Cross(cM3dGCps const& cps, cXyz* xyz) const { return cM3d_Cross_CpsTri(cps, *this, xyz); } - bool Cross(cM3dGCyl const& cyl, cXyz* xyz) const { return this->cross(&cyl, xyz); } - bool Cross(cM3dGSph const& sph, cXyz* xyz) const { return cM3d_Cross_SphTri(&sph, this, xyz); } - bool Cross(cM3dGTri const& other, cXyz* xyz) const { + bool Cross(cM3dGCps const& cps, Vec* xyz) const { return cM3d_Cross_CpsTri(cps, *this, xyz); } + bool Cross(cM3dGCyl const& cyl, Vec* xyz) const { return this->cross(&cyl, xyz); } + bool Cross(cM3dGSph const& sph, Vec* xyz) const { return cM3d_Cross_SphTri(&sph, this, xyz); } + bool Cross(cM3dGTri const& other, Vec* xyz) const { return cM3d_Cross_TriTri(*this, other, xyz); } bool cross(const cM3dGLin* lin, Vec* xyz, bool param_2, bool param_3) const { diff --git a/include/d/actor/d_a_e_hz.h b/include/d/actor/d_a_e_hz.h index 7e5902e016..539d808cf5 100644 --- a/include/d/actor/d_a_e_hz.h +++ b/include/d/actor/d_a_e_hz.h @@ -87,7 +87,7 @@ private: /* 0x6B4 */ s16 field_0x6b4; /* 0x6B6 */ s16 field_0x6b6; /* 0x6B8 */ u8 field_0x6B8[0x6BC - 0x6B8]; - /* 0x6BC */ char* mpName; + /* 0x6BC */ const char* mpName; /* 0x6C0 */ s32 mAction; /* 0x6C4 */ s32 mPrevAction; /* 0x6C8 */ s32 mMode; // That's just a guess. Might need a better name for it's usage diff --git a/include/d/actor/d_a_npc2.h b/include/d/actor/d_a_npc2.h index ea5548696a..d1d06d7764 100644 --- a/include/d/actor/d_a_npc2.h +++ b/include/d/actor/d_a_npc2.h @@ -134,7 +134,7 @@ public: /* 0x842 */ u16 field_0x842; /* 0x844 */ u8 field_0x844; /* 0x845 */ u8 field_0x845[0x848 - 0x845]; - /* 0x848 */ s32 field_0x848; + /* 0x848 */ s32 mFlowID; /* 0x84C */ dMsgFlow_c mMsgFlow; /* 0x898 */ u8 field_0x898[0x89A - 0x898]; /* 0x89A */ s16 mEvtIdx; diff --git a/include/d/actor/d_a_npc_bouS.h b/include/d/actor/d_a_npc_bouS.h index bd3b1ff0b6..27eafb48fd 100644 --- a/include/d/actor/d_a_npc_bouS.h +++ b/include/d/actor/d_a_npc_bouS.h @@ -72,7 +72,7 @@ public: void setExpression(int, f32); bool talk(void*); bool demo(void*); - inline fopAc_ac_c* searchInstructionTag(); + inline fopAc_ac_c* searchInstructionTag(); bool instruction(void*); bool checkIntroDemoStart(); int EvCut_BousIntroSumo1(int); diff --git a/include/d/actor/d_a_npc_gra.h b/include/d/actor/d_a_npc_gra.h index 3209329a76..236755aba7 100644 --- a/include/d/actor/d_a_npc_gra.h +++ b/include/d/actor/d_a_npc_gra.h @@ -160,7 +160,7 @@ private: /* 0x14B0 */ int field_0x1460; /* 0x1464 */ int field_0x1464; /* 0x1468 */ int field_0x1468; - /* 0x146C */ int field_0x146C; + /* 0x146C */ int mFlowID; /* 0x1470 */ s16 mLookMode; /* 0x1472 */ u16 field_0x1472; /* 0x1474 */ u8 mType; diff --git a/include/d/actor/d_a_npc_grs.h b/include/d/actor/d_a_npc_grs.h index 202dd25267..d2a0c5359d 100644 --- a/include/d/actor/d_a_npc_grs.h +++ b/include/d/actor/d_a_npc_grs.h @@ -103,7 +103,7 @@ private: /* 0xE00 */ int field_0xe00; /* 0xE04 */ int field_0xe04; /* 0xE08 */ int field_0xe08; - /* 0xE0C */ int field_0xe0c; + /* 0xE0C */ int mFlowID; /* 0xE10 */ s16 mLookMode; /* 0xE12 */ u16 mActionState; /* 0xE14 */ u8 mType; diff --git a/include/d/actor/d_a_npc_gwolf.h b/include/d/actor/d_a_npc_gwolf.h index adcdb75adb..fcf5d804d0 100644 --- a/include/d/actor/d_a_npc_gwolf.h +++ b/include/d/actor/d_a_npc_gwolf.h @@ -121,7 +121,7 @@ private: /* 0xDFC */ int field_0xdfc; /* 0xE00 */ int field_0xe00; /* 0xE04 */ int field_0xe04; - /* 0xE08 */ int field_0xe08; + /* 0xE08 */ int mFlowID; /* 0xE0C */ s16 mLookMode; /* 0xE0E */ u16 mMode; /* 0xE10 */ u8 mType; diff --git a/include/d/actor/d_a_npc_kasi_hana.h b/include/d/actor/d_a_npc_kasi_hana.h index 54b0cf914b..e355ed8c55 100644 --- a/include/d/actor/d_a_npc_kasi_hana.h +++ b/include/d/actor/d_a_npc_kasi_hana.h @@ -182,7 +182,8 @@ public: s16 getMessageNo() { return s16(home.angle.x); } s8 getType() { s8 rv = fopAcM_GetParam(this) & 0xFF; - + + // !@bug Comparison of s8 with 0xFF will always evaluate to false if (rv == 0xFF) { rv = 0; } diff --git a/include/d/actor/d_a_npc_kasi_kyu.h b/include/d/actor/d_a_npc_kasi_kyu.h index 9ca549e46c..0387c563b7 100644 --- a/include/d/actor/d_a_npc_kasi_kyu.h +++ b/include/d/actor/d_a_npc_kasi_kyu.h @@ -98,7 +98,8 @@ public: s8 getType() { s8 rv = fopAcM_GetParam(this) & 0xFF; - + + // !@bug Comparison of s8 with 0xFF will always evaluate to false if (rv == 0xFF) { rv = 0; } diff --git a/include/d/actor/d_a_npc_kasi_mich.h b/include/d/actor/d_a_npc_kasi_mich.h index 9f38d3dd1c..e3782f1b27 100644 --- a/include/d/actor/d_a_npc_kasi_mich.h +++ b/include/d/actor/d_a_npc_kasi_mich.h @@ -99,7 +99,8 @@ public: s8 getType() { s8 rv = fopAcM_GetParam(this) & 0xFF; - + + // !@bug Comparison of s8 with 0xFF will always evaluate to false if (rv == 0xFF) { rv = 0; } diff --git a/include/d/actor/d_a_npc_kn.h b/include/d/actor/d_a_npc_kn.h index a14a89aefe..e97431baef 100644 --- a/include/d/actor/d_a_npc_kn.h +++ b/include/d/actor/d_a_npc_kn.h @@ -77,7 +77,7 @@ public: class daNpc_Kn_prtclMngr_c { public: - /* 0x00 */ bool mpModel; + /* 0x00 */ bool field_0x00; /* 0x04 */ cXyz mPos; /* 0x10 */ csXyz mAngle; /* 0x18 */ cXyz mScale; diff --git a/include/d/actor/d_a_npc_ks.h b/include/d/actor/d_a_npc_ks.h index ba14540735..7ec5fd129d 100644 --- a/include/d/actor/d_a_npc_ks.h +++ b/include/d/actor/d_a_npc_ks.h @@ -89,7 +89,7 @@ public: /* 0x5B7 */ u8 field_0x5b7; /* 0x5B8 */ int order; /* 0x5BC */ int bitTRB; - /* 0x5C0 */ char* res_name; + /* 0x5C0 */ const char* res_name; /* 0x5C4 */ f32 dis; /* 0x5C8 */ s16 target_angle; /* 0x5CC */ mDoExt_McaMorfSO* model; diff --git a/include/d/actor/d_a_npc_myna2.h b/include/d/actor/d_a_npc_myna2.h index bf97f43124..ac6af4d8f7 100644 --- a/include/d/actor/d_a_npc_myna2.h +++ b/include/d/actor/d_a_npc_myna2.h @@ -104,7 +104,7 @@ public: /* 0xDF8 */ int field_0xdf8; /* 0xDFC */ int field_0xdfc; /* 0xE00 */ int field_0xe00; - /* 0xE04 */ int field_0xe04; + /* 0xE04 */ int mFlowID; /* 0xE08 */ s16 mLookMode; /* 0xE0A */ u16 mMode; /* 0xE0C */ u8 mType; diff --git a/include/d/actor/d_a_npc_ne.h b/include/d/actor/d_a_npc_ne.h index 10474cc828..51f9f06e81 100644 --- a/include/d/actor/d_a_npc_ne.h +++ b/include/d/actor/d_a_npc_ne.h @@ -95,7 +95,7 @@ public: /* 0x5D8 */ f32 mDistToTarget; /* 0x5DC */ s16 mAngleToPlayer; /* 0x5E0 */ f32 mDistScale; - /* 0x5E4 */ char* mResName; + /* 0x5E4 */ const char* mResName; /* 0x5E8 */ mDoExt_McaMorf* mpMorf; /* 0x5EC */ mDoExt_btkAnm* mpBtkAnm; /* 0x5F0 */ mDoExt_btpAnm* mpBtpAnm; diff --git a/include/d/actor/d_a_tag_push.h b/include/d/actor/d_a_tag_push.h index 3a20b5ed77..a1f0b75b22 100644 --- a/include/d/actor/d_a_tag_push.h +++ b/include/d/actor/d_a_tag_push.h @@ -24,6 +24,9 @@ public: u8 getBitSW2() { return (fopAcM_GetParam(this) & 0xFF00) >> 8; } u32 getFlowNodeNo() { + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { return (u16)home.angle.x; } diff --git a/include/d/actor/d_a_tag_shop_item.h b/include/d/actor/d_a_tag_shop_item.h index 826f867ad8..1b04b6ef8e 100644 --- a/include/d/actor/d_a_tag_shop_item.h +++ b/include/d/actor/d_a_tag_shop_item.h @@ -19,6 +19,10 @@ public: u32 getProcessID() { return mProcessID; } + int getFlowNodeNum() { + return (u16)home.angle.x == 0xFFFF ? -1 : (u16)home.angle.x; + } + /* 0x56C */ u32 mProcessID; /* 0x570 */ s16 mCreateTimer; /* 0x572 */ u8 field_0x572; diff --git a/include/d/d_cc_d.h b/include/d/d_cc_d.h index 7c6b438a4d..1d9b4b5a93 100644 --- a/include/d/d_cc_d.h +++ b/include/d/d_cc_d.h @@ -144,7 +144,7 @@ public: void ClrEffCounter() { mEffCounter = 0; } u32 GetGFlag() const { return mGFlag; } u32 GetRPrm() const { return mRPrm; } - u32 MskSPrm(u32 mask) const { return mGFlag & mask; } + u32 MskSPrm(u32 mask) { return mGFlag & mask; } u32 MskRPrm(u32 mask) const { return mRPrm & mask; } bool ChkSPrm(u32 mask) { return MskSPrm(mask); } void OnSPrm(u32 flag) { mGFlag |= flag; } @@ -173,7 +173,7 @@ public: u8 GetSe() { return mSe; } dCcG_At_Spl GetSpl() { return (dCcG_At_Spl)mSpl; } u8 GetMtrl() { return mMtrl; } - u8 GetHitMark() { return mHitMark; } + int GetHitMark() { return mHitMark; } void SetRVec(cXyz& vec) { mRVec = vec; } void SetHitPos(cXyz& pos) { mHitPos = pos; } cXyz* GetHitPosP() { return &mHitPos; } @@ -203,10 +203,10 @@ public: void SetHitMark(CcG_Tg_HitMark mark) { mHitMark = mark; } s16* GetShieldFrontRangeYAngle() { return mShieldFrontRangeYAngle; } s16 GetShieldRange() { return mShieldRange; } - u8 GetSpl() { return mSpl; } + int GetSpl() { return mSpl; } void SetSpl(dCcG_Tg_Spl tg_spl) { mSpl = tg_spl; } void SetSpl(u8 tg_spl) { mSpl = tg_spl; } - u8 GetHitMark() { return mHitMark; } + int GetHitMark() { return mHitMark; } void SetRVec(cXyz& vec) { mRVec = vec; } cXyz* GetVecP() { return &mVec; } cXyz* GetRVecP() { return &mRVec; } @@ -250,7 +250,7 @@ public: void SetRoomId(int id) { mRoomId = id; } fpc_ProcID GetAtOldApid() { return mAtOldApid; } fpc_ProcID GetTgOldApid() { return mTgOldApid; } - bool ChkNoActor() { return field_0x1C & 1;} + BOOL ChkNoActor() { return field_0x1C & 1;} bool ChkNoneActorPerfTblId() { return field_0x08 == 0xFFFF; } dCcG_At_Spl GetAtSpl() { return (dCcG_At_Spl)mAt; } void SetAtSpl(dCcG_At_Spl spl) { mAt = spl; } diff --git a/include/d/d_cc_mass_s.h b/include/d/d_cc_mass_s.h index c5d6186014..672adb913a 100644 --- a/include/d/d_cc_mass_s.h +++ b/include/d/d_cc_mass_s.h @@ -9,7 +9,7 @@ class dCcMassS_Obj { private: /* 0x00 */ cCcD_Obj* mpObj; /* 0x04 */ u8 mPriority; - /* 0x08 */ dCcMassS_ObjCallback mpCallback; + /* 0x08 */ dCcMassS_ObjCallback mpAreaCheckFunc; /* 0x0C */ cCcD_DivideInfo mDivideInfo; /* 0x1C vtable */ @@ -19,10 +19,10 @@ public: void Set(cCcD_Obj* p_obj, u8 priority, dCcMassS_ObjCallback callback); void Clear(); - cCcD_Obj* GetObj() { return mpObj; } + cCcD_Obj* GetObj() const { return mpObj; } u8 GetPriority() const { return mPriority; } - dCcMassS_ObjCallback GetCallback() const { return mpCallback; } - cCcD_DivideInfo& GetDivideInfo() { return mDivideInfo; } + dCcMassS_ObjCallback GetAreaCheckFunc() const { return mpAreaCheckFunc; } + cCcD_DivideInfo* GetPDivideInfo() { return &mDivideInfo; } }; // Size = 0x20 STATIC_ASSERT(0x20 == sizeof(dCcMassS_Obj)); diff --git a/include/d/d_cc_s.h b/include/d/d_cc_s.h index dbd3c18285..b4d90787ae 100644 --- a/include/d/d_cc_s.h +++ b/include/d/d_cc_s.h @@ -44,6 +44,16 @@ public: virtual void MoveAfterCheck(); virtual void CalcParticleAngle(dCcD_GObjInf*, cCcD_Stts*, cCcD_Stts*, csXyz*); + #if DEBUG + void OnMassAllTimer() { + m_is_mass_all_timer = 1; + } + + void OffMassAllTimer() { + m_is_mass_all_timer = 0; + } + #endif + void SetMass(cCcD_Obj* i_obj, u8 i_priority) { mMass_Mng.Set(i_obj, i_priority); } void SetMassCam(cM3dGCps& i_cps) { mMass_Mng.SetCam(i_cps); } u32 GetMassResultCam() { return mMass_Mng.GetResultCam(); } @@ -70,7 +80,7 @@ public: // /* 0x0000 */ cCcS mCCcS; /* 0x284C */ dCcMassS_Mng mMass_Mng; #if DEBUG - /* 0x2AD0 */ u8 field_0x2ad0; + /* 0x2AD0 */ u8 m_is_mass_all_timer; #endif }; // Size = 0x2AC4 diff --git a/include/d/d_demo.h b/include/d/d_demo.h index 9b9d2325ac..e72698ed9a 100644 --- a/include/d/d_demo.h +++ b/include/d/d_demo.h @@ -340,27 +340,6 @@ public: virtual JPABaseEmitter* emitter_create(u32); }; -namespace { -class jstudio_tAdaptor_message : public JStudio::TAdaptor_message { -public: - typedef JStudio::TObject_message ObjectType; - - jstudio_tAdaptor_message() {} - - virtual ~jstudio_tAdaptor_message(); - virtual void adaptor_do_MESSAGE(JStudio::data::TEOperationData, const void*, u32); -}; - -class jstudio_tCreateObject_message : public JStudio::TCreateObject { -public: - jstudio_tCreateObject_message() {} - - virtual ~jstudio_tCreateObject_message(); - virtual bool create(JStudio::TObject**, const JStudio::stb::data::TParse_TBlock_object&); -}; - -}; // namespace - int dDemo_setDemoData(fopAc_ac_c*, u8, mDoExt_McaMorf*, char const*, int, u16*, u32, s8); class dDemo_c { @@ -409,7 +388,7 @@ public: static JStudio_JStage::TCreateObject* m_stage; static JStudio_JAudio2::TCreateObject* m_audio; static dDemo_particle_c* m_particle; - static jstudio_tCreateObject_message* m_message; + static JStudio::TCreateObject* m_message; static JStudio::TFactory* m_factory; static jmessage_tControl* m_mesgControl; static dDemo_object_c* m_object; diff --git a/include/d/d_jnt_col.h b/include/d/d_jnt_col.h index c239bf8a69..cc67b7104d 100644 --- a/include/d/d_jnt_col.h +++ b/include/d/d_jnt_col.h @@ -33,7 +33,7 @@ public: void offPassNum(int num) { field_0xc &= ~(1 << num); } bool checkShieldType(int i) { return getType(i) == 3; } - s8 getType(int i) { return mData[i].mType; } + int getType(int i) { return mData[i].mType; } int getJntNum(int i) { return (s16)mData[i].mJntNum; } /* 0x00 */ const dJntColData_c* mData; @@ -64,4 +64,9 @@ public: }; +#if DEBUG +void dJntCol_setDebugHIO(); +void dJntCol_deleteDebugHIO(); +#endif + #endif /* D_D_JNT_COL_H */ diff --git a/include/d/d_menu_window.h b/include/d/d_menu_window.h index 35c6789127..65e415077d 100644 --- a/include/d/d_menu_window.h +++ b/include/d/d_menu_window.h @@ -190,7 +190,7 @@ public: bool isPauseWindow() { return mPauseWindow != false; } void onShowFlag() { mShowFlag |= 1; } void offShowFlag() { mShowFlag &= ~1; } - bool isShowFlag() { return mShowFlag & 1 != 0; } + bool isShowFlag() { return (mShowFlag & 1) != 0; } bool isFadeNowCheck() { return mDoGph_gInf_c::getFader()->getStatus() == 1; } private: diff --git a/include/d/d_msg_scrn_howl.h b/include/d/d_msg_scrn_howl.h index aa51249e17..bf28682d42 100644 --- a/include/d/d_msg_scrn_howl.h +++ b/include/d/d_msg_scrn_howl.h @@ -112,7 +112,4 @@ struct dMsgScrnHowl_c : public dMsgScrnBase_c { /* 0x27A8 */ f32 field_0x27a8; }; -#define LINE_MAX 30 -#define PLOT_BUFFER_MAX_e 0x300 - #endif /* MSG_SCRN_D_MSG_SCRN_HOWL_H */ diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 2251a23aea..5b11f0e57a 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -437,11 +437,11 @@ inline void fopAcM_SetAngle(fopAc_ac_c* i_actor, s16 x, s16 y, s16 z) { i_actor->current.angle.set(x, y, z); } -inline void dComIfGs_onSwitch(int i_no, int i_roomNo); -inline void dComIfGs_offSwitch(int i_no, int i_roomNo); -inline void dComIfGs_revSwitch(int i_no, int i_roomNo); -inline BOOL dComIfGs_isSwitch(int i_no, int i_roomNo); -inline void dComIfGs_offActor(int i_no, int i_roomNo); +void dComIfGs_onSwitch(int i_no, int i_roomNo); +void dComIfGs_offSwitch(int i_no, int i_roomNo); +void dComIfGs_revSwitch(int i_no, int i_roomNo); +BOOL dComIfGs_isSwitch(int i_no, int i_roomNo); +void dComIfGs_offActor(int i_no, int i_roomNo); inline void fopAcM_onSwitch(const fopAc_ac_c* i_actor, int sw) { return dComIfGs_onSwitch(sw, fopAcM_GetHomeRoomNo(i_actor)); @@ -463,12 +463,12 @@ inline fopAc_ac_c* fopAcM_SearchByName(s16 proc_id) { return (fopAc_ac_c*)fopAcIt_Judge(fpcSch_JudgeForPName, &proc_id); } -inline void dComIfGs_onItem(int bitNo, int roomNo); +void dComIfGs_onItem(int bitNo, int roomNo); inline void fopAcM_onItem(const fopAc_ac_c* item, int bitNo) { dComIfGs_onItem(bitNo, fopAcM_GetHomeRoomNo(item)); } -inline bool dComIfGs_isItem(int bitNo, int roomNo); +bool dComIfGs_isItem(int bitNo, int roomNo); inline bool fopAcM_isItem(const fopAc_ac_c* item, int bitNo) { return dComIfGs_isItem(bitNo, fopAcM_GetHomeRoomNo(item)); } @@ -481,7 +481,7 @@ inline int fopAcM_GetSetId(const fopAc_ac_c* i_actor) { return i_actor->setID; } -inline void dComIfGs_onActor(int bitNo, int roomNo); +void dComIfGs_onActor(int bitNo, int roomNo); inline void fopAcM_onActor(const fopAc_ac_c* i_actor) { dComIfGs_onActor(fopAcM_GetSetId(i_actor), fopAcM_GetHomeRoomNo(i_actor)); @@ -716,7 +716,7 @@ inline void make_prm_warp_hole(u32* o_params, u8 prm1, u8 prm2, u8 prm3) { *o_params = pprm2 | pprm3 | pprm1; } -inline fopAc_ac_c* dComIfGp_getPlayer(int); +fopAc_ac_c* dComIfGp_getPlayer(int); inline s16 fopAcM_searchPlayerAngleY(const fopAc_ac_c* actor) { return fopAcM_searchActorAngleY(actor, dComIfGp_getPlayer(0)); diff --git a/include/global.h b/include/global.h index 375b92de1a..3501627dff 100644 --- a/include/global.h +++ b/include/global.h @@ -130,7 +130,7 @@ static const float INF = 2000000000.0f; #define NO_INLINE #endif #endif - + // Hack to trick the compiler into not inlining functions that use this macro. #define FORCE_DONT_INLINE \ (void*)0; (void*)0; (void*)0; (void*)0; (void*)0; (void*)0; (void*)0; (void*)0; (void*)0; (void*)0; \ @@ -200,4 +200,15 @@ static const float INF = 2000000000.0f; using std::isnan; #endif +// Comparing a non-volatile reference type to NULL is tautological +// and triggers a warning on modern compilers, but in some cases is +// required to match the original assembly. +#if defined(__MWERKS__) || defined(DECOMPCTX) +#define IS_REF_NULL(r) (&(r) == NULL) +#define IS_REF_NONNULL(r) (&(r) != NULL) +#else +#define IS_REF_NULL(r) (0) +#define IS_REF_NONNULL(r) (1) +#endif + #endif diff --git a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h index ff41bc4f01..4c3f0f75bb 100644 --- a/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h +++ b/libs/JSystem/include/JSystem/J3DGraphAnimator/J3DMaterialAnm.h @@ -3,6 +3,8 @@ #include "JSystem/J3DGraphAnimator/J3DAnimation.h" +class J3DMaterial; + /** * @ingroup jsystem-j3d * diff --git a/libs/JSystem/src/JAudio2/JASAramStream.cpp b/libs/JSystem/src/JAudio2/JASAramStream.cpp index 2a188b87e3..14f3221711 100644 --- a/libs/JSystem/src/JAudio2/JASAramStream.cpp +++ b/libs/JSystem/src/JAudio2/JASAramStream.cpp @@ -434,7 +434,7 @@ void JASAramStream::updateChannel(u32 i_callbackType, JASChannel* i_channel, field_0x120 = 0; field_0x12c |= 2; if (field_0x0c4 < 0xffffffff) { - field_0x0c4++; + field_0x0c4 += 1; } field_0x0c0 = false; } diff --git a/libs/JSystem/src/JAudio2/JASAudioThread.cpp b/libs/JSystem/src/JAudio2/JASAudioThread.cpp index ab059cf747..fc926b3bb5 100644 --- a/libs/JSystem/src/JAudio2/JASAudioThread.cpp +++ b/libs/JSystem/src/JAudio2/JASAudioThread.cpp @@ -107,7 +107,7 @@ void* JASAudioThread::run() { case AUDIOMSG_DSP: JUT_ASSERT(125, snIntCount != 0); - snIntCount--; + snIntCount -= 1; if (snIntCount == 0) { JASProbe::stop(7); JASDriver::finishDSPFrame(); diff --git a/libs/JSystem/src/JAudio2/JASBasicBank.cpp b/libs/JSystem/src/JAudio2/JASBasicBank.cpp index e7304d4d32..936c7829e8 100644 --- a/libs/JSystem/src/JAudio2/JASBasicBank.cpp +++ b/libs/JSystem/src/JAudio2/JASBasicBank.cpp @@ -21,7 +21,7 @@ bool JASBasicBank::getInstParam(int prg_no, int param_1, int param_2, JASInstParam* o_param) const { JASInst* inst = getInst(prg_no); if (inst == NULL) { - return NULL; + return false; } return inst->getParam(param_1, param_2, o_param); } diff --git a/libs/JSystem/src/JAudio2/JASCalc.cpp b/libs/JSystem/src/JAudio2/JASCalc.cpp index be87a8aa4e..79d9cb500f 100644 --- a/libs/JSystem/src/JAudio2/JASCalc.cpp +++ b/libs/JSystem/src/JAudio2/JASCalc.cpp @@ -5,7 +5,7 @@ #include void JASCalc::imixcopy(const s16* s1, const s16* s2, s16* dst, u32 n) { - for (n; n != 0; n--) { + for (; n != 0; n--) { *dst++ = *(s1)++; *dst++ = *(s2)++; } diff --git a/libs/JSystem/src/JAudio2/JASSeqParser.cpp b/libs/JSystem/src/JAudio2/JASSeqParser.cpp index ea91cc06ae..bb80e583c2 100644 --- a/libs/JSystem/src/JAudio2/JASSeqParser.cpp +++ b/libs/JSystem/src/JAudio2/JASSeqParser.cpp @@ -295,7 +295,7 @@ u32 JASSeqParser::readReg(JASTrack* param_0, u32 param_1) const { case 0x6a: result = param_0->getReleasePrio(); // @bug this should have been <<= - result << 8; + (void)(result << 8); result |= param_0->getNoteOnPrio(); break; case 0x6b: diff --git a/libs/JSystem/src/JParticle/JPABaseShape.cpp b/libs/JSystem/src/JParticle/JPABaseShape.cpp index fffcf05cad..f28add564e 100644 --- a/libs/JSystem/src/JParticle/JPABaseShape.cpp +++ b/libs/JSystem/src/JParticle/JPABaseShape.cpp @@ -1260,7 +1260,7 @@ JPABaseShape::JPABaseShape(u8 const* pData, JKRHeap* pHeap) { } if (isTexAnm()) { - JUT_ASSERT(1698, pBsd->texAnmKeyNum != NULL); + JUT_ASSERT(1698, pBsd->texAnmKeyNum != 0); u32 offs = sizeof(JPABaseShapeData); if (isTexCrdAnm()) { offs += 0x28; @@ -1271,7 +1271,7 @@ JPABaseShape::JPABaseShape(u8 const* pData, JKRHeap* pHeap) { } if (isPrmAnm()) { - JUT_ASSERT(1707, pBsd->prmAnmKeyNum != NULL); + JUT_ASSERT(1707, pBsd->prmAnmKeyNum != 0); JPAClrAnmKeyData* anmKeyData = (JPAClrAnmKeyData*)(pData + pBsd->mClrPrmAnmOffset); makeColorTable(&mpPrmClrAnmTbl, anmKeyData, pBsd->prmAnmKeyNum, pBsd->mClrAnmFrmMax, pHeap); @@ -1280,7 +1280,7 @@ JPABaseShape::JPABaseShape(u8 const* pData, JKRHeap* pHeap) { } if (isEnvAnm()) { - JUT_ASSERT(1716, pBsd->envAnmKeyNum != NULL); + JUT_ASSERT(1716, pBsd->envAnmKeyNum != 0); JPAClrAnmKeyData* anmKeyData = (JPAClrAnmKeyData*)(pData + pBsd->mClrEnvAnmOffset); makeColorTable(&mpEnvClrAnmTbl, anmKeyData, pBsd->envAnmKeyNum, pBsd->mClrAnmFrmMax, pHeap); diff --git a/libs/JSystem/src/JStudio/JStudio_JStage/control.cpp b/libs/JSystem/src/JStudio/JStudio_JStage/control.cpp index 5ba81c8fc9..641348b87b 100644 --- a/libs/JSystem/src/JStudio/JStudio_JStage/control.cpp +++ b/libs/JSystem/src/JStudio/JStudio_JStage/control.cpp @@ -37,7 +37,7 @@ bool JStudio_JStage::TCreateObject::create( eObject = JStage::OBJECT_FOG; break; default: - return NULL; + return false; } JUT_ASSERT(99, pfnCreateObject!=NULL); JUT_ASSERT(100, eObject!=JStage::OBJECT_UNDEFINED); diff --git a/libs/JSystem/src/JUtility/JUTConsole.cpp b/libs/JSystem/src/JUtility/JUTConsole.cpp index b2d350f0d5..3be4a370ef 100644 --- a/libs/JSystem/src/JUtility/JUTConsole.cpp +++ b/libs/JSystem/src/JUtility/JUTConsole.cpp @@ -181,7 +181,7 @@ void JUTConsole::doDraw(JUTConsole::EConsoleType consoleType) const { mFont->drawString_scale((int)f31, sp94, mFontSizeX, mFontSizeY, mVisible ? "[ON]" : "[OFF]", TRUE); f31 += (int)(mFontSizeX * 6.0f); - if (this == NULL) // ???? + if (IS_REF_NULL(*this)) // ???? { mFont->setCharColor(JUtility::TColor(0xff, 0xff, 0x64, 0xff)); mFont->drawString_scale((int)(f31 - mFontSizeX), mFontSizeX, mFontSizeY, sp94, diff --git a/libs/JSystem/src/JUtility/JUTException.cpp b/libs/JSystem/src/JUtility/JUTException.cpp index e34b56c710..509acbfb3e 100644 --- a/libs/JSystem/src/JUtility/JUTException.cpp +++ b/libs/JSystem/src/JUtility/JUTException.cpp @@ -949,7 +949,7 @@ bool JUTException::queryMapAddress_single(char* mapPath, u32 address, s32 sectio dst--; i--; } - (void)*src; // needed to match debug + UNUSED(*src); // needed to match debug *dst = 0; if (print) { if (begin_with_newline) { diff --git a/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp b/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp index 687bf217fe..8ef7c7fe32 100644 --- a/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp +++ b/src/SSystem/SComponent/c_bg_s_gnd_chk.cpp @@ -5,6 +5,12 @@ #include "SSystem/SComponent/c_bg_s_gnd_chk.h" #include "f_pc/f_pc_manager.h" +#include "JSystem/JUtility/JUTAssert.h" + +#define CHECK_FLOAT_CLASS(line, x) JUT_ASSERT(line, !isnan(x)); +#define CHECK_FLOAT_RANGE(line, x) JUT_ASSERT(line, -INF < x && x < INF); +#define CHECK_FLOAT_MIN(line, x) JUT_ASSERT(line, -INF < x); +#define CHECK_FLOAT_MAX(line, x) JUT_ASSERT(line, x < INF); cBgS_GndChk::cBgS_GndChk() { m_pos = cXyz::Zero; @@ -15,11 +21,31 @@ cBgS_GndChk::cBgS_GndChk() { cBgS_GndChk::~cBgS_GndChk() {} void cBgS_GndChk::SetPos(Vec const* pos) { - m_pos = *pos; + m_pos.x = pos->x; + m_pos.y = pos->y; + m_pos.z = pos->z; + + CHECK_FLOAT_CLASS(37, m_pos.x); + CHECK_FLOAT_CLASS(38, m_pos.y); + CHECK_FLOAT_CLASS(39, m_pos.z); + + CHECK_FLOAT_RANGE(43, m_pos.x); + CHECK_FLOAT_MIN(44, m_pos.y); + CHECK_FLOAT_MAX(45, m_pos.y); + CHECK_FLOAT_RANGE(46, m_pos.z); } void cBgS_GndChk::SetPos(cXyz const* pos) { m_pos = *pos; + + CHECK_FLOAT_CLASS(59, m_pos.x); + CHECK_FLOAT_CLASS(60, m_pos.y); + CHECK_FLOAT_CLASS(61, m_pos.z); + + CHECK_FLOAT_RANGE(65, m_pos.x); + CHECK_FLOAT_MIN(66, m_pos.y); + CHECK_FLOAT_MAX(67, m_pos.y); + CHECK_FLOAT_RANGE(68, m_pos.z); } void cBgS_GndChk::PreCheck() { diff --git a/src/SSystem/SComponent/c_bg_s_lin_chk.cpp b/src/SSystem/SComponent/c_bg_s_lin_chk.cpp index ddfd9274b6..cb207254ea 100644 --- a/src/SSystem/SComponent/c_bg_s_lin_chk.cpp +++ b/src/SSystem/SComponent/c_bg_s_lin_chk.cpp @@ -28,11 +28,11 @@ void cBgS_LinChk::Set2(cXyz const* startPos, cXyz const* endPos, unsigned int ac field_0x40 = *endPos; SetActorPid(actorPid); mStts &= ~STTS_HIT; - ClearPi(); + ClearCheckIndex(); } void cBgS_LinChk::PreCalc() { - mPreWallChk = !(mStts & STTS_WALL_OFF); - mPreGroundChk = !(mStts & STTS_GROUND_OFF); - mPreRoofChk = !(mStts & STTS_ROOF_OFF); + mPreWallChk = !ChkSttsWallOff(); + mPreGroundChk = !ChkSttsGroundOff(); + mPreRoofChk = !ChkSttsRoofOff(); } diff --git a/src/SSystem/SComponent/c_cc_d.cpp b/src/SSystem/SComponent/c_cc_d.cpp index 5326338602..569d64e5e7 100644 --- a/src/SSystem/SComponent/c_cc_d.cpp +++ b/src/SSystem/SComponent/c_cc_d.cpp @@ -218,9 +218,7 @@ void cCcD_Stts::PlusCcMove(f32 x, f32 y, f32 z) { } void cCcD_Stts::ClrCcMove() { - m_cc_move.z = 0.0f; - m_cc_move.y = 0.0f; - m_cc_move.x = 0.0f; + m_cc_move.x = m_cc_move.y = m_cc_move.z = 0.0f; } void cCcD_Stts::PlusDmg(int dmg) { @@ -231,7 +229,8 @@ void cCcD_Stts::PlusDmg(int dmg) { } f32 cCcD_Stts::GetWeightF() const { - return (s32)m_weight; + int weighti = GetWeightUc(); + return weighti; } void cCcD_ObjCommonBase::ct() { @@ -259,17 +258,13 @@ fopAc_ac_c* cCcD_Obj::GetAc() { if (mStts == NULL) { return NULL; } else { - return mStts->GetAc(); + return mStts->GetActor(); } } void cCcD_ShapeAttr::getShapeAccess(cCcD_ShapeAttr::Shape* pshape) const { pshape->_0 = 2; - pshape->_14 = 0.0f; - pshape->_10 = 0.0f; - pshape->_4.z = 0.0f; - pshape->_4.y = 0.0f; - pshape->_4.x = 0.0f; + pshape->_4.x = pshape->_4.y = pshape->_4.z = pshape->_10 = pshape->_14 = 0.0f; } bool cCcD_PntAttr::GetNVec(cXyz const& param_0, cXyz* param_1) const { @@ -321,19 +316,20 @@ bool cCcD_TriAttr::CrossAtTg(const cCcD_TriAttr& other, cXyz* pxyz) const { } void cCcD_TriAttr::CalcAabBox() { - mAab.ClearForMinMax(); - mAab.SetMinMax(mA); - mAab.SetMinMax(mB); - mAab.SetMinMax(mC); + GetWorkAab().ClearForMinMax(); + GetWorkAab().SetMinMax(mA); + GetWorkAab().SetMinMax(mB); + GetWorkAab().SetMinMax(mC); } bool cCcD_TriAttr::GetNVec(const cXyz& param_0, cXyz* pOut) const { if (getPlaneFunc(¶m_0) >= 0.0f) { - *pOut = mNormal; + *pOut = *GetNP(); } else { - *pOut = mNormal; - VECScale(pOut, pOut, -1.0f); + *pOut = *GetNP(); + PSVECScale(pOut, pOut, -1.0f); } + return true; } @@ -362,7 +358,7 @@ bool cCcD_CpsAttr::CrossAtTg(const cCcD_SphAttr& sphAttr, cXyz* pxyz) const { } bool cCcD_CpsAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { - if (triAttr.cM3dGTri::Cross(*this, pxyz)) { + if (cM3dGCps::Cross(triAttr, pxyz)) { return true; } else { return false; @@ -400,44 +396,47 @@ bool cCcD_CpsAttr::CrossCo(const cCcD_SphAttr& sphAttr, f32* param_1) const { } void cCcD_CpsAttr::CalcAabBox() { - mAab.ClearForMinMax(); - mAab.SetMinMax(mStart); - mAab.SetMinMax(mEnd); - mAab.PlusR(mRadius); + GetWorkAab().ClearForMinMax(); + GetWorkAab().SetMinMax(*GetStartP()); + GetWorkAab().SetMinMax(*GetEndP()); + GetWorkAab().PlusR(GetR()); } bool cCcD_CpsAttr::GetNVec(const cXyz& param_0, cXyz* param_1) const { - Vec diff; - const cXyz& endP = GetEndP(); - VECSubtract(&endP, &mStart, &diff); + cXyz diff; + PSVECSubtract(GetEndP(), GetStartP(), &diff); - f32 diffLen = VECDotProduct(&diff, &diff); + f32 diffLen = PSVECDotProduct(&diff, &diff); if (cM3d_IsZero(diffLen)) { return false; - } else { - Vec vec1, vec2; - VECSubtract(¶m_0, &mStart, &vec1); - f32 vec1Len = VECDotProduct(&vec1, &diff) / diffLen; - if (vec1Len < 0.0f) { - vec2 = mStart; - } else { - if (vec1Len > 1.0f) { - vec2 = endP; - } else { - VECScale(&diff, &diff, vec1Len); - VECAdd(&diff, &mStart, &vec2); - } - } + } - VECSubtract(¶m_0, &vec2, param_1); - if (cM3d_IsZero(VECMag(param_1))) { - param_1->set(0.0f, 0.0f, 0.0f); - return false; + cXyz vec1; + PSVECSubtract(¶m_0, GetStartP(), &vec1); + f32 vec1Len = PSVECDotProduct(&vec1, &diff) / diffLen; + + cXyz vec2; + if (vec1Len < 0.0f) { + vec2 = *GetStartP(); + } else { + if (vec1Len > 1.0f) { + vec2 = *GetEndP(); } else { - VECNormalize(param_1, param_1); - return true; + PSVECScale(&diff, &diff, vec1Len); + PSVECAdd(&diff, GetStartP(), &vec2); } } + + PSVECSubtract(¶m_0, &vec2, param_1); + if (cM3d_IsZero(PSVECMag(param_1))) { + param_1->x = 0.0f; + param_1->y = 0.0f; + param_1->z = 0.0f; + return false; + } else { + PSVECNormalize(param_1, param_1); + return true; + } } bool cCcD_CylAttr::CrossAtTg(const cCcD_CpsAttr& cpsAttr, cXyz* pxyz) const { @@ -473,7 +472,7 @@ bool cCcD_CylAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { } bool cCcD_CylAttr::CrossCo(const cCcD_CylAttr& other, f32* f) const { - if (cM3dGCyl::Cross(&other, f)) { + if (cM3dGCyl::cross(&other, f)) { return true; } else { return false; @@ -481,7 +480,7 @@ bool cCcD_CylAttr::CrossCo(const cCcD_CylAttr& other, f32* f) const { } bool cCcD_CylAttr::CrossCo(const cCcD_SphAttr& sphAttr, f32* f) const { - if (cM3dGCyl::Cross(&sphAttr, f)) { + if (cM3dGCyl::cross(&sphAttr, f)) { return true; } else { return false; @@ -507,51 +506,51 @@ void cCcD_CylAttr::CalcAabBox() { max.x = GetCP()->x + GetR(); max.y = GetCP()->y + GetH(); max.z = GetCP()->z + GetR(); - mAab.Set(&min, &max); + GetWorkAab().Set(&min, &max); } bool cCcD_CylAttr::GetNVec(const cXyz& param_0, cXyz* param_1) const { - Vec vec; - if (GetCP()->y > param_0.y) { - vec = mCenter; + const cXyz* cp = GetCP(); + cXyz vec; + if (cp->y > param_0.y) { + vec = *cp; } else { - if (GetCP()->y + GetH() < param_0.y) { - vec.x = GetCP()->x; - vec.y = GetCP()->y; - vec.z = GetCP()->z; - vec.y = GetCP()->y + GetH(); + if (cp->y + GetH() < param_0.y) { + vec = *cp; + vec.y += GetH(); } else { - vec = mCenter; + vec = *cp; vec.y = param_0.y; } } - VECSubtract(¶m_0, &vec, param_1); - if (cM3d_IsZero(VECMag(param_1))) { - param_1->set(0.0f, 0.0f, 0.0f); + PSVECSubtract(¶m_0, &vec, param_1); + if (cM3d_IsZero(PSVECMag(param_1))) { + param_1->x = 0.0f; + param_1->y = 0.0f; + param_1->z = 0.0f; return false; } else { - VECNormalize(param_1, param_1); + PSVECNormalize(param_1, param_1); return true; } + return false; } void cCcD_CylAttr::getShapeAccess(cCcD_ShapeAttr::Shape* pshape) const { pshape->_0 = 1; - pshape->_4.x = mCenter.x; - pshape->_4.y = mCenter.y; - pshape->_4.z = mCenter.z; - pshape->_10 = mRadius; - pshape->_14 = mHeight; -} -inline bool inlineCross(const cM3dGSph& sph, const cM3dGCps* pcps, cXyz* pxyz) { - return cM3d_Cross_CpsSph(*pcps, sph, pxyz); + const cXyz& center = GetC(); + pshape->_4.x = center.x; + pshape->_4.y = center.y; + pshape->_4.z = center.z; + pshape->_10 = GetR(); + pshape->_14 = GetH(); } bool cCcD_SphAttr::CrossAtTg(const cCcD_CpsAttr& cpsAttr, cXyz* pxyz) const { - if (inlineCross(*this, &cpsAttr, pxyz)) { + if (cM3dGSph::Cross(&cpsAttr, pxyz)) { return true; } else { return false; @@ -575,7 +574,7 @@ bool cCcD_SphAttr::CrossAtTg(const cCcD_SphAttr& sphAttr, cXyz* pxyz) const { } bool cCcD_SphAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { - if (triAttr.cM3dGTri::Cross(*this, pxyz)) { + if (cM3dGSph::Cross(triAttr, pxyz)) { return true; } else { return false; @@ -583,7 +582,7 @@ bool cCcD_SphAttr::CrossAtTg(const cCcD_TriAttr& triAttr, cXyz* pxyz) const { } bool cCcD_SphAttr::CrossCo(const cCcD_CylAttr& cylAttr, f32* f) const { - if (cM3dGSph::Cross(&cylAttr, f)) { + if (cM3dGSph::cross(&cylAttr, f)) { return true; } else { return false; @@ -591,7 +590,7 @@ bool cCcD_SphAttr::CrossCo(const cCcD_CylAttr& cylAttr, f32* f) const { } bool cCcD_SphAttr::CrossCo(const cCcD_SphAttr& sphAttr, f32* f) const { - if (cM3dGSph::Cross(&sphAttr, f)) { + if (cM3dGSph::cross(&sphAttr, f)) { return true; } else { return false; @@ -622,37 +621,40 @@ void cCcD_SphAttr::CalcAabBox() { max.y += GetR(); max.z += GetR(); - mAab.Set(&min, &max); + GetWorkAab().Set(&min, &max); } bool cCcD_SphAttr::GetNVec(const cXyz& param_0, cXyz* param_1) const { - param_1->x = param_0.x - mCenter.x; - param_1->y = param_0.y - mCenter.y; - param_1->z = param_0.z - mCenter.z; + const cXyz& center = GetC(); + param_1->x = param_0.x - center.x; + param_1->y = param_0.y - center.y; + param_1->z = param_0.z - center.z; - if (cM3d_IsZero(VECMag(param_1))) { + if (cM3d_IsZero(PSVECMag(param_1))) { param_1->x = 0.0f; param_1->y = 0.0f; param_1->z = 0.0f; return false; } else { - VECNormalize(param_1, param_1); + PSVECNormalize(param_1, param_1); return true; } } void cCcD_SphAttr::getShapeAccess(cCcD_ShapeAttr::Shape* pshape) const { pshape->_0 = 0; - pshape->_4.x = mCenter.x; - pshape->_4.y = mCenter.y; - pshape->_4.z = mCenter.z; - pshape->_10 = mRadius; + + const cXyz& center = GetC(); + pshape->_4.x = center.x; + pshape->_4.y = center.y; + pshape->_4.z = center.z; + pshape->_10 = GetR(); pshape->_14 = 0.0f; } void cCcD_ObjAt::SetHit(cCcD_Obj* pObj) { - mRPrm = 1; - mHitObj = pObj; + SetRPrm(1); + SetHitObj(pObj); } void cCcD_ObjAt::Set(const cCcD_SrcObjAt& src) { @@ -662,8 +664,8 @@ void cCcD_ObjAt::Set(const cCcD_SrcObjAt& src) { } void cCcD_ObjAt::ClrHit() { - mRPrm &= ~1; - mHitObj = NULL; + ClrRPrm(1); + ClrObj(); } void cCcD_ObjTg::Set(const cCcD_SrcObjTg& src) { @@ -672,36 +674,36 @@ void cCcD_ObjTg::Set(const cCcD_SrcObjTg& src) { } void cCcD_ObjTg::SetGrp(u32 grp) { - mSPrm &= ~0x1E; - mSPrm |= grp; + OffSPrmBit(0x1E); + OnSPrmBit(grp); } void cCcD_ObjTg::ClrHit() { - mRPrm &= ~1; - mHitObj = NULL; + ClrRPrm(1); + ClrObj(); } void cCcD_ObjTg::SetHit(cCcD_Obj* pObj) { - mRPrm = 1; - mHitObj = pObj; + SetRPrm(1); + SetHitObj(pObj); } void cCcD_ObjCo::SetHit(cCcD_Obj* pObj) { - mRPrm = 1; - mHitObj = pObj; + SetRPrm(1); + SetHitObj(pObj); } void cCcD_ObjCo::ClrHit() { - mRPrm &= ~1; - mHitObj = NULL; + ClrRPrm(1); + ClrObj(); } void cCcD_ObjCo::SetIGrp(u32 grp) { - mSPrm &= ~0xE; - mSPrm |= grp; + OffSPrmBit(0xE); + OnSPrmBit(grp); } void cCcD_ObjCo::SetVsGrp(u32 grp) { - mSPrm &= ~0x70; - mSPrm |= grp; + OffSPrmBit(0x70); + OnSPrmBit(grp); } diff --git a/src/SSystem/SComponent/c_cc_s.cpp b/src/SSystem/SComponent/c_cc_s.cpp index 72df9625d8..7660064cef 100644 --- a/src/SSystem/SComponent/c_cc_s.cpp +++ b/src/SSystem/SComponent/c_cc_s.cpp @@ -33,6 +33,10 @@ void cCcS::Ct() { *obj = NULL; } mObjCount = 0; + + #if DEBUG + m_debug_code = 1234; + #endif } void cCcS::Dt() { @@ -98,9 +102,8 @@ void cCcS::ClrCoHitInf() { if (*obj != NULL) { (*obj)->GetGObjInf()->ClrCoHit(); - cCcD_Stts* stts = (*obj)->GetStts(); - if (stts != NULL) { - stts->ClrCcMove(); + if ((*obj)->GetStts() != NULL) { + (*obj)->GetStts()->ClrCo(); } } } @@ -111,9 +114,8 @@ void cCcS::ClrTgHitInf() { if (*obj != NULL) { (*obj)->GetGObjInf()->ClrTgHit(); - cCcD_Stts* stts = (*obj)->GetStts(); - if (stts != NULL) { - stts->ClrTg(); + if ((*obj)->GetStts() != NULL) { + (*obj)->GetStts()->ClrTg(); } } } @@ -124,9 +126,8 @@ void cCcS::ClrAtHitInf() { if (*obj != NULL) { (*obj)->GetGObjInf()->ClrAtHit(); - cCcD_Stts* stts = (*obj)->GetStts(); - if (stts != NULL) { - stts->ClrAt(); + if ((*obj)->GetStts() != NULL) { + (*obj)->GetStts()->ClrAt(); } } } @@ -155,18 +156,18 @@ void cCcS::ChkAtTg() { continue; cCcD_ShapeAttr* pat_sa = (*pat_obj)->GetShapeAttr(); - JUT_ASSERT(0, pat_sa != NULL); + JUT_ASSERT(338, pat_sa != NULL); for (cCcD_Obj** ptg_obj = mpObjTg; ptg_obj < objTgEnd; ++ptg_obj) { if (*ptg_obj == NULL || !(*ptg_obj)->ChkTgSet()) continue; - if (!(*pat_obj)->GetDivideInfo().Chk((*ptg_obj)->GetDivideInfo())) + if (!(*pat_obj)->GetPDivideInfo()->Chk(*(*ptg_obj)->GetPDivideInfo())) continue; if (ChkNoHitAtTg(*pat_obj, *ptg_obj)) continue; cCcD_ShapeAttr* ptg_sa = (*ptg_obj)->GetShapeAttr(); - JUT_ASSERT(0, ptg_sa != NULL); + JUT_ASSERT(354, ptg_sa != NULL); static cXyz cross; bool didCross = pat_sa->CrossAtTg(*ptg_sa, &cross); @@ -176,9 +177,12 @@ void cCcS::ChkAtTg() { } else if (anyBsRevHit && !didCross) { cCcD_ShapeAttr* pat_sa = (*pat_obj)->GetShapeAttr(); if (pat_sa == NULL) { - cross.set(0.0f, 0.0f, 0.0f); + cross.x = 0.0f; + cross.y = 0.0f; + cross.z = 0.0f; } else { - pat_sa->GetWorkAab().CalcCenter(&cross); + cM3dGAab& aab = pat_sa->GetWorkAab(); + aab.CalcCenter(&cross); } SetAtTgCommonHitInf(*pat_obj, *ptg_obj, &cross); @@ -213,24 +217,22 @@ void cCcS::ChkCo() { continue; cCcD_ShapeAttr* pco1_sa = (*pco1_obj)->GetShapeAttr(); - JUT_ASSERT(0, pco1_sa != NULL); + JUT_ASSERT(444, pco1_sa != NULL); for (cCcD_Obj** pco2_obj = pco1_obj + 1; pco2_obj < objCoEnd; ++pco2_obj) { if (*pco2_obj == NULL || !(*pco2_obj)->ChkCoSet()) continue; - if (!(*pco1_obj)->GetDivideInfo().Chk((*pco2_obj)->GetDivideInfo())) + if (!(*pco1_obj)->GetPDivideInfo()->Chk(*(*pco2_obj)->GetPDivideInfo())) continue; if (ChkNoHitCo(*pco1_obj, *pco2_obj)) continue; cCcD_ShapeAttr* pco2_sa = (*pco2_obj)->GetShapeAttr(); - JUT_ASSERT(0, pco2_sa != NULL); + JUT_ASSERT(456, pco2_sa != NULL); f32 cross_len; if (pco1_sa->CrossCo(*pco2_sa, &cross_len)) { - cXyz& co2_center = pco2_sa->GetCoCP(); - cXyz& co1_center = pco1_sa->GetCoCP(); - SetCoCommonHitInf(*pco1_obj, &co1_center, *pco2_obj, &co2_center, cross_len); + SetCoCommonHitInf(*pco1_obj, &pco1_sa->GetCoCP(), *pco2_obj, &pco2_sa->GetCoCP(), cross_len); } } } @@ -238,7 +240,11 @@ void cCcS::ChkCo() { void cCcS::CalcTgPlusDmg(cCcD_Obj* pat_obj, cCcD_Obj* ptg_obj, cCcD_Stts* pat_stts, cCcD_Stts* ptg_stts) { - ptg_stts->PlusDmg(pat_obj->GetAtAtp()); + UNUSED(ptg_obj); + UNUSED(pat_stts); + + int atp = pat_obj->GetAtAtp(); + ptg_stts->PlusDmg(atp); } void cCcS::SetAtTgCommonHitInf(cCcD_Obj* pat_obj, cCcD_Obj* ptg_obj, cXyz* pcross) { @@ -296,8 +302,8 @@ void cCcS::SetPosCorrect(cCcD_Obj* pco1_obj, cXyz* ppos1, cCcD_Obj* pco2_obj, cX return; if (pco1_obj->GetStts() == NULL || pco2_obj->GetStts() == NULL) return; - if (pco1_obj->GetStts()->GetAc() != NULL && - pco1_obj->GetStts()->GetAc() == pco2_obj->GetStts()->GetAc()) + if (pco1_obj->GetStts()->GetActor() != NULL && + pco1_obj->GetStts()->GetActor() == pco2_obj->GetStts()->GetActor()) return; if (!(fabsf(cross_len) < (1.0f / 125.0f))) { @@ -346,12 +352,12 @@ void cCcS::SetPosCorrect(cCcD_Obj* pco1_obj, cXyz* ppos1, cCcD_Obj* pco2_obj, cX } f32 objDistLen; - Vec vec1; - Vec vec2; + cXyz vec1; + cXyz vec2; Vec objsDist; if (bothCoSph3DCrr) { - VECSubtract(ppos2, ppos1, &objsDist); - objDistLen = VECMag(&objsDist); + PSVECSubtract(ppos2, ppos1, &objsDist); + objDistLen = PSVECMag(&objsDist); } else { objsDist.x = ppos2->x - ppos1->x; objsDist.y = 0; @@ -361,10 +367,11 @@ void cCcS::SetPosCorrect(cCcD_Obj* pco1_obj, cXyz* ppos1, cCcD_Obj* pco2_obj, cX if (!cM3d_IsZero(objDistLen)) { if (bothCoSph3DCrr) { - VECScale(&objsDist, &objsDist, cross_len / objDistLen); + f32 sp1C = cross_len / objDistLen; + PSVECScale(&objsDist, &objsDist, sp1C); obj2Weight *= -1; - VECScale(&objsDist, &vec1, obj2Weight); - VECScale(&objsDist, &vec2, obj1Weight); + PSVECScale(&objsDist, &vec1, obj2Weight); + PSVECScale(&objsDist, &vec2, obj1Weight); } else { f32 pushFactor = cross_len / objDistLen; objsDist.x *= pushFactor; @@ -435,7 +442,7 @@ void cCcS::CalcArea() { for (cCcD_Obj** pset_obj = mpObj; pset_obj < mpObj + mObjCount; ++pset_obj) { if (*pset_obj != NULL) { cCcD_ShapeAttr* pset_sa = (*pset_obj)->GetShapeAttr(); - JUT_ASSERT(0, pset_sa != NULL); + JUT_ASSERT(826, pset_sa != NULL); pset_sa->CalcAabBox(); aab.SetMinMax(pset_sa->GetWorkAab()); @@ -445,10 +452,10 @@ void cCcS::CalcArea() { mDivideArea.SetArea(aab); for (cCcD_Obj** pset_obj = mpObj; pset_obj < mpObj + mObjCount; ++pset_obj) { if (*pset_obj != NULL) { - const cCcD_ShapeAttr* pset_sa = (*pset_obj)->GetShapeAttr(); - JUT_ASSERT(0, pset_sa != NULL); + cCcD_ShapeAttr* pset_sa = (*pset_obj)->GetShapeAttr(); + JUT_ASSERT(839, pset_sa != NULL); - cCcD_DivideInfo* divideInfo = &(*pset_obj)->GetDivideInfo(); + cCcD_DivideInfo* divideInfo = (*pset_obj)->GetPDivideInfo(); mDivideArea.CalcDivideInfo(divideInfo, pset_sa->GetWorkAab(), (*pset_obj)->ChkBsRevHit()); } @@ -456,10 +463,22 @@ void cCcS::CalcArea() { } void cCcS::Move() { + #if DEBUG + JUT_ASSERT(866, m_debug_code == 1234); + #endif + CalcArea(); ChkAtTg(); ChkCo(); MoveAfterCheck(); + + #if DEBUG + field_0x280c = mObjAtCount; + field_0x280e = mObjTgCount; + field_0x2810 = mObjCoCount; + field_0x2812 = mObjCount; + #endif + mObjAtCount = 0; mObjTgCount = 0; mObjCoCount = 0; diff --git a/src/SSystem/SComponent/c_m3d.cpp b/src/SSystem/SComponent/c_m3d.cpp index 8487468223..c44ea66bf8 100644 --- a/src/SSystem/SComponent/c_m3d.cpp +++ b/src/SSystem/SComponent/c_m3d.cpp @@ -66,14 +66,14 @@ bool cM3d_Len2dSqPntAndSegLine(f32 param_1, f32 param_2, f32 param_3, f32 param_ bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin* pLine, const Vec* pVec, Vec* pOutVec, f32* pOutF) { bool retVal = false; Vec tmp; - VECSubtract(&pLine->GetEndP(), &pLine->GetStartP(), &tmp); + VECSubtract(pLine->GetEndP(), pLine->GetStartP(), &tmp); f32 seqLen = VECDotProduct(&tmp, &tmp); if (cM3d_IsZero(seqLen)) { *pOutF = 0.0f; return retVal; } else { Vec tmp2; - VECSubtract(pVec, &pLine->GetStartP(), &tmp2); + VECSubtract(pVec, pLine->GetStartP(), &tmp2); f32 tmpF = VECDotProduct(&tmp2, &tmp); tmpF /= seqLen; if (tmpF < 0.0f || tmpF > 1.0f) { @@ -82,7 +82,7 @@ bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin* pLine, const Vec* pVec, Vec* pOut retVal = true; } VECScale(&tmp, &tmp, tmpF); - VECAdd(&tmp, &pLine->GetStartP(), pOutVec); + VECAdd(&tmp, pLine->GetStartP(), pOutVec); *pOutF = VECSquareDistance(pOutVec, pVec); return retVal; } @@ -213,7 +213,7 @@ int cM3d_Check_LinLin(const cM3dGLin* lin_a, const cM3dGLin* lin_b, f32* dst_a, VECScale(&linAVec, &linAVec, invLinALen); VECScale(&linBVec, &linBVec, invLinBLen); Vec tmp; - VECSubtract(&lin_a->GetStartP(), &lin_b->GetStartP(), &tmp); + VECSubtract(lin_a->GetStartP(), lin_b->GetStartP(), &tmp); f32 tmpF = -VECDotProduct(&linAVec, &linBVec); f32 tmpF2 = VECDotProduct(&tmp, &linAVec); VECSquareMag(&tmp); // result not used @@ -262,19 +262,19 @@ static bool cM3d_CrossInfLineVsInfPlane_proc(f32 pFloatA, f32 pFloatB, const Vec } bool cM3d_Cross_LinPla(const cM3dGLin* lin, const cM3dGPla* pla, Vec* dst, bool a, bool b) { - f32 startVal = pla->getPlaneFunc(&lin->GetStartP()); - f32 endVal = pla->getPlaneFunc(&lin->GetEndP()); + f32 startVal = pla->getPlaneFunc(lin->GetStartP()); + f32 endVal = pla->getPlaneFunc(lin->GetEndP()); if (startVal * endVal > 0.0f) { *dst = lin->GetEnd(); return false; } else { if (startVal >= 0.0f && endVal <= 0.0f) { if (a) { - return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, &lin->GetStartP(), &lin->GetEndP(), dst); + return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, lin->GetStartP(), lin->GetEndP(), dst); } } else { if (b) { - return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, &lin->GetStartP(), &lin->GetEndP(), dst); + return cM3d_CrossInfLineVsInfPlane_proc(startVal, endVal, lin->GetStartP(), lin->GetEndP(), dst); } } *dst = lin->GetEnd(); @@ -1034,53 +1034,53 @@ bool cM3d_Cross_LinSph(cM3dGLin const* line, cM3dGSph const* sph, Vec* param_2) const Vec* center = sph->GetCP(); f32 max_x = center->x + sph->GetR(); - if (max_x < line->GetStartP().x && max_x < line->GetEndP().x) { + if (max_x < line->GetStartP()->x && max_x < line->GetEndP()->x) { return false; } f32 min_x = center->x - sph->GetR(); - if (min_x > line->GetStartP().x && min_x > line->GetEndP().x) { + if (min_x > line->GetStartP()->x && min_x > line->GetEndP()->x) { return false; } f32 max_y = center->y + sph->GetR(); - if (max_y < line->GetStartP().y && max_y < line->GetEndP().y) { + if (max_y < line->GetStartP()->y && max_y < line->GetEndP()->y) { return false; } f32 min_y = center->y - sph->GetR(); - if (min_y > line->GetStartP().y && min_y > line->GetEndP().y) { + if (min_y > line->GetStartP()->y && min_y > line->GetEndP()->y) { return false; } f32 max_z = center->z + sph->GetR(); - if (max_z < line->GetStartP().z && max_z < line->GetEndP().z) { + if (max_z < line->GetStartP()->z && max_z < line->GetEndP()->z) { return false; } f32 min_z = center->z - sph->GetR(); - if (min_z > line->GetStartP().z && min_z > line->GetEndP().z) { + if (min_z > line->GetStartP()->z && min_z > line->GetEndP()->z) { return false; } - VECSubtract(&line->GetEndP(), &line->GetStartP(), &lin_vec); + VECSubtract(line->GetEndP(), line->GetStartP(), &lin_vec); f32 len_sq = VECSquareMag(&lin_vec); if (cM3d_IsZero(len_sq)) { return false; } - VECSubtract(center, &line->GetStartP(), &vec); + VECSubtract(center, line->GetStartP(), &vec); f32 proj = VECDotProduct(&vec, &lin_vec) / len_sq; if (proj < 0.0f || proj > 1.0f) { - if (line->GetStartP().abs2(*center) < line->GetEndP().abs2(*center)) { - if (cM3d_Cross_SphPnt(sph, &line->GetStartP())) { - param_2->x = line->GetStartP().x; - param_2->y = line->GetStartP().y; - param_2->z = line->GetStartP().z; + if (line->GetStartP()->abs2(*center) < line->GetEndP()->abs2(*center)) { + if (cM3d_Cross_SphPnt(sph, line->GetStartP())) { + param_2->x = line->GetStartP()->x; + param_2->y = line->GetStartP()->y; + param_2->z = line->GetStartP()->z; return true; } } else { - if (cM3d_Cross_SphPnt(sph, &line->GetEndP())) { - param_2->x = line->GetEndP().x; - param_2->y = line->GetEndP().y; - param_2->z = line->GetEndP().z; + if (cM3d_Cross_SphPnt(sph, line->GetEndP())) { + param_2->x = line->GetEndP()->x; + param_2->y = line->GetEndP()->y; + param_2->z = line->GetEndP()->z; return true; } } @@ -1089,7 +1089,7 @@ bool cM3d_Cross_LinSph(cM3dGLin const* line, cM3dGSph const* sph, Vec* param_2) Vec proj_vec; VECScale(&lin_vec, &proj_vec, proj); - VECAdd(&proj_vec, &line->GetStartP(), param_2); + VECAdd(&proj_vec, line->GetStartP(), param_2); if (cM3d_LenSq(param_2, center) <= sph->GetR() * sph->GetR()) { return true; } @@ -1100,8 +1100,8 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p Vec* param_3) { int ret; Vec line_vec, vec; - VECSubtract(&line.GetEndP(), &line.GetStartP(), &line_vec); - VECSubtract(&line.GetStartP(), sph.GetCP(), &vec); + VECSubtract(line.GetEndP(), line.GetStartP(), &line_vec); + VECSubtract(line.GetStartP(), sph.GetCP(), &vec); f32 len_sq = VECDotProduct(&line_vec, &line_vec); f32 dVar9 = VECDotProduct(&line_vec, &vec) * 2.0f; f32 dVar6 = VECDotProduct(&vec, &vec) - sph.GetR() * sph.GetR(); @@ -1113,7 +1113,7 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p ret = 1; Vec vec2; VECScale(&line_vec, &vec2, -dVar6 / dVar9); - VECAdd(&vec2, &line.GetStartP(), param_2); + VECAdd(&vec2, line.GetStartP(), param_2); } } else { f32 f11 = dVar9 * dVar9 - len_sq * 4.0f * dVar6; @@ -1121,7 +1121,7 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p ret = 1; Vec vec2; VECScale(&line_vec, &vec2, -dVar9 / (len_sq * 2.0f)); - VECAdd(&vec2, &line.GetStartP(), param_2); + VECAdd(&vec2, line.GetStartP(), param_2); } else if (f11 < 0.0f) { ret = 0; } else { @@ -1131,9 +1131,9 @@ int cM3d_Cross_LinSph_CrossPos(cM3dGSph const& sph, cM3dGLin const& line, Vec* p f32 scale1 = f1 * (-dVar9 + sqrtf(f11)); f32 scale2 = f1 * (-dVar9 - sqrtf(f11)); VECScale(&line_vec, &vec2, scale1); - VECAdd(&vec2, &line.GetStartP(), param_2); + VECAdd(&vec2, line.GetStartP(), param_2); VECScale(&line_vec, &vec2, scale2); - VECAdd(&vec2, &line.GetStartP(), param_3); + VECAdd(&vec2, line.GetStartP(), param_3); } } @@ -1460,17 +1460,17 @@ int cM3d_Cross_CylLin(cM3dGCyl const* cyl, cM3dGLin const* line, Vec* param_2, V f2 = 0.0f; uVar11 = 0; - if (cM3d_Cross_CylPnt(cyl, &line->GetStartP()) && cM3d_Cross_CylPnt(cyl, &line->GetEndP())) { - *param_2 = line->GetStartP(); - *param_3 = line->GetEndP(); + if (cM3d_Cross_CylPnt(cyl, line->GetStartP()) && cM3d_Cross_CylPnt(cyl, line->GetEndP())) { + *param_2 = *line->GetStartP(); + *param_3 = *line->GetEndP(); return 2; } Vec vec1, vec2, vec3; Vec vec[4]; const Vec* center = cyl->GetCP(); - VECSubtract(&line->GetStartP(), center, &vec1); - VECSubtract(&line->GetEndP(), center, &vec2); + VECSubtract(line->GetStartP(), center, &vec1); + VECSubtract(line->GetEndP(), center, &vec2); VECSubtract(&vec2, &vec1, &vec3); r_sq = cyl->GetR() * cyl->GetR(); @@ -1599,7 +1599,7 @@ int cM3d_Cross_CylLin(cM3dGCyl const* cyl, cM3dGLin const* line, Vec* param_2, V if (count == 0) { *param_2 = vec[i]; } else if (count == 1) { - if (cM3d_LenSq(&line->GetStartP(), param_2) < cM3d_LenSq(&line->GetStartP(), &vec[i])) { + if (cM3d_LenSq(line->GetStartP(), param_2) < cM3d_LenSq(line->GetStartP(), &vec[i])) { *param_3 = vec[i]; } else { *param_3 = *param_2; @@ -1707,36 +1707,36 @@ inline bool cM3d_Cross_CpsCyl_Check(cM3dGCps const& cps, cM3dGCyl const& cyl, Ve bool cM3d_Cross_CpsCyl(cM3dGCps const& cps, cM3dGCyl const& cyl, Vec* param_2) { cM3dGLin line; - if (cM3d_Cross_CylPnt(&cyl, &cps.GetEndP())) { - *param_2 = cps.GetEndP(); + if (cM3d_Cross_CylPnt(&cyl, cps.GetEndP())) { + *param_2 = *cps.GetEndP(); return true; } - if (cM3d_Cross_CylPnt(&cyl, &cps.GetStartP())) { - *param_2 = cps.GetStartP(); + if (cM3d_Cross_CylPnt(&cyl, cps.GetStartP())) { + *param_2 = *cps.GetStartP(); return true; } - line.GetStartP() = *cyl.GetCP(); - line.GetEndP() = *cyl.GetCP(); - line.GetEndP().y += cyl.GetH(); + *line.GetStartP() = *cyl.GetCP(); + *line.GetEndP() = *cyl.GetCP(); + line.GetEndP()->y += cyl.GetH(); Vec vec; f32 tmp; - if (cM3d_Len3dSqPntAndSegLine(&cps, &line.GetEndP(), &vec, &tmp)) { - f32 dist = VECDistance(&line.GetEndP(), &vec); + if (cM3d_Len3dSqPntAndSegLine(&cps, line.GetEndP(), &vec, &tmp)) { + f32 dist = VECDistance(line.GetEndP(), &vec); if (dist < cps.GetR()) { - VECAdd(&line.GetEndP(), &vec, param_2); + VECAdd(line.GetEndP(), &vec, param_2); VECScale(param_2, param_2, 0.5f); - *param_2 = line.GetEndP(); + *param_2 = *line.GetEndP(); return true; } } - if (cM3d_Len3dSqPntAndSegLine(&cps, &line.GetStartP(), &vec, &tmp)) { - f32 dist = VECDistance(&line.GetStartP(), &vec); + if (cM3d_Len3dSqPntAndSegLine(&cps, line.GetStartP(), &vec, &tmp)) { + f32 dist = VECDistance(line.GetStartP(), &vec); if (dist < cps.GetR()) { - VECAdd(&line.GetStartP(), &vec, param_2); + VECAdd(line.GetStartP(), &vec, param_2); VECScale(param_2, param_2, 0.5f); return true; } @@ -1749,7 +1749,7 @@ bool cM3d_Cross_CpsCyl(cM3dGCps const& cps, cM3dGCyl const& cyl, Vec* param_2) { cM3dGSph sph; f32 tmp2; sph.SetR(cps.GetR()); - sph.SetC(cps.GetStartP()); + sph.SetC(*cps.GetStartP()); return cM3d_Cross_CylSph(&cyl, &sph, param_2, &tmp2); } else if (iVar2 == 2) { if (f1 >= 0.0f && f1 <= 1.0f && f2 >= 0.0f && f2 <= 1.0f) { @@ -1818,8 +1818,8 @@ static void cM3d_Cross_CpsSph_CrossPos(cM3dGCps const& param_1, cM3dGSph const& if (iVar5 == 1) { *param_4 = aVStack_70; } else if (iVar5 == 2) { - f32 dVar8 = VECSquareDistance(&aVStack_70, ¶m_1.GetStartP()); - f32 dVar9 = VECSquareDistance(&VStack_7c, ¶m_1.GetStartP()); + f32 dVar8 = VECSquareDistance(&aVStack_70, param_1.GetStartP()); + f32 dVar9 = VECSquareDistance(&VStack_7c, param_1.GetStartP()); if (dVar8 < dVar9) { *param_4 = aVStack_70; } else { @@ -1840,14 +1840,14 @@ static void cM3d_Cross_CpsSph_CrossPos(cM3dGCps const& param_1, cM3dGSph const& bool cM3d_Cross_CpsSph(cM3dGCps const& param_1, cM3dGSph const& param_2, Vec* param_3) { - f32 local_38 = VECDistance(¶m_1.GetStartP(), param_2.GetCP()); + f32 local_38 = VECDistance(param_1.GetStartP(), param_2.GetCP()); if (local_38 < param_1.GetR() + param_2.GetR()) { - cM3d_Cross_CpsSph_CrossPos(param_1, param_2, param_1.GetStartP(), param_3); + cM3d_Cross_CpsSph_CrossPos(param_1, param_2, *param_1.GetStartP(), param_3); return true; } - local_38 = VECDistance(¶m_1.GetEndP(), param_2.GetCP()); + local_38 = VECDistance(param_1.GetEndP(), param_2.GetCP()); if (local_38 < param_1.GetR() + param_2.GetR()) { - cM3d_Cross_CpsSph_CrossPos(param_1, param_2, param_1.GetEndP(), param_3); + cM3d_Cross_CpsSph_CrossPos(param_1, param_2, *param_1.GetEndP(), param_3); return true; } Vec auStack_34; @@ -1922,13 +1922,13 @@ inline f32 cM3d_2LinCenter(cM3dGLin const& pLinA, f32 pLinAF, cM3dGLin const& pL bool cM3d_Cross_CpsTri(cM3dGCps const& cps, cM3dGTri tri, Vec* param_2) { cM3dGSph sph; - sph.SetC(cps.GetStartP()); + sph.SetC(*cps.GetStartP()); sph.SetR(cps.GetR()); if (cM3d_Cross_SphTri(&sph, &tri, param_2)) { return true; } - sph.SetC(cps.GetEndP()); + sph.SetC(*cps.GetEndP()); sph.SetR(cps.GetR()); if (cM3d_Cross_SphTri(&sph, &tri, param_2)) { return true; @@ -2044,25 +2044,25 @@ static int cM3d_2PlaneCrossLine(const cM3dGPla& pPlaneA, const cM3dGPla& pPlaneB if (absTX >= absTY && absTX >= absTZ) { cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP()->y, pPlaneA.GetNP()->z, pPlaneB.GetNP()->y, pPlaneB.GetNP()->z, tmp.x, pPlaneA.GetD(), pPlaneB.GetD(), - &pLinOut->GetStartP().y, &pLinOut->GetStartP().z); - pLinOut->GetStartP().x = 0.0f; + &pLinOut->GetStartP()->y, &pLinOut->GetStartP()->z); + pLinOut->GetStartP()->x = 0.0f; } else if (absTY >= absTX && absTY >= absTZ) { cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP()->z, pPlaneA.GetNP()->x, pPlaneB.GetNP()->z, pPlaneB.GetNP()->x, tmp.y, pPlaneA.GetD(), pPlaneB.GetD(), - &pLinOut->GetStartP().z, &pLinOut->GetStartP().x); - pLinOut->GetStartP().y = 0.0f; + &pLinOut->GetStartP()->z, &pLinOut->GetStartP()->x); + pLinOut->GetStartP()->y = 0.0f; } else { cM3d_PlaneCrossLineProcWork(pPlaneA.GetNP()->x, pPlaneA.GetNP()->y, pPlaneB.GetNP()->x, pPlaneB.GetNP()->y, tmp.z, pPlaneA.GetD(), pPlaneB.GetD(), - &pLinOut->GetStartP().x, &pLinOut->GetStartP().y); - pLinOut->GetStartP().z = 0.0f; + &pLinOut->GetStartP()->x, &pLinOut->GetStartP()->y); + pLinOut->GetStartP()->z = 0.0f; } - f32 scale = VECMag(&pLinOut->GetStartP()); + f32 scale = VECMag(pLinOut->GetStartP()); if (cM3d_IsZero(scale)) { scale = 1.0f; } VECScale(&tmp, &tmp, scale); - VECAdd(&pLinOut->GetStartP(), &tmp, &pLinOut->GetEndP()); + VECAdd(pLinOut->GetStartP(), &tmp, pLinOut->GetEndP()); return 1; } } @@ -2073,10 +2073,10 @@ BOOL cM3d_3PlaneCrossPos(const cM3dGPla& pPlaneA, const cM3dGPla& pPlaneB, const if (!cM3d_2PlaneCrossLine(pPlaneA, pPlaneB, &lin)) { return false; } else { - const Vec* end = &lin.GetEndP(); - f32 tmpf1 = pPlaneC.getPlaneFunc(&lin.GetStartP()); + const Vec* end = lin.GetEndP(); + f32 tmpf1 = pPlaneC.getPlaneFunc(lin.GetStartP()); f32 tmpf2 = pPlaneC.getPlaneFunc(end); - if (!cM3d_CrossInfLineVsInfPlane_proc(tmpf1, tmpf2, &lin.GetStartP(), end, pVecOut)) { + if (!cM3d_CrossInfLineVsInfPlane_proc(tmpf1, tmpf2, lin.GetStartP(), end, pVecOut)) { return false; } else { return true; @@ -2094,10 +2094,10 @@ f32 cM3d_lineVsPosSuisenCross(const cM3dGLin* pLine, const Vec* pPoint, Vec* pVe *pVecOut = *pPoint; return 0.0f; } else { - VECSubtract(pPoint, &pLine->GetStartP(), &tmp2); + VECSubtract(pPoint, pLine->GetStartP(), &tmp2); f32 retVal = VECDotProduct(&tmp2, &tmp1) / diffLen; VECScale(&tmp1, &tmp3, retVal); - VECAdd(&tmp3, &pLine->GetStartP(), pVecOut); + VECAdd(&tmp3, pLine->GetStartP(), pVecOut); return retVal; } } diff --git a/src/d/actor/d_a_alink.cpp b/src/d/actor/d_a_alink.cpp index 93bfd80296..c05d595a3c 100644 --- a/src/d/actor/d_a_alink.cpp +++ b/src/d/actor/d_a_alink.cpp @@ -15717,7 +15717,7 @@ int daAlink_c::procMoveTurnInit(int param_0) { dComIfGp_setPlayerStatus0(0, 0x800); if (param_0 != 0) { - mProcVar3.field_0x300e = (mpHIO->mMove.m.mMaxTurnAngle * 4) + 19030; + mProcVar3.field_0x300e = (s16)((mpHIO->mMove.m.mMaxTurnAngle * 4) + 19030); mProcVar4.field_0x3010 = mpHIO->mMove.m.mMaxTurnAngle * 2; mProcVar1.field_0x300a = 2; current.angle.y = mMoveAngle; diff --git a/src/d/actor/d_a_b_bq.cpp b/src/d/actor/d_a_b_bq.cpp index 07b2ca4439..f109c11509 100644 --- a/src/d/actor/d_a_b_bq.cpp +++ b/src/d/actor/d_a_b_bq.cpp @@ -1872,7 +1872,7 @@ static void demo_camera(b_bq_class* i_this) { spFC.set(BREG_F(5) + -30.0f, 0.0f, BREG_F(6) + 1938.0f); } - daPy_getPlayerActorClass()->setPlayerPosAndAngle(&spFC, BREG_S(5) + 0x8000, 0); + daPy_getPlayerActorClass()->setPlayerPosAndAngle(&spFC, (s16)(BREG_S(5) + 0x8000), 0); if (i_this->field_0x5c8 != 0) { i_this->field_0x5cc.y += i_this->field_0x5d8; diff --git a/src/d/actor/d_a_b_mgn.cpp b/src/d/actor/d_a_b_mgn.cpp index e9c2235039..169db10cd3 100644 --- a/src/d/actor/d_a_b_mgn.cpp +++ b/src/d/actor/d_a_b_mgn.cpp @@ -1325,6 +1325,7 @@ void daB_MGN_c::executeDash() { } if (mMoveMode == 11) { + // @bug - parenthesis should not be on the condition if (abs((s16)(angle - field_0xa90) < 0x1800) != 0) { if ((s16)(angle - field_0xa90) < 0) { angle = field_0xa90 - 0x1800; diff --git a/src/d/actor/d_a_bg_obj.cpp b/src/d/actor/d_a_bg_obj.cpp index c7f5280df1..4c7fb4d03e 100644 --- a/src/d/actor/d_a_bg_obj.cpp +++ b/src/d/actor/d_a_bg_obj.cpp @@ -881,7 +881,7 @@ void daBgObj_c::setParticle() { for (; partNum != 0; partNum--) { u32 flags = *(BE(u32)*)partBlockItems++; u16 res_id = *(BE(u32)*)partBlockItems; - *partBlockItems++; + partBlockItems++; GXColor prmColor = { 0xFF, 0xFF, 0xFF, 0xFF }; GXColor envColor = { 0xFF, 0xFF, 0xFF, 0xFF }; diff --git a/src/d/actor/d_a_door_boss.cpp b/src/d/actor/d_a_door_boss.cpp index c1a135d42a..476a9c8ad6 100644 --- a/src/d/actor/d_a_door_boss.cpp +++ b/src/d/actor/d_a_door_boss.cpp @@ -254,7 +254,7 @@ BOOL daBdoor_c::checkArea() { if (fabsf(vec.z) > 100.0f) { return false; } - return (s16)fabs(current.angle.y - 0x7fff - player->current.angle.y) <= 0x4000 ? 1 : 0; + return (s16)fabs((f64)(current.angle.y - 0x7fff - player->current.angle.y)) <= 0x4000 ? 1 : 0; } BOOL daBdoor_c::checkFront() { diff --git a/src/d/actor/d_a_door_bossL1.cpp b/src/d/actor/d_a_door_bossL1.cpp index f187412a0b..a756cc6fd2 100644 --- a/src/d/actor/d_a_door_bossL1.cpp +++ b/src/d/actor/d_a_door_bossL1.cpp @@ -825,7 +825,7 @@ int daBdoorL1_c::checkArea() { if (fabsf(local_48.z) > 100.0f) { return 0; } - if ((s16)fabs(current.angle.y - 0x7fff - player->current.angle.y) <= 0x4000) { + if ((s16)fabs((f64)(current.angle.y - 0x7fff - player->current.angle.y)) <= 0x4000) { return 1; } else { return 0; diff --git a/src/d/actor/d_a_door_bossL5.cpp b/src/d/actor/d_a_door_bossL5.cpp index 3299c91216..d71fddad1f 100644 --- a/src/d/actor/d_a_door_bossL5.cpp +++ b/src/d/actor/d_a_door_bossL5.cpp @@ -348,7 +348,7 @@ int daBdoorL5_c::checkArea() { if (fabsf(local_48.z) > 100.0f) { return 0; } - if ((s16)fabs(current.angle.y - 0x7fff - player->current.angle.y) <= 0x4000) { + if ((s16)fabs((f64)(current.angle.y - 0x7fff - player->current.angle.y)) <= 0x4000) { return 1; } else { return 0; diff --git a/src/d/actor/d_a_door_mbossL1.cpp b/src/d/actor/d_a_door_mbossL1.cpp index a42aabd022..1f37fbcc7b 100644 --- a/src/d/actor/d_a_door_mbossL1.cpp +++ b/src/d/actor/d_a_door_mbossL1.cpp @@ -1318,7 +1318,7 @@ int daMBdoorL1_c::checkArea() { return 0; } - if ((s16)fabs(angle - 0x7fff - player->current.angle.y) > 0x4000) { + if ((s16)fabs((f64)(angle - 0x7fff - player->current.angle.y)) > 0x4000) { return 0; } else { return 1; diff --git a/src/d/actor/d_a_e_hz.cpp b/src/d/actor/d_a_e_hz.cpp index 86a0260e91..f2fb7d12b8 100644 --- a/src/d/actor/d_a_e_hz.cpp +++ b/src/d/actor/d_a_e_hz.cpp @@ -1934,7 +1934,13 @@ int daE_HZ_c::CreateHeap() { return 0; } + // This happens to work with MWCC since the member will only ever be initialized a pointer to a + // string in this TU's .data section, but comparing against a string literal is still UB. +#if AVOID_UB + if (strcmp(mpName, "E_hzp") == 0) { +#else if (mpName == "E_hzp") { +#endif modelData = (J3DModelData*)dComIfG_getObjectRes(mpName, 3); } else { modelData = (J3DModelData*)dComIfG_getObjectRes(mpName, 3); diff --git a/src/d/actor/d_a_e_kr.cpp b/src/d/actor/d_a_e_kr.cpp index de277a0e33..f21c83b50a 100644 --- a/src/d/actor/d_a_e_kr.cpp +++ b/src/d/actor/d_a_e_kr.cpp @@ -496,6 +496,7 @@ static s8 e_kr_path_move(e_kr_class* i_this) { if (totalDiff < 10.0f * TREG_F(10) + 300.0f) { point = &i_this->field_0x6e4->m_points[i_this->field_0x6e2]; u8 pointArg1 = point->mArg1; + // !@bug Comparison of u8 with -1 will always evaluate to false if (pointArg1 == -1) { i_this->field_0x684 = 50.0f * 1.2f; } else { diff --git a/src/d/actor/d_a_e_mm_mt.cpp b/src/d/actor/d_a_e_mm_mt.cpp index b745fa31c9..205cebab78 100644 --- a/src/d/actor/d_a_e_mm_mt.cpp +++ b/src/d/actor/d_a_e_mm_mt.cpp @@ -370,7 +370,7 @@ static void e_mm_mt_drop(e_mm_mt_class* i_this) { i_this->enemy.speed.y += -5.0f; i_this->enemy.eyePos = i_this->enemy.current.pos; i_this->enemy.attention_info.position = i_this->enemy.current.pos; - cLib_addCalcAngleS2(&i_this->m_rotation.z, (TREG_S(6)+0x10000)-0x8000, 1, 0x1000); + cLib_addCalcAngleS2(&i_this->m_rotation.z, (s16)((TREG_S(6) + 0x10000) - 0x8000), 1, 0x1000); cLib_onBit(i_this->enemy.attention_info.flags, fopAc_AttnFlag_CARRY_e); i_this->enemy.attention_info.distances[fopAc_attn_CARRY_e] = 7; i_this->m_rotation.y += i_this->m_spin; diff --git a/src/d/actor/d_a_e_oc.cpp b/src/d/actor/d_a_e_oc.cpp index 0403896e70..01f282b0ea 100644 --- a/src/d/actor/d_a_e_oc.cpp +++ b/src/d/actor/d_a_e_oc.cpp @@ -724,7 +724,13 @@ void daE_OC_c::damage_check() { } else if (mAtInfo.mpCollider->ChkAtType(AT_TYPE_40)) { S16_ADD(health, 10); } else if (mAtInfo.mpCollider->ChkAtType(AT_TYPE_SLINGSHOT)) { + // This happens to work with MWCC since the member will only ever be initialized a pointer to a + // string in this TU's .data section, but comparing against a string literal is still UB. +#if AVOID_UB + if (strcmp(mName, "E_OC") == 0) { +#else if (mName == "E_OC") { +#endif S16_SUB(health, 5); if (health < 0) { health = 0; @@ -855,7 +861,12 @@ void daE_OC_c::setDashSound() { } else if (mpMorf->checkFrame(8.5f)) { mSound.startCreatureSound(Z2SE_EN_OC_FOOTNOTE_R, 0, -1); } + // See comment in damage_check +#if AVOID_UB + if (strcmp(mName, "E_OC") == 0) { +#else if (mName == "E_OC") { +#endif mSound.startCreatureSoundLevel(Z2SE_EN_OC_CLUB_DAGGLE, 0, -1); } else { mSound.startCreatureSoundLevel(Z2SE_EN_OC_NATA_DAGGLE, 0, -1); @@ -1421,7 +1432,12 @@ void daE_OC_c::executeAttack() { } else if (mpMorf->checkFrame(12.5f)) { mSound.startCreatureSound(Z2SE_EN_OC_ATTACK_B, 0, -1); } else if (mpMorf->checkFrame(19.0f)) { + // See comment in damage_check +#if AVOID_UB + if (strcmp(mName, "E_OC") == 0) { +#else if (mName == "E_OC") { +#endif mSound.startCreatureSound(Z2SE_EN_OC_CLUB_HIT, 0, -1); } else { mSound.startCreatureSound(Z2SE_EN_OC_NATA_HIT, 0, -1); @@ -1843,7 +1859,12 @@ void daE_OC_c::executeDeath() { case 2: cLib_chaseF(&speedF, 0.0f, 1.0f); if (field_0x6c0 == 0) { + // See comment in damage_check +#if AVOID_UB + if (strcmp(mName, "E_OC") == 0) { +#else if (mName == "E_OC") { +#endif fopAcM_createDisappear(this, ¤t.pos, 10, 0, 4); } else { fopAcM_createDisappear(this, ¤t.pos, 10, 0, 0x34); @@ -1917,7 +1938,12 @@ void daE_OC_c::executeWaterDeath() { } if (mpMorf->isStop()) { + // See comment in damage_check +#if AVOID_UB + if (strcmp(mName, "E_OC") == 0) { +#else if (mName == "E_OC") { +#endif fopAcM_createDisappear(this, ¤t.pos, 10, 0, 4); } else { fopAcM_createDisappear(this, ¤t.pos, 10, 0, 0x34); @@ -2741,7 +2767,12 @@ cPhs_Step daE_OC_c::create() { mAcchCir.SetWallH(70.0f); } mAcchCir.SetWallR(100.0f); + // See comment in damage_check +#if AVOID_UB + if (strcmp(mName, "E_OC") == 0) { +#else if (mName == "E_OC") { +#endif field_0x560 = health = 40; } else { field_0x560 = health = 220; @@ -2756,7 +2787,12 @@ cPhs_Step daE_OC_c::create() { mSphs_at[0].SetStts(&mStts); mSphs_at[1].Set(E_OC_n::at_sph_src); mSphs_at[1].SetStts(&mStts); + // See comment in damage_check +#if AVOID_UB + if (strcmp(mName, "E_OC") == 0) { +#else if (mName == "E_OC") { +#endif mSphs_at[0].SetAtAtp(1); mSphs_at[1].SetAtAtp(1); fopAcM_OnStatus(this, fopAcStts_UNK_0x10000_e); diff --git a/src/d/actor/d_a_e_rdy.cpp b/src/d/actor/d_a_e_rdy.cpp index 4e13d7e3ed..305fc55efe 100644 --- a/src/d/actor/d_a_e_rdy.cpp +++ b/src/d/actor/d_a_e_rdy.cpp @@ -2155,7 +2155,7 @@ static void e_rdy_damage(e_rdy_class* i_this) { case 1: if (i_this->mAcch.ChkWallHit() && i_this->mTimer[0] == 0) { - if (check = kado_check(i_this)) { + if ((check = kado_check(i_this))) { OS_REPORT(" ..KADO KABE ..%x\n", check); if (check == 2) { i_this->field_0xac6 = 0x1000; @@ -4721,7 +4721,7 @@ static int daE_RDY_Execute(e_rdy_class* i_this) { } MTXCopy(i_this->mpMorf->getModel()->getAnmMtx(JNT_HAND_R), *calc_mtx); MtxTrans(20.0f + NREG_F(0), 5.0f + NREG_F(1), -10.0f + NREG_F(2), 1); - cMtx_XrotM(*calc_mtx, NREG_S(0) + 0x8000); + cMtx_XrotM(*calc_mtx, (s16)(NREG_S(0) + 0x8000)); cMtx_YrotM(*calc_mtx, NREG_S(1) + ang_y + -0x15cd); cMtx_ZrotM(*calc_mtx, NREG_S(2) + 0x28cd); i_this->mpHawkGrassModel->setBaseTRMtx(*calc_mtx); diff --git a/src/d/actor/d_a_e_wb.cpp b/src/d/actor/d_a_e_wb.cpp index 6ff349c4a6..819439879e 100644 --- a/src/d/actor/d_a_e_wb.cpp +++ b/src/d/actor/d_a_e_wb.cpp @@ -1100,7 +1100,7 @@ static void e_wb_f_run(e_wb_class* i_this) { } else { e_rd_class* local_90 = (e_rd_class*)fopAcM_SearchByID(i_this->rd_id); int saku; - if (saku = e_wb_saku_check(i_this)) { + if ((saku = e_wb_saku_check(i_this))) { i_this->field_0x6d4 = 60; if ((saku & 2) != 0) { i_this->field_0x6d6 = 0x3000; diff --git a/src/d/actor/d_a_e_yg.cpp b/src/d/actor/d_a_e_yg.cpp index 6e02f7cb0b..43f91ee793 100644 --- a/src/d/actor/d_a_e_yg.cpp +++ b/src/d/actor/d_a_e_yg.cpp @@ -1235,7 +1235,7 @@ static int daE_YG_Execute(e_yg_class* i_this) { MTXCopy(daPy_getLinkPlayerActorClass()->getWolfMouthMatrix(), mDoMtx_stack_c::get()); mDoMtx_stack_c::multVecZero(&actor->current.pos); mDoMtx_stack_c::YrotM(KREG_S(0)); - mDoMtx_stack_c::XrotM(KREG_S(1) + 0x8000); + mDoMtx_stack_c::XrotM((s16)(KREG_S(1) + 0x8000)); mDoMtx_stack_c::ZrotM(KREG_S(2) + 2500); mDoMtx_stack_c::transM(KREG_F(0) + 10.0f, KREG_F(1) + -60.0f, KREG_F(2) + -20.0f); model->setBaseTRMtx(mDoMtx_stack_c::get()); diff --git a/src/d/actor/d_a_e_yh.cpp b/src/d/actor/d_a_e_yh.cpp index d37bdd1749..bbbd3e5129 100644 --- a/src/d/actor/d_a_e_yh.cpp +++ b/src/d/actor/d_a_e_yh.cpp @@ -1930,7 +1930,7 @@ static void eff_set(e_yh_class* i_this) { dComIfGp_particle_set(i_this->mParticleIds2[2], dPa_RM(ID_ZI_S_YD_YODAHIT_A), &a_this->current.pos, 0, NULL); { - JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticleIds[5]); + JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticleIds2[2]); if (emitter != NULL) { MTXCopy(model->getAnmMtx(1), *calc_mtx); emitter->setGlobalRTMatrix(*calc_mtx); diff --git a/src/d/actor/d_a_e_ymb.cpp b/src/d/actor/d_a_e_ymb.cpp index 7a18b75a2c..e107b2a8b9 100644 --- a/src/d/actor/d_a_e_ymb.cpp +++ b/src/d/actor/d_a_e_ymb.cpp @@ -516,7 +516,7 @@ void daE_YMB_c::checkWaterPos() { field_0x6cc = wtr_pos; field_0x69c.y = wtr_pos + 1000.0f + l_HIO.fly_height_adjust; - std::fabsf(field_0x6cc - current.pos.y); + UNUSED(std::fabsf(field_0x6cc - current.pos.y)); if (current.pos.y < (200.0f + field_0x6cc)) { if (field_0x715 == 0) { setWaterEffect1(); diff --git a/src/d/actor/d_a_e_zh.cpp b/src/d/actor/d_a_e_zh.cpp index fb64be0f5e..827a8fd36a 100644 --- a/src/d/actor/d_a_e_zh.cpp +++ b/src/d/actor/d_a_e_zh.cpp @@ -542,7 +542,7 @@ bool daE_ZH_c::mBallBgLineCheck() { bool daE_ZH_c::mSearchMove(u8 param_1) { if (mS_Ball == NULL) { setActionMode(ACTION_EXECUTE_FLY_DELETE, 0); - return NULL; + return false; } cXyz sp50, sp5c; diff --git a/src/d/actor/d_a_horse.cpp b/src/d/actor/d_a_horse.cpp index 14090b75d6..db0542058a 100644 --- a/src/d/actor/d_a_horse.cpp +++ b/src/d/actor/d_a_horse.cpp @@ -51,9 +51,10 @@ #define ANM_HS_WALK_FAST 34 #define ANM_HS_WALK_SLOW 35 -static f32* strippedFunc() { - f32 v[3] = {}; - return v; +static void strippedFunc() { + extern void F(f32*); + f32 v[3] = {0.0f}; + F(v); } static char const l_arcName[] = "Horse"; diff --git a/src/d/actor/d_a_mg_rod.cpp b/src/d/actor/d_a_mg_rod.cpp index 1fae2979fe..96ad7aa148 100644 --- a/src/d/actor/d_a_mg_rod.cpp +++ b/src/d/actor/d_a_mg_rod.cpp @@ -2977,8 +2977,8 @@ static void hook_set(dmg_rod_class* i_this, cXyz* param_1, int param_2) { mDoMtx_stack_c::XrotM(-0x4000); if (param_2 == 1 && (i_this->action <= ACTION_LURE_STANDBY || (i_this->lure_type != MG_LURE_SP && i_this->action == ACTION_LURE_CATCH))) { - sp38.x = fabsf(hook->field_0x18.y); - sp38.z = fabsf(hook->field_0x18.x - 0x4000); + sp38.x = fabsf((f32)hook->field_0x18.y); + sp38.z = fabsf((f32)(hook->field_0x18.x - 0x4000)); f32 var_f31 = JMAFastSqrt(SQUARE(sp38.x) + SQUARE(sp38.z)); if (var_f31 > 7000.0f) { diff --git a/src/d/actor/d_a_nbomb.cpp b/src/d/actor/d_a_nbomb.cpp index 070fdc2c7f..4a185c9561 100644 --- a/src/d/actor/d_a_nbomb.cpp +++ b/src/d/actor/d_a_nbomb.cpp @@ -986,7 +986,7 @@ BOOL daNbomb_c::procWait() { speedF *= player->getBombBoundRate(); current.angle.y = (mAcchCir.GetWallAngleY() * 2) - (current.angle.y + 0x8000); } else if (mAcch.ChkGroundLanding() && speedF > 5.0f && cM_deg2s(50.0f) <= field_0xb5a) { - if ((f32)fabs(var_r28) >= (f32)0x4000) { + if ((f32)fabs((f64)var_r28) >= (f32)0x4000) { speedF *= player->getBombBoundRate(); current.angle.y = (var_r27 * 2) - (current.angle.y + 0x8000); mAcch.ClrGroundLanding(); diff --git a/src/d/actor/d_a_npc2.cpp b/src/d/actor/d_a_npc2.cpp index 9d5d0beee8..f629c0b562 100644 --- a/src/d/actor/d_a_npc2.cpp +++ b/src/d/actor/d_a_npc2.cpp @@ -544,7 +544,7 @@ void daBaseNpc_c::orderEvent(int param_0, char* i_evtName) { if (i_evtName != NULL) { mEvtIdx = dComIfGp_getEventManager().getEventIdx(this, i_evtName, -1); fopAcM_orderOtherEventId(this, mEvtIdx, 0xFF, 0xFFFF, 0, 1); - } else if (field_0x848 >= 0 && attention_info.flags == (fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e)) { + } else if (mFlowID >= 0 && attention_info.flags == (fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e)) { eventInfo.onCondition(1); if (param_0 != 0) { fopAcM_orderSpeakEvent(this, 0, 0); diff --git a/src/d/actor/d_a_npc_bou.cpp b/src/d/actor/d_a_npc_bou.cpp index f5b94392e5..775bfd7c4c 100644 --- a/src/d/actor/d_a_npc_bou.cpp +++ b/src/d/actor/d_a_npc_bou.cpp @@ -635,7 +635,7 @@ void daNpc_Bou_c::action() { hit_actor = field_0xba0.getActorP(); if (hit_actor != NULL) { - abs( (s16)(fopAcM_searchPlayerAngleY(this) - mCurAngle.y) ); + UNUSED(abs((s16)(fopAcM_searchPlayerAngleY(this) - mCurAngle.y))); switch (((daTag_Push_c*) hit_actor)->getId()) { case 7: { mEvtNo = 8; diff --git a/src/d/actor/d_a_npc_chat.cpp b/src/d/actor/d_a_npc_chat.cpp index 8a963d2497..39ebb0313c 100644 --- a/src/d/actor/d_a_npc_chat.cpp +++ b/src/d/actor/d_a_npc_chat.cpp @@ -2628,7 +2628,7 @@ BOOL daNpcChat_c::setAttention(int param_1) { cXyz(0.0f, 10.0f, 0.0f), }; - int jointNo = isM_() ? JNTM_HEAD : JNTW_HEAD; + int jointNo = isM_() ? (int)JNTM_HEAD : (int)JNTW_HEAD; mDoMtx_stack_c::copy(mAnm_p->getModel()->getAnmMtx(jointNo)); mDoMtx_stack_c::multVec(&a_eyeOfsTbl[param_1], &eyePos); mBaseAttnPos.set(current.pos.x, current.pos.y + AtnOfs(param_1), current.pos.z); diff --git a/src/d/actor/d_a_npc_coach.cpp b/src/d/actor/d_a_npc_coach.cpp index abd3dac290..51a5019088 100644 --- a/src/d/actor/d_a_npc_coach.cpp +++ b/src/d/actor/d_a_npc_coach.cpp @@ -517,8 +517,7 @@ BOOL daNpcChPath_c::setPath(int path_index, int room_no, cXyz& i_vec, bool param mCurrentID = path_index; mPntIndex = 0; - // Is this really what the Nintendo devs wrote?? The debug ROM suggests as such. - if (param_4 && &i_vec) { + if (param_4 && IS_REF_NONNULL(i_vec)) { f32 fVar1 = G_CM3D_F_INF; for (int pnt_index = 0; pnt_index < mpPath->m_num; pnt_index++) { dPnt* pnt = dPath_GetPnt(mpPath, pnt_index); @@ -534,8 +533,7 @@ BOOL daNpcChPath_c::setPath(int path_index, int room_no, cXyz& i_vec, bool param field_0x8 = G_CM3D_F_INF; - // ditto. - if (&i_vec) { + if (IS_REF_NONNULL(i_vec)) { field_0x4 = &i_vec; cXyz targetPoint; getTargetPoint(targetPoint); diff --git a/src/d/actor/d_a_npc_gra.cpp b/src/d/actor/d_a_npc_gra.cpp index 03c6e2279b..e1db3b4568 100644 --- a/src/d/actor/d_a_npc_gra.cpp +++ b/src/d/actor/d_a_npc_gra.cpp @@ -343,10 +343,13 @@ BOOL daNpc_grA_c::create() { mType = getTypeFromParam(); mMode = getMode(); mSwBit = getSwBit(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xffff) { - field_0x146C = home.angle.x; + mFlowID = home.angle.x; } else{ - field_0x146C = -1; + mFlowID = -1; } if (isDelete()) { return cPhs_ERROR_e; @@ -2146,7 +2149,7 @@ BOOL daNpc_grA_c::ECut_talkSpa(int i_staffID) { setLookMode(5); break; case 1: - initTalk(field_0x146C, arr); + initTalk(mFlowID, arr); break; case 2: if (daNpcF_chkEvtBit(6) && daNpcF_chkEvtBit(0x3e) == FALSE) { @@ -3020,7 +3023,7 @@ BOOL daNpc_grA_c::ECut_rollRockCrash(int i_staffID) { break; case 0x14: { setLookMode(0); - initTalk(field_0x146C, NULL); + initTalk(mFlowID, NULL); cXyz c(200.0f, 100.0f, 0.0f); mDoMtx_stack_c::YrotS(home.angle.y); mDoMtx_stack_c::multVec(&c, &c); @@ -3588,7 +3591,7 @@ BOOL daNpc_grA_c::waitSpaWater(void*) { } setLookMode(0); mTurnMode = 0; - field_0x146C = 0x28; + mFlowID = 0x28; field_0x1472 = 2; field_0x9ea = 1; // fallthrough @@ -3968,7 +3971,7 @@ BOOL daNpc_grA_c::talk(void*) { setGateWalk(); } } else { - r27 = field_0x146C; + r27 = mFlowID; } initTalk(r27, NULL); field_0x1484 = fopAcM_searchPlayerAngleY(this); diff --git a/src/d/actor/d_a_npc_grc.cpp b/src/d/actor/d_a_npc_grc.cpp index cf4a2b58a7..f41578bcaa 100644 --- a/src/d/actor/d_a_npc_grc.cpp +++ b/src/d/actor/d_a_npc_grc.cpp @@ -308,6 +308,9 @@ cPhs_Step daNpc_grC_c::create() { mTwilight = dKy_darkworld_check(); mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { mFlowID = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_grd.cpp b/src/d/actor/d_a_npc_grd.cpp index 5075c0b22a..8f006bf4cf 100644 --- a/src/d/actor/d_a_npc_grd.cpp +++ b/src/d/actor/d_a_npc_grd.cpp @@ -172,6 +172,9 @@ int daNpc_Grd_c::create() { mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xffff) { mFlowID = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_gro.cpp b/src/d/actor/d_a_npc_gro.cpp index 7b20d908d4..785136559f 100644 --- a/src/d/actor/d_a_npc_gro.cpp +++ b/src/d/actor/d_a_npc_gro.cpp @@ -396,6 +396,9 @@ cPhs_Step daNpc_grO_c::create() { mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { mMsgNo = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_grr.cpp b/src/d/actor/d_a_npc_grr.cpp index 4942aec8ae..39689144f4 100644 --- a/src/d/actor/d_a_npc_grr.cpp +++ b/src/d/actor/d_a_npc_grr.cpp @@ -264,6 +264,9 @@ cPhs_Step daNpc_grR_c::create() { mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { mFlowID = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_grs.cpp b/src/d/actor/d_a_npc_grs.cpp index 1ab19544cf..401634d2ab 100644 --- a/src/d/actor/d_a_npc_grs.cpp +++ b/src/d/actor/d_a_npc_grs.cpp @@ -138,10 +138,13 @@ int daNpc_grS_c::create() { mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xffff) { - field_0xe0c = home.angle.x; + mFlowID = home.angle.x; } else { - field_0xe0c = -1; + mFlowID = -1; } if (isDelete()) { @@ -856,7 +859,7 @@ int daNpc_grS_c::selectAction() { mpNextActionFn = &daNpc_grS_c::test; } else { - (int)mType; + UNUSED((int)mType); mpNextActionFn = &daNpc_grS_c::wait; } @@ -936,7 +939,7 @@ int daNpc_grS_c::doEvent() { if (eventInfo.checkCommandDemoAccrpt() && mEventIdx != -1 && eventManager->endCheck(mEventIdx)) { - (int)mOrderEvtNo; + UNUSED((int)mOrderEvtNo); dComIfGp_event_reset(); mOrderEvtNo = 0; mEventIdx = -1; @@ -1157,7 +1160,7 @@ int daNpc_grS_c::talk(void* param_0) { daNpcF_offTmpBit(11); } - unkInt1 = field_0xe0c; + unkInt1 = mFlowID; mIsSpeaking = false; initTalk(unkInt1, NULL); mTurnMode = 0; diff --git a/src/d/actor/d_a_npc_grz.cpp b/src/d/actor/d_a_npc_grz.cpp index e417f1d47b..c245340c4c 100644 --- a/src/d/actor/d_a_npc_grz.cpp +++ b/src/d/actor/d_a_npc_grz.cpp @@ -455,6 +455,9 @@ cPhs_Step daNpc_Grz_c::create() { mType = getTypeFromParam(); mSwNo = fopAcM_GetParam(this) >> 16; + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { mMsgNo = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_gwolf.cpp b/src/d/actor/d_a_npc_gwolf.cpp index 45c1025e0e..9956468e41 100644 --- a/src/d/actor/d_a_npc_gwolf.cpp +++ b/src/d/actor/d_a_npc_gwolf.cpp @@ -291,10 +291,13 @@ cPhs_Step daNpc_GWolf_c::create() { mExitId = fopAcM_GetParam(this) >> 24; + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { - field_0xe08 = home.angle.x; + mFlowID = home.angle.x; } else { - field_0xe08 = -1; + mFlowID = -1; } swBit = getSwBitFromParam(); @@ -1817,7 +1820,7 @@ BOOL daNpc_GWolf_c::talk(void* param_1) { break; } - int msgNo = field_0xe08; + int msgNo = mFlowID; mOrderSpeakEvt = false; initTalk(msgNo, NULL); mTurnMode = 0; diff --git a/src/d/actor/d_a_npc_kn.cpp b/src/d/actor/d_a_npc_kn.cpp index 3a39a0b196..63db584cda 100644 --- a/src/d/actor/d_a_npc_kn.cpp +++ b/src/d/actor/d_a_npc_kn.cpp @@ -4961,11 +4961,11 @@ int daNpc_Kn_c::setPrtcl() { // cXyz* pos = mParticleMngr[i].mpModel == true ? &mParticleMngr[i].mPos : NULL; mParticleMngr[i].mManager.setEffectCenter(&tevStr, &mParticleMngr[i].mPos, check, sp_0x18, - mParticleMngr[i].mpModel == true ? &mParticleMngr[i].mPos : NULL, - mParticleMngr[i].mpModel == true ? &mParticleMngr[i].mAngle : NULL, + mParticleMngr[i].field_0x00 == true ? &mParticleMngr[i].mPos : NULL, + mParticleMngr[i].field_0x00 == true ? &mParticleMngr[i].mAngle : NULL, 0, fopAcM_GetRoomNo(this), 0.0f, speedF); - if (mParticleMngr[i].mpModel != false) { + if (mParticleMngr[i].field_0x00 != false) { emitter = mParticleMngr[i].mManager.getCenterEmitter(0, 0); if (emitter != NULL) { switch (i) { @@ -4984,7 +4984,7 @@ int daNpc_Kn_c::setPrtcl() { } } - mParticleMngr[i].mpModel = NULL; + mParticleMngr[i].field_0x00 = false; } return 1; @@ -4996,21 +4996,21 @@ int daNpc_Kn_c::setSlipPrtcl() { mParticleMngr[0].mPos.y -= 20.0f; mParticleMngr[0].mAngle = current.angle; ANGLE_SUB_2(mParticleMngr[0].mAngle.y, 0x8000); - mParticleMngr[0].mpModel = true; + mParticleMngr[0].field_0x00 = true; mDoMtx_stack_c::copy(mpModelMorf[0]->getModel()->getAnmMtx(0x1b)); mDoMtx_stack_c::multVecZero(&mParticleMngr[1].mPos); mParticleMngr[1].mPos.y -= 20.0f; mParticleMngr[1].mAngle = current.angle; ANGLE_SUB_2(mParticleMngr[1].mAngle.y, 0x8000); - mParticleMngr[1].mpModel = true; + mParticleMngr[1].field_0x00 = true; return 1; } int daNpc_Kn_c::setLandingPrtcl() { mParticleMngr[2].mPos = current.pos; mParticleMngr[2].mAngle = mCurAngle; - mParticleMngr[2].mpModel = true; + mParticleMngr[2].field_0x00 = true; return 1; } diff --git a/src/d/actor/d_a_npc_ks.cpp b/src/d/actor/d_a_npc_ks.cpp index 7d7dc1802b..1d60f5a10a 100644 --- a/src/d/actor/d_a_npc_ks.cpp +++ b/src/d/actor/d_a_npc_ks.cpp @@ -250,7 +250,13 @@ static int daNpc_Ks_Draw(npc_ks_class* i_this) { fopAc_ac_c* actor = &i_this->actor; J3DModel* model = i_this->model->getModel(); + // This happens to work with MWCC since the member will only ever be initialized a pointer to a + // string in this TU's .data section, but comparing against a string literal is still UB. +#if AVOID_UB + if (strcmp(i_this->res_name, "Npc_kst") == 0) { +#else if (i_this->res_name == "Npc_kst") { +#endif g_env_light.settingTevStruct(4, &actor->current.pos, &actor->tevStr); } else { g_env_light.settingTevStruct(0, &actor->current.pos, &actor->tevStr); diff --git a/src/d/actor/d_a_npc_myna2.cpp b/src/d/actor/d_a_npc_myna2.cpp index f7d8b7f048..d78b94fc5f 100644 --- a/src/d/actor/d_a_npc_myna2.cpp +++ b/src/d/actor/d_a_npc_myna2.cpp @@ -189,10 +189,13 @@ int daNpc_myna2_c::create() { mType = getTypeFromParam(); field_0xe0d = (fopAcM_GetParam(this) & 0xFF00) >> 8; + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { - field_0xe04 = home.angle.x; + mFlowID = home.angle.x; } else { - field_0xe04 = -1; + mFlowID = -1; } if (isDelete()) { @@ -928,7 +931,7 @@ int daNpc_myna2_c::talk(void* param_0) { switch (mMode) { case 0: if (!mIsDamaged) { - initTalk(field_0xe04, NULL); + initTalk(mFlowID, NULL); mTurnMode = 0; mAnm_p->setPlaySpeed(1.0f); mMode = 2; @@ -1014,7 +1017,7 @@ int daNpc_myna2_c::ECut_firstTalk(int i_staffId) { case 10: break; case 20: - initTalk(field_0xe04, NULL); + initTalk(mFlowID, NULL); break; } } @@ -1063,7 +1066,7 @@ int daNpc_myna2_c::ECut_gameFailure(int i_staffId) { case 20: break; case 10: - initTalk(field_0xe04, NULL); + initTalk(mFlowID, NULL); break; } } @@ -1121,7 +1124,7 @@ int daNpc_myna2_c::ECut_gameGoal(int i_staffId) { } break; case 10: - initTalk(field_0xe04, NULL); + initTalk(mFlowID, NULL); break; case 20: break; @@ -1183,7 +1186,7 @@ int daNpc_myna2_c::ECut_gameGoalSuccess(int i_staffId) { } break; case 10: - initTalk(field_0xe04, NULL); + initTalk(mFlowID, NULL); break; case 20: { int itemNo = 0; @@ -1193,7 +1196,7 @@ int daNpc_myna2_c::ECut_gameGoalSuccess(int i_staffId) { break; } case 25: - initTalk(field_0xe04, NULL); + initTalk(mFlowID, NULL); break; case 30: break; diff --git a/src/d/actor/d_a_npc_ne.cpp b/src/d/actor/d_a_npc_ne.cpp index 0ff4c01d41..ae43981593 100644 --- a/src/d/actor/d_a_npc_ne.cpp +++ b/src/d/actor/d_a_npc_ne.cpp @@ -135,7 +135,13 @@ static int daNpc_Ne_Draw(npc_ne_class* i_this) { } J3DModel* model = i_this->mpMorf->getModel(); + // This happens to work with MWCC since the member will only ever be initialized a pointer to a + // string in this TU's .data section, but comparing against a string literal is still UB. +#if AVOID_UB + if (strcmp(i_this->mResName, "Npc_net") == 0) { +#else if (i_this->mResName == "Npc_net") { +#endif if (!dComIfGs_wolfeye_effect_check()) { return 1; } @@ -426,7 +432,12 @@ static void npc_ne_wait(npc_ne_class* i_this) { daPy_py_c* player = static_cast(dComIfGp_getPlayer(0)); cLib_addCalc0(&_this->speedF, 1.0f, 1.3f); + // See comment in daNpc_Ne_Draw +#if AVOID_UB + if (strcmp(i_this->mResName, "Npc_net") == 0) { +#else if (i_this->mResName == "Npc_net") { +#endif switch (i_this->mMode) { case 0: i_this->mTargetAngleY = cM_rndF(0x10000); @@ -2173,7 +2184,12 @@ static void action(npc_ne_class* i_this) { _this->gravity = -7.0f; + // See comment in daNpc_Ne_Draw +#if AVOID_UB + if (strcmp(i_this->mResName, "Npc_net") == 0) { +#else if (i_this->mResName == "Npc_net") { +#endif i_this->mDistToTarget = 10000.0f; } else { i_this->mDistToTarget = i_this->mDistScale * fopAcM_searchPlayerDistance(_this); @@ -2298,9 +2314,15 @@ static void action(npc_ne_class* i_this) { break; } + // See comment in daNpc_Ne_Draw +#if AVOID_UB + if (strcmp(i_this->mResName, "Npc_net") != 0) { +#else if (i_this->mResName != "Npc_net") { - if (i_this->mMessageState == 1 && daPy_py_c::checkNowWolf() - && i_this->mDistToTarget < 300.0f) { +#endif + if (i_this->mMessageState == 1 && + daPy_py_c::checkNowWolf() && + i_this->mDistToTarget < 300.0f) { i_this->mAction = npc_ne_class::ACT_MESSAGE; i_this->mMode = 0; bird_check = false; @@ -2846,8 +2868,15 @@ static void demo_camera(npc_ne_class* i_this) { } static int message(npc_ne_class* i_this) { - if (i_this->mResName == "Npc_net" && !dComIfGs_wolfeye_effect_check()) { - i_this->mMessageState = 0; + // See comment in daNpc_Ne_Draw +#if AVOID_UB + if (strcmp(i_this->mResName, "Npc_net") == 0) { +#else + if (i_this->mResName == "Npc_net") { +#endif + if (!dComIfGs_wolfeye_effect_check()) { + i_this->mMessageState = 0; + } } if (i_this->mIsTalking) { @@ -2872,7 +2901,12 @@ static int message(npc_ne_class* i_this) { !fopAcM_otherBgCheck(daPy_getLinkPlayerActorClass(), i_this)) { fopAcM_OnStatus(i_this, 0); cLib_onBit(i_this->attention_info.flags, fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e); + // See comment in daNpc_Ne_Draw +#if AVOID_UB + if (strcmp(i_this->mResName, "Npc_net") == 0) { +#else if (i_this->mResName == "Npc_net") { +#endif cLib_onBit(i_this->attention_info.flags, fopAc_AttnFlag_UNK_0x800000 | fopAc_AttnFlag_UNK_0x400000); } i_this->eventInfo.onCondition(dEvtCnd_CANTALK_e); @@ -2978,14 +3012,21 @@ static int daNpc_Ne_Execute(npc_ne_class* i_this) { message(i_this); demo_camera(i_this); - if (i_this->mResName == "Npc_net" && !dComIfGs_wolfeye_effect_check()) { - static u16 e_name[2] = {0x8497, 0x8498}; - for (int i = 0; i < 2; i++) { - i_this->mParticle[i] = dComIfGp_particle_set(i_this->mParticle[i], e_name[i], - &i_this->eyePos, NULL, NULL); - JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticle[i]); - if (emitter != NULL) { - emitter->setGlobalAlpha(!dComIfGs_wolfeye_effect_check() ? 0xff : 0); + // See comment in daNpc_Ne_Draw +#if AVOID_UB + if (strcmp(i_this->mResName, "Npc_net") == 0) { +#else + if (i_this->mResName == "Npc_net") { +#endif + if (!dComIfGs_wolfeye_effect_check()) { + static u16 e_name[2] = {0x8497, 0x8498}; + for (int i = 0; i < 2; i++) { + i_this->mParticle[i] = dComIfGp_particle_set(i_this->mParticle[i], e_name[i], + &i_this->eyePos, NULL, NULL); + JPABaseEmitter* emitter = dComIfGp_particle_getEmitter(i_this->mParticle[i]); + if (emitter != NULL) { + emitter->setGlobalAlpha(!dComIfGs_wolfeye_effect_check() ? 0xff : 0); + } } } } @@ -3231,7 +3272,12 @@ static cPhs_Step daNpc_Ne_Create(fopAc_ac_c* i_this) { _this->mAcchCir.SetWall(_this->mBaseScale.y * 30.0f, _this->mBaseScale.z * 35.0f); _this->mDistScale = cM_rndFX(0.2f) + 1.0f; _this->mGroundY = i_this->current.pos.y; + // See comment in daNpc_Ne_Draw +#if AVOID_UB + if (strcmp(_this->mResName, "Npc_net") == 0) { +#else if (_this->mResName == "Npc_net") { +#endif _this->mAction = npc_ne_class::ACT_WAIT; _this->mMode = 0; } diff --git a/src/d/actor/d_a_npc_pachi_maro.cpp b/src/d/actor/d_a_npc_pachi_maro.cpp index b87bfcb32a..9631bd42ba 100644 --- a/src/d/actor/d_a_npc_pachi_maro.cpp +++ b/src/d/actor/d_a_npc_pachi_maro.cpp @@ -1098,7 +1098,7 @@ int daNpc_Pachi_Maro_c::wait(void* param_1) { } if (mJntAnm.getMode() == 0) { - (s32)mType; + UNUSED((int)mType); } } break; diff --git a/src/d/actor/d_a_npc_pachi_taro.cpp b/src/d/actor/d_a_npc_pachi_taro.cpp index 6ceb762239..1da06ded50 100644 --- a/src/d/actor/d_a_npc_pachi_taro.cpp +++ b/src/d/actor/d_a_npc_pachi_taro.cpp @@ -1464,7 +1464,7 @@ int daNpc_Pachi_Taro_c::wait(void* param_1) { // ??? if (mJntAnm.getMode() == 0) { - (int)mType; + UNUSED((int)mType); } if (field_0x1004 == 0) { diff --git a/src/d/actor/d_a_npc_post.cpp b/src/d/actor/d_a_npc_post.cpp index b6333d699e..e47d4c3e13 100644 --- a/src/d/actor/d_a_npc_post.cpp +++ b/src/d/actor/d_a_npc_post.cpp @@ -696,7 +696,7 @@ BOOL daNpc_Post_c::checkChangeEvt() { return TRUE; } - (int)mType; + UNUSED((int)mType); } return FALSE; diff --git a/src/d/actor/d_a_npc_soldierA.cpp b/src/d/actor/d_a_npc_soldierA.cpp index 54718eb9f7..14e188e4a8 100644 --- a/src/d/actor/d_a_npc_soldierA.cpp +++ b/src/d/actor/d_a_npc_soldierA.cpp @@ -206,6 +206,9 @@ cPhs_Step daNpc_SoldierA_c::create() { mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { mMsgNo = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_soldierB.cpp b/src/d/actor/d_a_npc_soldierB.cpp index c1eddb23c8..8ee1762ca4 100644 --- a/src/d/actor/d_a_npc_soldierB.cpp +++ b/src/d/actor/d_a_npc_soldierB.cpp @@ -171,6 +171,9 @@ cPhs_Step daNpc_SoldierB_c::create() { mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xFFFF) { mMsgNo = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_theB.cpp b/src/d/actor/d_a_npc_theB.cpp index 6cdb85a3fe..71704f9717 100644 --- a/src/d/actor/d_a_npc_theB.cpp +++ b/src/d/actor/d_a_npc_theB.cpp @@ -244,6 +244,9 @@ cPhs_Step daNpcTheB_c::create() { return cPhs_ERROR_e; } + // !@bug The return value (an s16) is promoted to a 32-bit signed + // integer prior to being compared, so the compared value can + // never exceed SHORT_MAX and the condition always passes. if (getMessageNo() != 0xFFFF) { mMsgNo = getMessageNo(); } else { diff --git a/src/d/actor/d_a_npc_wrestler.cpp b/src/d/actor/d_a_npc_wrestler.cpp index 40eae8e827..81b50c8338 100644 --- a/src/d/actor/d_a_npc_wrestler.cpp +++ b/src/d/actor/d_a_npc_wrestler.cpp @@ -2219,8 +2219,8 @@ bool daNpcWrestler_c::sumouReady(void* param_1) { // fallthrough case 2: field_0xe5e += field_0xbd8->field_0xac; - field_0xe54 -= fabsf(field_0xbd8->field_0xac); - if (field_0xe54 < fabsf(field_0xbd8->field_0xac)) { + field_0xe54 -= fabsf((f32)field_0xbd8->field_0xac); + if (field_0xe54 < fabsf((f32)field_0xbd8->field_0xac)) { field_0xe80 = 1; field_0xe84++; } diff --git a/src/d/actor/d_a_npc_zra.cpp b/src/d/actor/d_a_npc_zra.cpp index ad35527516..15ed62157e 100644 --- a/src/d/actor/d_a_npc_zra.cpp +++ b/src/d/actor/d_a_npc_zra.cpp @@ -493,6 +493,9 @@ cPhs_Step daNpc_zrA_c::create() { fopAcM_ct(this, daNpc_zrA_c); mType = getTypeFromArgument(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xffff) { mFlowID = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_zrc.cpp b/src/d/actor/d_a_npc_zrc.cpp index 738f585127..d7f2ebc372 100644 --- a/src/d/actor/d_a_npc_zrc.cpp +++ b/src/d/actor/d_a_npc_zrc.cpp @@ -222,6 +222,9 @@ cPhs_Step daNpc_zrC_c::create() { fopAcM_ct(this, daNpc_zrC_c); mType = getTypeFromParam(); + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xffff) { mFlowID = home.angle.x; } else { diff --git a/src/d/actor/d_a_npc_zrz.cpp b/src/d/actor/d_a_npc_zrz.cpp index 37656be3bf..7e71ef130e 100644 --- a/src/d/actor/d_a_npc_zrz.cpp +++ b/src/d/actor/d_a_npc_zrz.cpp @@ -203,6 +203,9 @@ cPhs_Step daNpc_zrZ_c::create() { mSwitch1 = home.angle.z & 0xff; mSwitch2 = (home.angle.z >> 8) & 0xff; mSwitch3 = fopAcM_GetParam(this) >> 0x18; + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.x != 0xffff) { mFlowID = home.angle.x; } else { diff --git a/src/d/actor/d_a_obj_brg.cpp b/src/d/actor/d_a_obj_brg.cpp index df9785f346..d0dea6cf98 100644 --- a/src/d/actor/d_a_obj_brg.cpp +++ b/src/d/actor/d_a_obj_brg.cpp @@ -666,8 +666,8 @@ static void obj_brg_move(obj_brg_class* i_this) { if ((i_this->mType & 1) == 1) { i_this->mBr[i].field_0x0e0 = 1.0f; } else { - var_f27 = ( f32(i) / (i_this->field_0xb1ea - 1)) * M_PI; - i_this->mBr[i].field_0x0e0 = fabsf(sin(var_f27)); + var_f27 = ((f32)i / (i_this->field_0xb1ea - 1)) * M_PI; + i_this->mBr[i].field_0x0e0 = fabsf(sinf(var_f27)); } i_this->mBr[i].field_0x704 = i_this->mBr[i].field_0x705 = 3; @@ -994,11 +994,11 @@ static int daObj_Brg_Execute(obj_brg_class* i_this) { f32 dbg_0x5c; for (int i = 0; i < i_this->field_0xb1ea; i++, part++) { if (i_this->field_0xb1ed == 2) { - dbg_0x5c = f32(i) / f32(i_this->field_0xb1ea - 1) * M_PI; - var_f26 = (-300.0f + WREG_F(15)) * f32(sin(dbg_0x5c)); + dbg_0x5c = (f32)i / (f32)(i_this->field_0xb1ea - 1) * M_PI; + var_f26 = (-300.0f + WREG_F(15)) * (f32)sin(dbg_0x5c); } else if (i_this->field_0xb1ed == 1) { - dbg_0x5c = f32(i) / f32(i_this->field_0xb1ea - 1) * M_PI; - var_f26 = (-100.0f + WREG_F(13)) * f32(sin(dbg_0x5c)); + dbg_0x5c = (f32)i / (f32)(i_this->field_0xb1ea - 1) * M_PI; + var_f26 = (-100.0f + WREG_F(13)) * (f32)sin(dbg_0x5c); } MtxTrans(part->field_0x0bc.x, part->field_0x0bc.y, part->field_0x0bc.z, 0); @@ -1795,7 +1795,7 @@ static int daObj_Brg_Create(fopAc_ac_c* i_this) { }; for (brno = 0; brno < a_this->field_0xb1ea; brno++) { - a_this->mBr[brno].field_0x098[2] = brg_init_pos[brno]; + a_this->mBr[brno].field_0x0b0 = brg_init_pos[brno]; } } diff --git a/src/d/actor/d_a_obj_cwall.cpp b/src/d/actor/d_a_obj_cwall.cpp index 0b6367505f..6bf0b480a5 100644 --- a/src/d/actor/d_a_obj_cwall.cpp +++ b/src/d/actor/d_a_obj_cwall.cpp @@ -333,6 +333,10 @@ void daObjCwall_c::getChainBasePos(cXyz* pBasePos) { void daObjCwall_c::setChainMtx() { chain_s* pChain = mChains; s16 sVar7 = home.angle.y; + + // !@bug The variable is promoted to a 32-bit signed integer prior + // to being compared to 0xC000, so the compared value can never + // exceed SHORT_MAX and the subcondition fails. if (sVar7 == 0x4000 || sVar7 == 0xc000) { sVar7 += 0x4000; } diff --git a/src/d/actor/d_a_obj_gra2.cpp b/src/d/actor/d_a_obj_gra2.cpp index 5f03df755f..4eca318eb9 100644 --- a/src/d/actor/d_a_obj_gra2.cpp +++ b/src/d/actor/d_a_obj_gra2.cpp @@ -277,7 +277,10 @@ cPhs_Step daObj_GrA_c::create() { } } - field_0x848 = ((int)home.angle.x == 0xFFFF) ? -1 : home.angle.x; + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always fails. + mFlowID = home.angle.x == 0xFFFF ? -1 : home.angle.x; field_0x1fe8 = (fopAcM_GetParam(this) & 0xC0000000) >> 30; field_0xa7f = home.angle.z & 0xFF; @@ -1435,7 +1438,7 @@ int daObj_GrA_c::talk(void* param_1) { int iVar1, iVar2; int rv = 0; int iVar3; - int iVar4 = field_0x848; + int iVar4 = mFlowID; s16 sVar1; switch (field_0xa7c) { case 0: @@ -2013,7 +2016,7 @@ int daObj_GrA_c::face999(int param_1) { } int daObj_GrA_c::evtcutTalk(int param_1, int param_2) { - s32 sVar1 = field_0x848; + s32 sVar1 = mFlowID; if (param_2 != 0) { mMsgFlow.init(this, sVar1, 0, NULL); field_0xaa0 = 0; diff --git a/src/d/actor/d_a_obj_gra2_soldier.inc b/src/d/actor/d_a_obj_gra2_soldier.inc index e36d7ec350..53100dafcd 100644 --- a/src/d/actor/d_a_obj_gra2_soldier.inc +++ b/src/d/actor/d_a_obj_gra2_soldier.inc @@ -768,7 +768,7 @@ int daObj_GrA_c::rollDemo(void* param_1) { field_0x91a.y = current.angle.y; if (mDemoCamMode >= 5) { - field_0x848 = 4; + mFlowID = 4; evtcutTalk(-1, 1); field_0x2000 = 0; } @@ -1169,7 +1169,7 @@ int daObj_GrA_c::rollAttacked(void* param_1) { case 2: if (mDemoCamMode >= 5) { - field_0x848 = 5; + mFlowID = 5; evtcutTalk(-1, 1); field_0x2018 = 3; } diff --git a/src/d/actor/d_a_obj_magne_arm.cpp b/src/d/actor/d_a_obj_magne_arm.cpp index 1c1c152c00..54a734c35d 100644 --- a/src/d/actor/d_a_obj_magne_arm.cpp +++ b/src/d/actor/d_a_obj_magne_arm.cpp @@ -947,7 +947,7 @@ void daObjMarm_c::calcHimo() { getRopeStartPos(&offset1); getFpartsOffset(&offset2); - fabs(offset1.y - offset2.y); + UNUSED(fabs(offset1.y - offset2.y)); cXyz* line_mat1_pos = mpRope1->getPos(0); *line_mat1_pos = offset1; diff --git a/src/d/actor/d_a_obj_pumpkin.cpp b/src/d/actor/d_a_obj_pumpkin.cpp index ff90ed6a74..6dcd0988f7 100644 --- a/src/d/actor/d_a_obj_pumpkin.cpp +++ b/src/d/actor/d_a_obj_pumpkin.cpp @@ -288,8 +288,9 @@ int daObj_Pumpkin_c::Execute() { if (field_0xBAE) { int item_table_no = getItemTableNo(); if (item_table_no >= 0 && mItemProcId == fpcM_ERROR_PROCESS_ID_e) { - mItemProcId = fopAcM_createItemFromTable(¤t.pos, item_table_no, -1, fopAcM_GetRoomNo(this), - NULL, 0, NULL, NULL, NULL, NULL); + mItemProcId = fopAcM_createItemFromTable(¤t.pos, item_table_no, -1, + fopAcM_GetRoomNo(this), NULL, 0, NULL, NULL, + NULL, false); } if (mItemProcId == fpcM_ERROR_PROCESS_ID_e || fopAcM_IsExecuting(mItemProcId)) { diff --git a/src/d/actor/d_a_obj_sekidoor.cpp b/src/d/actor/d_a_obj_sekidoor.cpp index 7be65ab45b..498282f4b4 100644 --- a/src/d/actor/d_a_obj_sekidoor.cpp +++ b/src/d/actor/d_a_obj_sekidoor.cpp @@ -112,7 +112,9 @@ int daObj_SekiDoor_c::Execute(Mtx** i_mtx) { if (mOpening != 0) { if (mDestroyed != 0) { - if(!dComIfGp_event_runCheck){ + // !@bug Missing parentheses - the function is not callled and + // this always evaluates to false. + if (!dComIfGp_event_runCheck) { fopAcM_delete(this); } } diff --git a/src/d/actor/d_a_obj_sekizoa.cpp b/src/d/actor/d_a_obj_sekizoa.cpp index 7a32754658..19f4446b87 100644 --- a/src/d/actor/d_a_obj_sekizoa.cpp +++ b/src/d/actor/d_a_obj_sekizoa.cpp @@ -1008,9 +1008,14 @@ bool daObj_Sekizoa_c::afterSetMotionAnm(int i_frame, int i_mode, f32 i_morf, int if (mBtkAnm.getBtkAnm() == anm_text) { mAnmFlags |= ANM_PLAY_BTK; } else { - if (setBtkAnm(anm_text, mpMorf[0]->getModel()->getModelData(), 1.0f, - btkAnmData[4].field_0x4)) - { +#if AVOID_UB + // negative attribute values are ignored in favor of the animation's default value + if (setBtkAnm(anm_text, mpMorf[0]->getModel()->getModelData(), 1.0f, -1)) { +#else + // !@bug Out-of-bounds array read, in practice this ends up reading from a jump table + // positioned immediately after btkAnmData in .data. + if (setBtkAnm(anm_text, mpMorf[0]->getModel()->getModelData(), 1.0f, btkAnmData[4].field_0x4)) { +#endif if (frame_1 == 3) { mBtkAnm.setPlaySpeed(0.0f); } @@ -1032,8 +1037,15 @@ bool daObj_Sekizoa_c::afterSetMotionAnm(int i_frame, int i_mode, f32 i_morf, int if (mBrkAnm.getBrkAnm() == anm_tev) { mAnmFlags |= ANM_PLAY_BRK; } else { - frame_1 = setBrkAnm(anm_tev, mpMorf[0]->getModel()->getModelData(), 1.0, + // !@bug OoB index into brkAnmData ends up indexing into btkAnmData instead. + // This was probably supposed to use brkAnmData[5] instead. +#if AVOID_UB + frame_1 = setBrkAnm(anm_tev, mpMorf[0]->getModel()->getModelData(), 1.0f, + btkAnmData[0].field_0x4); +#else + frame_1 = setBrkAnm(anm_tev, mpMorf[0]->getModel()->getModelData(), 1.0f, brkAnmData[6].field_0x4); +#endif if (frame_1 != 0) { if (frame_2 == 5) { mBrkAnm.setPlaySpeed(0.0f); diff --git a/src/d/actor/d_a_obj_ss_drink.cpp b/src/d/actor/d_a_obj_ss_drink.cpp index 1327de2255..a2b68af17e 100644 --- a/src/d/actor/d_a_obj_ss_drink.cpp +++ b/src/d/actor/d_a_obj_ss_drink.cpp @@ -384,6 +384,7 @@ int daObj_SSDrink_c::chkEvent() { } int daObj_SSDrink_c::orderEvent() { + // !@bug Comparison of u16 (getFlowNodeNum()) with -1 always evaluates to false if (!daPy_py_c::checkNowWolf() && field_0xb0c != 0x60 && getFlowNodeNum() != -1) { attention_info.flags = fopAc_AttnFlag_TALKREAD_e | fopAc_AttnFlag_SPEAK_e; } else { diff --git a/src/d/actor/d_a_tag_evt.cpp b/src/d/actor/d_a_tag_evt.cpp index 2552f59e24..8dc5954ef0 100644 --- a/src/d/actor/d_a_tag_evt.cpp +++ b/src/d/actor/d_a_tag_evt.cpp @@ -168,6 +168,7 @@ int daTag_Evt_c::isDelete() { if (field_0x5DD == 0xFF || (field_0x5DD != 0xFF && dComIfGs_isSwitch(field_0x5DD, fopAcM_GetRoomNo(this)) != 0)) { + // !@bug Comparison of u8 field with 0xFFF will always evaluate to false if (field_0x5DE != 0xFFF) { return dComIfGs_isSwitch(field_0x5DE, fopAcM_GetRoomNo(this)); } else { diff --git a/src/d/actor/d_a_tag_evtmsg.cpp b/src/d/actor/d_a_tag_evtmsg.cpp index 8a2035f147..b5e71f00e3 100644 --- a/src/d/actor/d_a_tag_evtmsg.cpp +++ b/src/d/actor/d_a_tag_evtmsg.cpp @@ -36,6 +36,9 @@ int daTag_EvtMsg_c::create() { scale.y *= 100.0f; scale.z = scale.x; + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.z != 0xFFFF) { mFlowID = home.angle.z; } else { diff --git a/src/d/actor/d_a_tag_lantern.cpp b/src/d/actor/d_a_tag_lantern.cpp index 264a0c1987..88660a029d 100644 --- a/src/d/actor/d_a_tag_lantern.cpp +++ b/src/d/actor/d_a_tag_lantern.cpp @@ -126,6 +126,9 @@ void daTag_Lantern_c::initialize() { mpHIO->entryHIO("カンテラチェックタグ"); #endif + // !@bug home.angle.x is promoted to a 32-bit signed integer prior + // to being compared, so the compared value can never exceed + // SHORT_MAX and the condition always passes. if (home.angle.z != 0xFFFF) { mFlowIndex = home.angle.z; } else { diff --git a/src/d/actor/d_a_tag_setrestart.cpp b/src/d/actor/d_a_tag_setrestart.cpp index c7134fbae4..4230abb920 100644 --- a/src/d/actor/d_a_tag_setrestart.cpp +++ b/src/d/actor/d_a_tag_setrestart.cpp @@ -163,7 +163,7 @@ static int daTagRestart_Execute(daTagRestart_c* i_this) { } static int daTagRestart_Delete(daTagRestart_c* i_this) { - ("Delete -> TagRestart( =%d)\n", fopAcM_GetID(i_this)); + fopAcM_RegisterDeleteID(i_this, "TagRestart"); return i_this->_delete(); } diff --git a/src/d/actor/d_a_tag_sppath.cpp b/src/d/actor/d_a_tag_sppath.cpp index b40908b387..81fbe04184 100644 --- a/src/d/actor/d_a_tag_sppath.cpp +++ b/src/d/actor/d_a_tag_sppath.cpp @@ -97,7 +97,7 @@ int daTagSppath_c::getNearPathPos(cXyz* i_result, dPath* i_path) { if (flatness > 0.001f) { flatness = 30.0f / flatness; if (segLen > flatness) { - line.GetStartP() = line.GetStart() + pntDiff * flatness; + *line.GetStartP() = line.GetStart() + pntDiff * flatness; } } } @@ -111,7 +111,7 @@ int daTagSppath_c::getNearPathPos(cXyz* i_result, dPath* i_path) { if (flatness > 0.001f) { flatness = 30.0f / flatness; if (segLen > flatness) { - line.GetEndP() = line.GetEnd() + pntDiff * flatness; + *line.GetEndP() = line.GetEnd() + pntDiff * flatness; } } } diff --git a/src/d/actor/d_a_tag_ss_drink.cpp b/src/d/actor/d_a_tag_ss_drink.cpp index 8916feae7a..8f2ee55815 100644 --- a/src/d/actor/d_a_tag_ss_drink.cpp +++ b/src/d/actor/d_a_tag_ss_drink.cpp @@ -136,7 +136,7 @@ int daTag_SSDrink_c::chkEvent() { if (!dComIfGp_getEvent()->isOrderOK()) { retVal = 0; if (eventInfo.checkCommandTalk()) { - if (!checkProcess(&daTag_SSDrink_c::talk) == 0) { + if (checkProcess(&daTag_SSDrink_c::talk) != 0) { retVal = (this->*mProcessFunc)(0); } else { if (dComIfGp_event_chkTalkXY() == 0 || dComIfGp_evmng_ChkPresentEnd() != 0) { diff --git a/src/d/actor/d_a_tag_theB_hint.cpp b/src/d/actor/d_a_tag_theB_hint.cpp index d368d726df..58887f976e 100644 --- a/src/d/actor/d_a_tag_theB_hint.cpp +++ b/src/d/actor/d_a_tag_theB_hint.cpp @@ -23,6 +23,7 @@ int daTagTheBHint_c::execute() { if (fopAcM_searchPlayerDistanceXZ2(this) < field_0x568) { daNpcTheB_c* the_b = (daNpcTheB_c*)fpcM_SearchByName(fpcNm_NPC_THEB_e); if (the_b) { + // !@bug Comparison of s8 (getRoomNo) with 0xFF always evaluates to false int roomNo = getRoomNo() == 0xff ? fopAcM_GetRoomNo(this) : getRoomNo(); the_b->setHintEvent(getMessageNo(), getLinkID(), roomNo); diff --git a/src/d/d_bg_w.cpp b/src/d/d_bg_w.cpp index b5d342d3f8..ecbc7fa6d3 100644 --- a/src/d/d_bg_w.cpp +++ b/src/d/d_bg_w.cpp @@ -524,8 +524,8 @@ bool cBgW::LineCheckRp(cBgS_LinChk* plinchk, int node_index) { cBgW_NodeTree* node = &pm_node_tree[node_index]; if (!cM3d_Cross_MinMaxBoxLine(node->GetMinP(), node->GetMaxP(), - &plinchk->GetLinP()->GetStartP(), - &plinchk->GetLinP()->GetEndP())) + plinchk->GetLinP()->GetStartP(), + plinchk->GetLinP()->GetEndP())) { return false; } diff --git a/src/d/d_cc_d.cpp b/src/d/d_cc_d.cpp index 3c1acd7d5a..1c30502d03 100644 --- a/src/d/d_cc_d.cpp +++ b/src/d/d_cc_d.cpp @@ -365,7 +365,7 @@ void dCcD_Cps::Draw(const GXColor& color) { cXyz cStack_d8; CalcVec(&cStack_d8); - cMtx_trans(auStack_98, GetStartP().x, GetStartP().y, GetStartP().z); + cMtx_trans(auStack_98, GetStartP()->x, GetStartP()->y, GetStartP()->z); cM3d_UpMtx(cStack_d8, auStack_c8); cMtx_concat(auStack_98, auStack_c8, auStack_68); cMtx_scale(auStack_98, GetR(), 0.5f * GetLen(), GetR()); @@ -375,8 +375,8 @@ void dCcD_Cps::Draw(const GXColor& color) { cMtx_XrotS(auStack_98, 0x4000); cMtx_concat(auStack_68, auStack_98, auStack_68); dDbVw_drawCylinderMXlu(auStack_68, color, 1); - dDbVw_drawSphereXlu(GetStartP(), GetR(), color, 1); - dDbVw_drawSphereXlu(GetEndP(), GetR(), color, 1); + dDbVw_drawSphereXlu(*GetStartP(), GetR(), color, 1); + dDbVw_drawSphereXlu(*GetEndP(), GetR(), color, 1); } #endif diff --git a/src/d/d_cc_mass_s.cpp b/src/d/d_cc_mass_s.cpp index 3a8ecdc7b2..1bc43a4565 100644 --- a/src/d/d_cc_mass_s.cpp +++ b/src/d/d_cc_mass_s.cpp @@ -10,16 +10,16 @@ #include "d/d_cc_d.h" #include "f_op/f_op_actor.h" -void dCcMassS_Obj::Set(cCcD_Obj* p_obj, u8 priority, dCcMassS_ObjCallback callback) { - mpObj = p_obj; - mPriority = priority; - mpCallback = callback; +void dCcMassS_Obj::Set(cCcD_Obj* pobj, u8 priority, dCcMassS_ObjCallback callback) { + mpObj = pobj; + mPriority = (u8)priority; + mpAreaCheckFunc = callback; } void dCcMassS_Obj::Clear() { mpObj = NULL; mPriority = 5; - mpCallback = NULL; + mpAreaCheckFunc = NULL; mDivideInfo.Set(0, 0, 0); } @@ -53,24 +53,30 @@ void dCcMassS_Mng::Ct() { void dCcMassS_Mng::SetAttr(f32 radius, f32 height, u8 param_2, u8 param_3) { mCylAttr.SetR(radius); mCylAttr.SetH(height); - field_0x200 = param_2; - field_0x201 = param_3; + field_0x200 = (u8)param_2; + field_0x201 = (u8)param_3; } void dCcMassS_Mng::Prepare() { cM3dGAab aab; aab.ClearForMinMax(); - for (dCcMassS_Obj* pObj = mMassObjs; pObj < mMassObjs + mMassObjCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - objShape->CalcAabBox(); - aab.SetMinMax(objShape->GetWorkAab()); + for (dCcMassS_Obj* i = mMassObjs; i < mMassObjs + mMassObjCount; ++i) { + cCcD_Obj* pobj = i->GetObj(); + JUT_ASSERT(123, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); + shape->CalcAabBox(); + aab.SetMinMax(shape->GetWorkAab()); } - for (dCcMassS_Obj* pObj = mMassAreas; pObj < mMassAreas + mMassAreaCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - objShape->CalcAabBox(); - aab.SetMinMax(objShape->GetWorkAab()); + for (dCcMassS_Obj* i = mMassAreas; i < mMassAreas + mMassAreaCount; ++i) { + cCcD_Obj* parea = i->GetObj(); + JUT_ASSERT(135, parea != NULL); + + cCcD_ShapeAttr* shape = parea->GetShapeAttr(); + shape->CalcAabBox(); + aab.SetMinMax(shape->GetWorkAab()); } if (field_0x202 & 1) { @@ -79,16 +85,23 @@ void dCcMassS_Mng::Prepare() { } mDivideArea.SetArea(aab); - for (dCcMassS_Obj* pObj = mMassObjs; pObj < mMassObjs + mMassObjCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - cCcD_DivideInfo* divideInfo = &pObj->GetDivideInfo(); - mDivideArea.CalcDivideInfo(divideInfo, objShape->GetWorkAab(), 0); + + for (dCcMassS_Obj* i = mMassObjs; i < mMassObjs + mMassObjCount; ++i) { + cCcD_Obj* pobj = i->GetObj(); + JUT_ASSERT(155, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = i->GetPDivideInfo(); + mDivideArea.CalcDivideInfo(pdivinfo, shape->GetWorkAab(), 0); } - for (dCcMassS_Obj* pObj = mMassAreas; pObj < mMassAreas + mMassAreaCount; ++pObj) { - cCcD_ShapeAttr* objShape = pObj->GetObj()->GetShapeAttr(); - cCcD_DivideInfo* divideInfo = &pObj->GetDivideInfo(); - mDivideArea.CalcDivideInfo(divideInfo, objShape->GetWorkAab(), 0); + for (dCcMassS_Obj* i = mMassAreas; i < mMassAreas + mMassAreaCount; ++i) { + cCcD_Obj* parea = i->GetObj(); + JUT_ASSERT(166, parea != NULL); + + cCcD_ShapeAttr* shape = parea->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = i->GetPDivideInfo(); + mDivideArea.CalcDivideInfo(pdivinfo, shape->GetWorkAab(), 0); } if (field_0x202 & 1) { @@ -106,32 +119,36 @@ void dCcMassS_Mng::Prepare() { mCamBottomDist = G_CM3D_F_INF; } -u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitInf) { +u32 dCcMassS_Mng::Chk(cXyz* ppos, fopAc_ac_c** ppactor, dCcMassS_HitInf* phitinf) { cCcD_DivideInfo divideInfo; u32 flagsMaybe = 0; - *p_actor = NULL; + *ppactor = NULL; - mCylAttr.SetC(*p_xyz); + mCylAttr.SetC(*ppos); mCylAttr.CalcAabBox(); mDivideArea.CalcDivideInfoOverArea(÷Info, mCylAttr.GetWorkAab()); - p_hitInf->ClearPointer(); + phitinf->ClearPointer(); if (field_0x200 & 8) { for (dCcMassS_Obj* massObj = mMassAreas; massObj < mMassAreas + mMassAreaCount; ++massObj) { - if (massObj->GetDivideInfo().Chk(divideInfo)) { - cCcD_Obj* obj = massObj->GetObj(); - cCcD_ShapeAttr* objShape = obj->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = massObj->GetPDivideInfo(); + if (pdivinfo->Chk(divideInfo)) { + cCcD_Obj* pobj = massObj->GetObj(); + JUT_ASSERT(226, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); f32 f; - if (obj->ChkCoSet() && mCylAttr.CrossCo(*objShape, &f)) { + if (pobj->ChkCoSet() && mCylAttr.CrossCo(*shape, &f)) { flagsMaybe |= 4; - *p_actor = obj->GetStts()->GetAc(); - if (p_hitInf != NULL) { - p_hitInf->SetAreaHitObj(obj); + *ppactor = pobj->GetStts()->GetActor(); + if (phitinf != NULL) { + phitinf->SetAreaHitObj(pobj); } - if (massObj->GetCallback() != NULL) { - massObj->GetCallback()(obj->GetStts()->GetAc(), p_xyz, field_0x201); + if (massObj->GetAreaCheckFunc() != NULL) { + dCcMassS_ObjCallback sp1C = massObj->GetAreaCheckFunc(); + sp1C(pobj->GetStts()->GetActor(), ppos, field_0x201); } } } @@ -139,42 +156,46 @@ u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitI } for (dCcMassS_Obj* massObj = mMassObjs; massObj < mMassObjs + mMassObjCount; ++massObj) { - if (massObj->GetDivideInfo().Chk(divideInfo)) { - cCcD_Obj* obj = massObj->GetObj(); - dCcD_GObjInf* gobjInf = (dCcD_GObjInf*)obj->GetGObjInf(); - cCcD_ShapeAttr* objShape = obj->GetShapeAttr(); + cCcD_DivideInfo* pdivinfo = massObj->GetPDivideInfo(); + if (pdivinfo->Chk(divideInfo)) { cXyz unusedVec; - if (obj->ChkAtSet() && !gobjInf->ChkAtNoMass() && - mCylAttr.CrossAtTg(*objShape, &unusedVec) && (field_0x200 & 1)) + cCcD_Obj* pobj = massObj->GetObj(); + dCcD_GObjInf* gobjInf = (dCcD_GObjInf*)pobj->GetGObjInf(); + JUT_ASSERT(266, pobj != NULL); + + cCcD_ShapeAttr* shape = pobj->GetShapeAttr(); + + if (pobj->ChkAtSet() && !gobjInf->ChkAtNoMass() && + mCylAttr.CrossAtTg(*shape, &unusedVec) && (field_0x200 & 1)) { flagsMaybe |= 1; - *p_actor = obj->GetStts()->GetAc(); - if (p_hitInf != NULL) { - p_hitInf->SetAtHitObj(obj); + *ppactor = pobj->GetStts()->GetActor(); + if (phitinf != NULL) { + phitinf->SetAtHitObj(pobj); } } f32 f; - if (obj->ChkCoSet() && mCylAttr.CrossCo(*objShape, &f) && (field_0x200 & 2)) { + if (pobj->ChkCoSet() && mCylAttr.CrossCo(*shape, &f) && (field_0x200 & 2)) { flagsMaybe |= 2; - *p_actor = obj->GetStts()->GetAc(); + *ppactor = pobj->GetStts()->GetActor(); if (field_0x200 & 0x10) { - Vec vec; - VECSubtract(&(*p_actor)->current.pos, p_xyz, &vec); + cXyz vec; + PSVECSubtract(&(*ppactor)->current.pos, ppos, &vec); vec.y = 0; - f32 vecMag = VECMag(&vec); + f32 vecMag = PSVECMag(&vec); if (cM3d_IsZero(vecMag)) { vec.x = 1; } else { - VECScale(&vec, &vec, f / vecMag); + PSVECScale(&vec, &vec, f / vecMag); } - obj->GetStts()->PlusCcMove(vec.x, vec.y, vec.z); + pobj->GetStts()->PlusCcMove(vec.x, vec.y, vec.z); } - if (p_hitInf != NULL) { - p_hitInf->SetCoHitObj(obj); - p_hitInf->SetCoHitLen(f); + if (phitinf != NULL) { + phitinf->SetCoHitObj(pobj); + phitinf->SetCoHitLen(f); } } } @@ -182,18 +203,18 @@ u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitI f32 f; if ((field_0x202 & 1) && mDivideInfo.Chk(divideInfo) && mCylAttr.CrossCo(mCpsAttr, &f)) { - mResultCam |= 1; - mResultCam |= 1 << (field_0x201 + 1); + mResultCam |= (u8)1; + mResultCam |= (1 << (field_0x201 + 1)); if ((mResultCam & 2) || (mResultCam & 8)) { - cXyz tmpVec; - f32 plusH = p_xyz->y + mCylAttr.GetH(); - tmpVec.x = p_xyz->x; + Vec tmpVec; + f32 plusH = ppos->y + mCylAttr.GetH(); + tmpVec.x = ppos->x; tmpVec.y = plusH; - tmpVec.z = p_xyz->z; + tmpVec.z = ppos->z; if (mCamTopPos.y < (20.0f + plusH)) { - f32 newCamTopDist = VECSquareDistance(&tmpVec, &mCpsAttr.GetStartP()); + f32 newCamTopDist = PSVECSquareDistance(&tmpVec, mCpsAttr.GetStartP()); if (mCamTopDist > newCamTopDist) { mCamTopDist = newCamTopDist; mCamTopPos = tmpVec; @@ -201,7 +222,7 @@ u32 dCcMassS_Mng::Chk(cXyz* p_xyz, fopAc_ac_c** p_actor, dCcMassS_HitInf* p_hitI } if (mCamBottomPos.y < (20.0f + plusH)) { - f32 newCamBottomDist = VECSquareDistance(&tmpVec, &mCpsAttr.GetEndP()); + f32 newCamBottomDist = PSVECSquareDistance(&tmpVec, mCpsAttr.GetEndP()); if (mCamBottomDist > newCamBottomDist) { mCamBottomDist = newCamBottomDist; mCamBottomPos = tmpVec; @@ -231,24 +252,24 @@ void dCcMassS_Mng::Clear() { field_0x201 = 4; } -void dCcMassS_Mng::Set(cCcD_Obj* p_obj, u8 priority) { +void dCcMassS_Mng::Set(cCcD_Obj* pobj, u8 priority) { if (mMassObjCount >= ARRAY_SIZE(mMassObjs)) { for (int i = 0; i < ARRAY_SIZE(mMassObjs); ++i) { int prevPrio = mMassObjs[i].GetPriority(); if (prevPrio > priority || (prevPrio == priority && cM_rndF(1.0f) < 0.5f)) { - mMassObjs[i].Set(p_obj, priority, NULL); + mMassObjs[i].Set(pobj, priority, NULL); break; } } } else { - mMassObjs[mMassObjCount].Set(p_obj, priority, NULL); + mMassObjs[mMassObjCount].Set(pobj, priority, NULL); mMassObjCount++; } } -void dCcMassS_Mng::SetCam(cM3dGCps const& cps) { +void dCcMassS_Mng::SetCam(const cM3dGCps& cps) { mCpsAttr.SetCps(cps); - field_0x202 |= 1; + field_0x202 |= (u8)1; mResultCam = 0; } @@ -256,6 +277,6 @@ u32 dCcMassS_Mng::GetResultCam() const { return mResultCam; } -void dCcMassS_Mng::GetCamTopPos(Vec* p_out) { - *p_out = mCamTopPos; +void dCcMassS_Mng::GetCamTopPos(Vec* ppos) { + *ppos = mCamTopPos; } diff --git a/src/d/d_cc_s.cpp b/src/d/d_cc_s.cpp index ccb8501542..de9fa587ed 100644 --- a/src/d/d_cc_s.cpp +++ b/src/d/d_cc_s.cpp @@ -10,13 +10,114 @@ #include "d/d_jnt_col.h" #include "f_op/f_op_actor_mng.h" +class dCcS_HIO : public JORReflexible { +public: + enum flags_e { + FLAG_CAM_COL_DISP_e = 0x1, + FLAG_AT_ON_e = 0x2, + FLAG_TG_ON_e = 0x4, + FLAG_CO_ON_e = 0x8, + FLAG_DRAW_CLEAR_OFF_e = 0x10, + FLAG_COUNTER_e = 0x20, + FLAG_MOVE_OFF_e = 0x40, + FLAG_MASS_OFF_e = 0x80, + FLAG_MOVE_TIMER_e = 0x100, + FLAG_MASS_TIMER_e = 0x200, + FLAG_MASS_COUNTER_e = 0x400, + FLAG_ALL_MASS_TIMER_e = 0x800, + + }; + + dCcS_HIO() { + m_flags = 0; + m_shield_range = 0x4000; + } + + virtual ~dCcS_HIO(); + + void genMessage(JORMContext*); + + BOOL ChkMoveTimer() { return m_flags & FLAG_MOVE_TIMER_e; } + BOOL ChkMoveOff() { return m_flags & FLAG_MOVE_OFF_e; } + BOOL ChkAllMassTimer() { return m_flags & FLAG_ALL_MASS_TIMER_e; } + BOOL ChkDrawClearOff() { return m_flags & FLAG_DRAW_CLEAR_OFF_e; } + BOOL ChkCounter() { return m_flags & FLAG_COUNTER_e; } + BOOL ChkCamColDisp() { return m_flags & FLAG_CAM_COL_DISP_e; } + BOOL CheckCoOn() { return m_flags & FLAG_CO_ON_e; } + BOOL CheckTgOn() { return m_flags & FLAG_TG_ON_e; } + BOOL CheckAtOn() { return m_flags & FLAG_AT_ON_e; } + BOOL ChkMassCounter() { return m_flags & FLAG_MASS_COUNTER_e; } + BOOL ChkMassOff() { return m_flags & FLAG_MASS_OFF_e; } + BOOL ChkMassTimer() { return m_flags & FLAG_MASS_TIMER_e; } + + /* 0x4 */ s8 id; + /* 0x6 */ u16 m_flags; + /* 0x8 */ s16 m_shield_range; +}; + +#if DEBUG +dCcS_HIO::~dCcS_HIO() {} + +void dCcS_HIO::genMessage(JORMContext* mctx) { + mctx->genLabel("処理関係 -----", 0); + mctx->genCheckBox("処理Off", &m_flags, 0x40); + mctx->genCheckBox("多数ヒットチェック(草木花)Off", &m_flags, 0x80); + mctx->genCheckBox("多数ヒット 1回時間", &m_flags, 0x200); + mctx->genCheckBox("多数ヒット 通しの処理時間(->terminal)", &m_flags, 0x800); + mctx->genCheckBox("多数ヒット チェックカウンタ", &m_flags, 0x400); + mctx->genCheckBox("処理時間(->terminal)", &m_flags, 0x100); + + mctx->genLabel("描画関係 -----", 0); + mctx->genCheckBox("At 描画", &m_flags, 2); + mctx->genCheckBox("Tg 描画", &m_flags, 4); + mctx->genCheckBox("Co 描画", &m_flags, 8); + mctx->genCheckBox("カメラCo描画", &m_flags, 1); + mctx->genCheckBox("クリアOff", &m_flags, 0x10); + + mctx->genLabel("情報(->terminal) -----", 0); + mctx->genCheckBox("個数", &m_flags, 0x20); + + mctx->genLabel("特殊-----", 0); + mctx->genSlider("盾範囲(max=360度)", &m_shield_range, 0, 0x7FFF); +} + +static OSStopwatch s_move_timer; +static OSStopwatch s_mass_timer; + +static dCcS_HIO s_Hio; + +int g_mass_counter; +#endif + void dCcS::Ct() { cCcS::Ct(); + + #if DEBUG + m_is_mass_all_timer = 0; + s_Hio.id = mDoHIO_CREATE_CHILD("zelda コリジョンシステム", &s_Hio); + + OSInitStopwatch(&s_move_timer, "CollsionCheckMove"); + OSResetStopwatch(&s_move_timer); + OSInitStopwatch(&s_mass_timer, "MassCheck"); + OSResetStopwatch(&s_mass_timer); + + g_mass_counter = 0; + #endif + mMass_Mng.Ct(); + + #if DEBUG + dJntCol_setDebugHIO(); + #endif } void dCcS::Dt() { cCcS::Dt(); + + #if DEBUG + mDoHIO_DELETE_CHILD(s_Hio.id); + dJntCol_deleteDebugHIO(); + #endif } bool dCcS::ChkShieldFrontRange(cCcD_Obj* i_atObj, cCcD_Obj* i_tgObj, int param_2, @@ -110,11 +211,11 @@ void dCcS::CalcTgPlusDmg(cCcD_Obj* i_atObj, cCcD_Obj* i_tgObj, cCcD_Stts* i_atSt bool dCcS::ChkAtTgHitAfterCross(bool i_setAt, bool i_setTg, cCcD_GObjInf const* i_atObjInf, cCcD_GObjInf const* i_tgObjInf, cCcD_Stts* i_atStts, cCcD_Stts* i_tgStts, cCcD_GStts* i_atGStts, cCcD_GStts* i_tgGStts) { - dCcD_GObjInf* atObjInf = (dCcD_GObjInf*)i_atObjInf; - dCcD_GObjInf* tgObjInf = (dCcD_GObjInf*)i_tgObjInf; - fpc_ProcID tgApid = i_atStts->GetApid(); fpc_ProcID atApid = i_tgStts->GetApid(); + + dCcD_GObjInf* atObjInf = (dCcD_GObjInf*)i_atObjInf; + dCcD_GObjInf* tgObjInf = (dCcD_GObjInf*)i_tgObjInf; if (i_setAt) { static_cast(i_atGStts)->SetAtApid(atApid); @@ -269,9 +370,10 @@ void dCcS::SetPosCorrect(cCcD_Obj* i_co1Obj, cXyz* i_pos1, cCcD_Obj* i_co2Obj, c int co1_rank = GetRank(i_co1Obj->GetStts()->GetWeightUc()); int co2_rank = GetRank(i_co2Obj->GetStts()->GetWeightUc()); u8 rank = rank_tbl[co1_rank][co2_rank]; + u8 var_r22 = 100 - rank; f32 fvar1 = rank * 0.01f; - f32 fvar2 = (u8)(100 - rank) * 0.01f; + f32 fvar2 = var_r22 * 0.01f; cXyz co1_move; cXyz co2_move; @@ -279,8 +381,8 @@ void dCcS::SetPosCorrect(cCcD_Obj* i_co1Obj, cXyz* i_pos1, cCcD_Obj* i_co2Obj, c f32 fvar14; if (bvar2) { - VECSubtract(i_pos2, i_pos1, &local_c8); - fvar14 = VECMag(&local_c8); + PSVECSubtract(i_pos2, i_pos1, &local_c8); + fvar14 = PSVECMag(&local_c8); } else { local_c8.x = i_pos2->x - i_pos1->x; local_c8.y = 0.0f; @@ -290,14 +392,15 @@ void dCcS::SetPosCorrect(cCcD_Obj* i_co1Obj, cXyz* i_pos1, cCcD_Obj* i_co2Obj, c if (!cM3d_IsZero(fvar14)) { if (bvar2) { - VECScale(&local_c8, &local_c8, i_cross_len / fvar14); + f32 var_f26 = i_cross_len / fvar14; + PSVECScale(&local_c8, &local_c8, var_f26); fvar1 *= -1.0f; - VECScale(&local_c8, &co1_move, fvar1); - VECScale(&local_c8, &co2_move, fvar2); + PSVECScale(&local_c8, &co1_move, fvar1); + PSVECScale(&local_c8, &co2_move, fvar2); } else { - fvar14 = i_cross_len / fvar14; - local_c8.x *= fvar14; - local_c8.z *= fvar14; + f32 var_f27 = i_cross_len / fvar14; + local_c8.x *= var_f27; + local_c8.z *= var_f27; co1_move.x = -local_c8.x * fvar1; co1_move.y = 0.0f; @@ -332,27 +435,25 @@ void dCcS::CalcParticleAngle(dCcD_GObjInf* i_atObjInf, cCcD_Stts* i_atStts, cCcD csXyz* o_angle) { cXyz vec(*i_atObjInf->GetAtVecP()); - if (cM3d_IsZero(VECMag(&vec))) { + if (cM3d_IsZero(PSVECMag(&vec))) { fopAc_ac_c* atActor = i_atStts->GetActor(); fopAc_ac_c* tgActor = i_tgStts->GetActor(); if (atActor == NULL || tgActor == NULL) { - vec.z = 0.0f; - vec.x = 0.0f; + vec.x = vec.z = 0.0f; vec.y = -1.0f; } else { - VECSubtract(&tgActor->current.pos, &atActor->current.pos, &vec); + PSVECSubtract(&tgActor->current.pos, &atActor->current.pos, &vec); - if (cM3d_IsZero(VECMag(&vec))) { - vec.z = 0.0f; - vec.x = 0.0f; + if (cM3d_IsZero(PSVECMag(&vec))) { + vec.x = vec.z = 0.0f; vec.y = -1.0f; } else { - VECNormalize(&vec, &vec); + PSVECNormalize(&vec, &vec); } } } else { - VECNormalize(&vec, &vec); + PSVECNormalize(&vec, &vec); } cM3d_CalcVecZAngle(vec, o_angle); @@ -441,9 +542,9 @@ void dCcS::SetAtTgGObjInf(bool i_setAt, bool i_setTg, cCcD_Obj* i_atObj, cCcD_Ob atObjInf->SetAtHitApid(i_tgStts->GetApid()); - if (chk_shield || tgObjInf->GetTgHitMark() == 8 && atObjInf->GetAtMtrl() != dCcD_MTRL_ICE && + if (chk_shield || (tgObjInf->GetTgHitMark() == 8 && atObjInf->GetAtMtrl() != dCcD_MTRL_ICE && (atObjInf->GetAtSpl() == 0 || atObjInf->GetAtSpl() == 5 || - atObjInf->GetAtSpl() == 8)) + atObjInf->GetAtSpl() == 8))) { atObjInf->OnAtShieldHit(); } @@ -466,7 +567,8 @@ void dCcS::SetAtTgGObjInf(bool i_setAt, bool i_setTg, cCcD_Obj* i_atObj, cCcD_Ob if (chk_shield) { tgObjInf->OnTgShieldHit(); } else { - i_tgStts->PlusDmg(i_atObj->GetAtAtp()); + int atp = i_atObj->GetAtAtp(); + i_tgStts->PlusDmg(atp); } if (at_gstts->ChkNoActor()) { @@ -523,9 +625,10 @@ bool dCcS::ChkCamera(cXyz& param_0, cXyz& param_1, f32 param_2, fopAc_ac_c* para dCcD_GObjInf* obj = (dCcD_GObjInf*)(*i)->GetGObjInf(); if (obj == NULL || !obj->ChkCoNoCamHit()) { - cCcD_ShapeAttr* shapeAttr = (*i)->GetShapeAttr(); + cCcD_ShapeAttr* pco_sa = (*i)->GetShapeAttr(); + JUT_ASSERT(1058, pco_sa != NULL); - if (sp48.CrossCo(*shapeAttr, &sp14)) { + if (sp48.CrossCo(*pco_sa, &sp14)) { return true; } } @@ -604,10 +707,11 @@ bool dCcS::chkCameraPoint(cXyz const& param_0, cCcD_ShapeAttr::Shape* param_1, f dCcD_GObjInf* obj = (dCcD_GObjInf*)(*i)->GetGObjInf(); if (obj == NULL || !obj->ChkCoNoCamHit()) { - cCcD_ShapeAttr* shapeAttr = (*i)->GetShapeAttr(); + cCcD_ShapeAttr* pco_sa = (*i)->GetShapeAttr(); + JUT_ASSERT(1196, pco_sa != NULL); - if (sp48.CrossCo(*shapeAttr, &sp14)) { - shapeAttr->getShapeAccess(param_1); + if (sp48.CrossCo(*pco_sa, &sp14)) { + pco_sa->getShapeAccess(param_1); if (param_1->_0 != 2) { return true; @@ -626,12 +730,110 @@ void dCcS::MoveAfterCheck() {} void dCcS::DrawAfter() {} void dCcS::Move() { + #if DEBUG + if (s_Hio.ChkAllMassTimer()) { + OnMassAllTimer(); + } else { + OffMassAllTimer(); + } + + if (s_Hio.ChkMoveOff()) { + return; + } + + if (s_Hio.ChkMoveTimer()) { + OSStartStopwatch(&s_move_timer); + } + #endif + cCcS::Move(); + + #if DEBUG + if (s_Hio.ChkMoveTimer()) { + OSStopStopwatch(&s_move_timer); + OSDumpStopwatch(&s_move_timer); + } + #endif } void dCcS::Draw() { + #if DEBUG + if (s_Hio.ChkMassCounter()) { + OS_REPORT("Mass Counter %d\n", g_mass_counter); + g_mass_counter = 0; + } + + if (s_Hio.CheckAtOn()) { + for (int i = 0; i < field_0x280c; i++) { + if (mpObjAt[i] != NULL && mpObjAt[i]->ChkAtSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjAt[i]->GetGObjInf(); + if (gobj->ChkAtHit()) { + GXColor color = {0xFF, 0, 0, 0xB4}; + mpObjAt[i]->Draw(color); + } else { + GXColor color = {0xFF, 0, 0, 0x50}; + mpObjAt[i]->Draw(color); + } + } + } + } + + if (s_Hio.CheckTgOn()) { + for (int i = 0; i < field_0x280e; i++) { + if (mpObjTg[i] != NULL && mpObjTg[i]->ChkTgSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjTg[i]->GetGObjInf(); + if (gobj->ChkTgHit()) { + GXColor color = {0, 0xFF, 0, 0xB4}; + mpObjTg[i]->Draw(color); + } else { + GXColor color = {0, 0xFF, 0, 0x50}; + mpObjTg[i]->Draw(color); + } + } + } + } + + if (s_Hio.CheckCoOn()) { + for (int i = 0; i < field_0x2810; i++) { + if (mpObjCo[i] != NULL && mpObjCo[i]->ChkCoSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjCo[i]->GetGObjInf(); + if (gobj->ChkCoHit()) { + GXColor color = {0xFF, 0xFF, 0xFF, 0xB4}; + mpObjCo[i]->Draw(color); + } else { + GXColor color = {0xFF, 0xFF, 0xFF, 0x50}; + mpObjCo[i]->Draw(color); + } + } + } + } + + if (s_Hio.ChkCamColDisp()) { + for (int i = 0; i < field_0x2810; i++) { + if (mpObjCo[i] != NULL && mpObjCo[i]->ChkCoSet()) { + dCcD_GObjInf* gobj = (dCcD_GObjInf*)mpObjCo[i]->GetGObjInf(); + if (!gobj->ChkCoNoCamHit()) { + GXColor color = {0xFF, 0xFF, 0, 0x50}; + mpObjCo[i]->Draw(color); + } + } + } + } + + if (s_Hio.ChkCounter()) { + OS_REPORT("At:%d,Tg:%d,Co:%d\n", field_0x280c, field_0x280e, field_0x2810); + } + #endif + DrawAfter(); - DrawClear(); + + #if DEBUG + if (!s_Hio.ChkDrawClearOff()) + #endif + { + DrawClear(); + } + mMass_Mng.Clear(); } @@ -657,7 +859,10 @@ BOOL dCcS::ChkAtTgMtrlHit(u8 i_atMtrl, u8 i_tgMtrl) { } bool dCcS::ChkNoHitGAtTg(cCcD_GObjInf const* i_atObjInf, cCcD_GObjInf const* i_tgObjInf, - cCcD_GStts*, cCcD_GStts*) { + cCcD_GStts* i_atStts, cCcD_GStts* i_tgStts) { + UNUSED(i_atStts); + UNUSED(i_tgStts); + dCcD_GObjInf* atObjInf = (dCcD_GObjInf*)i_atObjInf; dCcD_GObjInf* tgObjInf = (dCcD_GObjInf*)i_tgObjInf; diff --git a/src/d/d_debug_camera.cpp b/src/d/d_debug_camera.cpp index d01f77a298..131a2c05ae 100644 --- a/src/d/d_debug_camera.cpp +++ b/src/d/d_debug_camera.cpp @@ -1719,7 +1719,7 @@ JUtility::TColor get_color(JUtility::TColor color) { JUtility::TColor(0x80, 0x80, 0xFF, 0xFF), }; - (void)(u32)color; + UNUSED((u32)color); int var_r30 = 1; if (var_r30 && (u32)color < 9) { diff --git a/src/d/d_demo.cpp b/src/d/d_demo.cpp index 370da262a5..d6425848d3 100644 --- a/src/d/d_demo.cpp +++ b/src/d/d_demo.cpp @@ -14,6 +14,24 @@ s16 dDemo_c::m_branchId = -1; namespace { +class jstudio_tAdaptor_message : public JStudio::TAdaptor_message { +public: + typedef JStudio::TObject_message ObjectType; + + jstudio_tAdaptor_message() {} + + virtual ~jstudio_tAdaptor_message(); + virtual void adaptor_do_MESSAGE(JStudio::data::TEOperationData, const void*, u32); +}; + +class jstudio_tCreateObject_message : public JStudio::TCreateObject { +public: + jstudio_tCreateObject_message() {} + + virtual ~jstudio_tCreateObject_message(); + virtual bool create(JStudio::TObject**, const JStudio::stb::data::TParse_TBlock_object&); +}; + jstudio_tAdaptor_message::~jstudio_tAdaptor_message() {} void jstudio_tAdaptor_message::adaptor_do_MESSAGE(JStudio::data::TEOperationData iType, @@ -168,7 +186,7 @@ JStudio_JAudio2::TCreateObject* dDemo_c::m_audio; dDemo_particle_c* dDemo_c::m_particle; -jstudio_tCreateObject_message* dDemo_c::m_message; +JStudio::TCreateObject* dDemo_c::m_message; JStudio::TFactory* dDemo_c::m_factory; diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index fefbd4e885..ee6b01f9fd 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -1853,7 +1853,7 @@ int dDlst_list_c::set(dDlst_base_c**& p_start, dDlst_base_c**& p_end, dDlst_base return 0; } *p_start = p_newDlst; - *p_start++; + UNUSED(*p_start++); return 1; } diff --git a/src/d/d_ev_camera.cpp b/src/d/d_ev_camera.cpp index 6be0bf991e..442c8cc4af 100644 --- a/src/d/d_ev_camera.cpp +++ b/src/d/d_ev_camera.cpp @@ -2167,7 +2167,7 @@ bool dCamera_c::gameOverEvCamera() { mViewCache.mEye = sp230; gover_p->field_0x0++; mViewCache.mFovy = 75.0f; - bVar9 = 75.0f; + bVar9 = true; } // fallthrough intentional. case 4: { diff --git a/src/d/d_jnt_col.cpp b/src/d/d_jnt_col.cpp index 0404225b3c..b88a298250 100644 --- a/src/d/d_jnt_col.cpp +++ b/src/d/d_jnt_col.cpp @@ -376,8 +376,8 @@ int dJntCol_c::searchNearPos(cM3dGLin const* param_1, cXyz const* param_2, cXyz* mDoMtx_stack_c::YrotM(cM_atan2s(-sp1AC.x, sp1AC.z)); mDoMtx_stack_c::transM(-sp188.x, -sp188.y, -sp188.z); mDoMtx_stack_c::multVec(&sp17C, &sp194); - mDoMtx_stack_c::multVec(¶m_1->GetStartP(), &sp170); - mDoMtx_stack_c::multVec(¶m_1->GetEndP(), &sp164); + mDoMtx_stack_c::multVec(param_1->GetStartP(), &sp170); + mDoMtx_stack_c::multVec(param_1->GetEndP(), &sp164); sp1C4.SetStartEnd(sp170, sp164); sp1C = 1; } else { diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index 8c6d3215ea..a74ca3c9db 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -10490,7 +10490,7 @@ BOOL dKy_camera_water_in_status_check() { u8 dKy_pol_efftype_get(const cBgS_PolyInfo* polyinfo_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10520,7 +10520,7 @@ u8 dKy_pol_efftype_get(const cBgS_PolyInfo* polyinfo_p) { u8 dKy_pol_efftype2_get(const cBgS_PolyInfo* polyinfo_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10550,7 +10550,7 @@ u8 dKy_pol_efftype2_get(const cBgS_PolyInfo* polyinfo_p) { u8 dKy_pol_sound_get(const cBgS_PolyInfo* polyinfo_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0; } @@ -10581,7 +10581,7 @@ u8 dKy_pol_sound_get(const cBgS_PolyInfo* polyinfo_p) { u8 dKy_pol_argument_get(const cBgS_PolyInfo* polyinfo_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0; } @@ -10606,7 +10606,7 @@ u8 dKy_pol_argument_get(const cBgS_PolyInfo* polyinfo_p) { u8 dKy_pol_eff_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); u8 eff_id = 0; - if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10643,7 +10643,7 @@ u8 dKy_pol_eff_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) { u8 dKy_pol_eff_env_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); u8 eff_id = 0; - if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10680,7 +10680,7 @@ u8 dKy_pol_eff_env_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) { u8 dKy_pol_eff2_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); u8 eff_id = 0; - if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10717,7 +10717,7 @@ u8 dKy_pol_eff2_prim_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) u8 dKy_pol_eff2_env_get(const cBgS_PolyInfo* polyinfo_p, GXColor* out_color_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); u8 eff_id = 0; - if (polyinfo_p == NULL || out_color_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || out_color_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10755,7 +10755,7 @@ u8 dKy_pol_eff_alpha_get(const cBgS_PolyInfo* polyinfo_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); int z0; u8 eff_id = 0; - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10792,7 +10792,7 @@ f32 dKy_pol_eff_ratio_get(const cBgS_PolyInfo* polyinfo_p) { u8 eff_id; f32 ratio = 0.0f; - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0.0f; } @@ -10829,7 +10829,7 @@ u8 dKy_pol_eff2_alpha_get(const cBgS_PolyInfo* polyinfo_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); int z0; u8 retval = 0; - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0xFF; } @@ -10865,7 +10865,7 @@ f32 dKy_pol_eff2_ratio_get(const cBgS_PolyInfo* polyinfo_p) { dScnKy_env_light_c* kankyo = dKy_getEnvlight(); f32 ratio = 0.0f; - if (polyinfo_p == NULL || &dComIfG_Bgsp() == NULL) { + if (polyinfo_p == NULL || IS_REF_NULL(dComIfG_Bgsp())) { return 0.0f; } diff --git a/src/d/d_lib.cpp b/src/d/d_lib.cpp index 8f3597a55b..34c626ea75 100644 --- a/src/d/d_lib.cpp +++ b/src/d/d_lib.cpp @@ -108,7 +108,7 @@ u8 STControl::checkTrigger() { f32 stickValue = getValueStick(); s16 stickAngle = getAngleStick(); u8 var_r6 = 0; - s16 temp_r7 = 0x2000 - field_0x26 >> 1; + s16 temp_r7 = (0x2000 - field_0x26) >> 1; if (!cM3d_IsZero(stickValue)) { if (stickAngle < field_0x22 - 0x7000 + temp_r7) { diff --git a/src/d/d_map_path_dmap.cpp b/src/d/d_map_path_dmap.cpp index a5a9eadf38..cd76155327 100644 --- a/src/d/d_map_path_dmap.cpp +++ b/src/d/d_map_path_dmap.cpp @@ -199,10 +199,10 @@ void dMapInfo_n::getRoomMinMaxXZ(int i_roomNo, f32* i_roomLeftX, f32* i_roomInne void dMapInfo_n::getFloorParameter(f32 param_0, s8* i_floorNo, f32* param_2, f32* param_3, f32* param_4, f32* param_5) { - f32 gap_level = dStage_stagInfo_GetGapLevel(dComIfGp_getStageStagInfo()); - f32 range_up = fabsf(dStage_stagInfo_GetRangeUp(dComIfGp_getStageStagInfo())); - f32 range_down = fabsf(dStage_stagInfo_GetRangeDown(dComIfGp_getStageStagInfo())); - s8 floorNo = (f32)floor(param_0 / gap_level); + f32 gap_level = (f32)dStage_stagInfo_GetGapLevel(dComIfGp_getStageStagInfo()); + f32 range_up = fabsf((f32)dStage_stagInfo_GetRangeUp(dComIfGp_getStageStagInfo())); + f32 range_down = fabsf((f32)dStage_stagInfo_GetRangeDown(dComIfGp_getStageStagInfo())); + s8 floorNo = (s8)(f32)floor(param_0 / gap_level); if (i_floorNo != NULL) { *i_floorNo = floorNo; diff --git a/src/d/d_menu_letter.cpp b/src/d/d_menu_letter.cpp index 6997655860..d0017558b3 100644 --- a/src/d/d_menu_letter.cpp +++ b/src/d/d_menu_letter.cpp @@ -18,9 +18,9 @@ #include "d/d_lib.h" #if VERSION == VERSION_GCN_JPN -#define LINE_MAX 9 +#define D_MENU_LETTER_LINE_MAX 9 #else -#define LINE_MAX 12 +#define D_MENU_LETTER_LINE_MAX 12 #endif typedef void (dMenu_Letter_c::*initFunc)(); @@ -258,8 +258,8 @@ void dMenu_Letter_c::_draw() { uVar10 = (J2DTextBox*)field_0x2f4[i]->getPanePtr(); } J2DTextBox* uVar18 = (J2DTextBox*)field_0x2ec[i]->getPanePtr(); - mpString->getStringPage(dMenu_Letter::getLetterText(dVar1), field_0x3e3 - 1, LINE_MAX, - uVar18, uVar10, NULL, NULL, 0); + mpString->getStringPage(dMenu_Letter::getLetterText(dVar1), field_0x3e3 - 1, + D_MENU_LETTER_LINE_MAX, uVar18, uVar10, NULL, NULL, 0); } mpString->drawOutFont((J2DTextBox*)field_0x2ec[1]->getPanePtr(), -1.0f); if (mProcess == 4) { @@ -491,10 +491,10 @@ void dMenu_Letter_c::read_open_init() { text1 = (J2DTextBox*)field_0x2f4[i]->getPanePtr(); } J2DTextBox* text2 = (J2DTextBox*)field_0x2ec[i]->getPanePtr(); - mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, LINE_MAX, text2, text1, - NULL, NULL, 0); + mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, + D_MENU_LETTER_LINE_MAX, text2, text1, NULL, NULL, 0); } - field_0x3e2 = mpString->getPageMax(LINE_MAX); + field_0x3e2 = mpString->getPageMax(D_MENU_LETTER_LINE_MAX); if (field_0x3e2 > 1) { char acStack_30[20]; sprintf(acStack_30, "%d/%d", field_0x3e3, field_0x3e2); @@ -642,7 +642,8 @@ void dMenu_Letter_c::read_next_fadein_init() { text1 = (J2DTextBox*)field_0x2f4[i]->getPanePtr(); } J2DTextBox* text2 = (J2DTextBox*)field_0x2ec[i]->getPanePtr(); - mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, LINE_MAX, text2, text1, NULL, NULL, 0); + mpString->getStringPage(dMenu_Letter::getLetterText(idx), field_0x3e3 - 1, + D_MENU_LETTER_LINE_MAX, text2, text1, NULL, NULL, 0); } char acStack_30[10]; sprintf(acStack_30, "%d/%d", field_0x3e3, field_0x3e2); diff --git a/src/d/d_menu_ring.cpp b/src/d/d_menu_ring.cpp index d1fa57dd4d..cad04d6ab6 100644 --- a/src/d/d_menu_ring.cpp +++ b/src/d/d_menu_ring.cpp @@ -1507,6 +1507,8 @@ void dMenu_Ring_c::setSelectItem(int i_idx, u8 i_itemNo) { } else { field_0x6be[i_idx] = 0; } + // !@bug Out-of-bounds access into mpSelectItemTexBuf + // (innermost dimension is 2, we take index 2 which is invalid) field_0x686[i_idx] = dMeter2Info_readItemTexture( i_itemNo, mpSelectItemTexBuf[i_idx][field_0x6be[i_idx]][0], mpSelectItemTex[i_idx][0], mpSelectItemTexBuf[i_idx][field_0x6be[i_idx]][1], mpSelectItemTex[i_idx][1], diff --git a/src/d/d_msg_object.cpp b/src/d/d_msg_object.cpp index 39c44b1470..da9605c4b2 100644 --- a/src/d/d_msg_object.cpp +++ b/src/d/d_msg_object.cpp @@ -1602,7 +1602,16 @@ u8 dMsgObject_c::isSend() { } void dMsgObject_c::readMessageGroupLocal(mDoDvdThd_mountXArchive_c** p_arcMount) { +#if AVOID_UB + // largest possible value msgGroup appears to be 99, but just in case + // we leave enough space to fit INT_MAX + static char arcName[32]; +#else + // We write at least 23 bytes into this which causes an overflow, + // but in practice arcName is followed by two bytes of padding + // at the end of .bss which mitigates the problem. static char arcName[22]; +#endif int msgGroup = dStage_stagInfo_GetMsgGroup(dComIfGp_getStage()->getStagInfo()); #if REGION_PAL @@ -2133,7 +2142,7 @@ u16 dMsgObject_c::getSmellTypeMessageIDLocal() { if (smell < dItemNo_SMELL_MEDICINE_e + 1 && smell >= dItemNo_SMELL_YELIA_POUCH_e) { msgId = smell + 0x165; } else { - if (dComIfGs_getCollectSmell() != -1) { + if (dComIfGs_getCollectSmell() != 0xFF) { OS_REPORT("smell type ====> %d\n", dComIfGs_getCollectSmell()); JUT_WARN(4858, "smell type no entry!"); } diff --git a/src/d/d_msg_scrn_howl.cpp b/src/d/d_msg_scrn_howl.cpp index 58e70e84ff..07018b376d 100644 --- a/src/d/d_msg_scrn_howl.cpp +++ b/src/d/d_msg_scrn_howl.cpp @@ -19,6 +19,16 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "Z2AudioLib/Z2WolfHowlMgr.h" +// POSIX already defines a macro with this name, but we know that this specific name is +// used in TP based on assertion messages. This redefinition is scoped to this TU which +// is unlikely to ever actually need the POSIX define, so we can just redefine it. +#if defined(LINE_MAX) +#undef LINE_MAX +#endif +#define LINE_MAX 30 +//TODO: This is likely an enum value based on its name +#define PLOT_BUFFER_MAX_e 0x300 + typedef void (dMsgScrnHowl_c::*dMsgScrnHowl_cFunc)(); static dMsgScrnHowl_cFunc init_proc[5] = { diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index 1e41a0c7ef..2a8e75d82e 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -512,7 +512,7 @@ bool dPa_modelEcallBack::model_c::set(J3DModelData* i_modelData, dKy_tevstr_c co field_0x8.field_0x344 = param_1.field_0x344; typedef struct Arr{ int field_0x0[2]; - }; + } Arr; *(Arr*)&field_0x8.AmbCol = *(Arr*)¶m_1.AmbCol; *(Arr*)&field_0x8.FogCol = *(Arr*)¶m_1.FogCol; *(Arr*)&field_0x8.TevColor = *(Arr*)¶m_1.TevColor; @@ -844,11 +844,11 @@ u32 dPa_simpleEcallBack::set(cXyz const* i_pos, dKy_tevstr_c const* param_2, u8 GXColor local_60; GXColor local_64 = {0xff, 0xff, 0xff, 0xff}; GXColor local_68 = {0xff, 0xff, 0xff, 0xff}; - if (¶m_5 != NULL) { + if (IS_REF_NONNULL(param_5)) { local_64 = param_5; } - if (¶m_4 != NULL) { + if (IS_REF_NONNULL(param_4)) { local_68 = param_4; } @@ -865,11 +865,11 @@ u32 dPa_simpleEcallBack::set(cXyz const* i_pos, dKy_tevstr_c const* param_2, u8 GXColor local_70; GXColor local_74 = {0xff, 0xff, 0xff, 0xff}; GXColor local_78 = {0xff, 0xff, 0xff, 0xff}; - if (¶m_5 != NULL) { + if (IS_REF_NONNULL(param_5)) { local_74 = param_5; } - if (¶m_4 != NULL) { + if (IS_REF_NONNULL(param_4)) { local_78 = param_4; } @@ -887,13 +887,13 @@ u32 dPa_simpleEcallBack::set(cXyz const* i_pos, dKy_tevstr_c const* param_2, u8 pData->field_0x10.g = local_6c.g; pData->field_0x10.b = local_6c.b; } else { - if (¶m_4 != NULL) { + if (IS_REF_NONNULL(param_4)) { pData->field_0x0c.r = param_4.r; pData->field_0x0c.g = param_4.g; pData->field_0x0c.b = param_4.b; } - if (¶m_5 != NULL) { + if (IS_REF_NONNULL(param_5)) { pData->field_0x10.r = param_5.r; pData->field_0x10.g = param_5.g; pData->field_0x10.b = param_5.b; diff --git a/src/d/d_save.cpp b/src/d/d_save.cpp index 868dc7cfca..06b92994db 100644 --- a/src/d/d_save.cpp +++ b/src/d/d_save.cpp @@ -1810,7 +1810,7 @@ int dSv_info_c::memory_to_card(char* card_ptr, int dataNum) { OS_REPORT("(dSv_reserve_c) size %d\n", sizeof(dSv_reserve_c)); OS_REPORT("(dSv_MiniGame_c) size %d\n", sizeof(dSv_MiniGame_c)); OS_REPORT("セーブ全体情報(dSv_save_c) size %d\n", sizeof(dSv_save_c)); - printf("Write size:%d\n", card_ptr - var_r29); + printf("Write size:%d\n", (int)(card_ptr - var_r29)); // Now that we've saved, reset events if needed if (lantern_not_recovered == true) { @@ -1829,11 +1829,11 @@ int dSv_info_c::memory_to_card(char* card_ptr, int dataNum) { } if (card_ptr - var_r29 > (QUEST_LOG_SIZE - 8)) { - printf("SAVE size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), card_ptr - var_r29); + printf("SAVE size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), (int)(card_ptr - var_r29)); return -1; } - printf("SAVE size:%d\n", card_ptr - var_r29); + printf("SAVE size:%d\n", (int)(card_ptr - var_r29)); return 0; } @@ -1879,11 +1879,11 @@ int dSv_info_c::card_to_memory(char* i_cardPtr, int i_dataNum) { OS_REPORT("########### save stage ====> %s\n", dMeter2Info_getSaveStageName()); if (i_cardPtr - var_r30 > (QUEST_LOG_SIZE - 8)) { - printf("LOAD size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), i_cardPtr - var_r30); + printf("LOAD size over(%d/%d)\n", (QUEST_LOG_SIZE - 8), (int)(i_cardPtr - var_r30)); return -1; } - printf("LOAD size:%d\n", i_cardPtr - var_r30); + printf("LOAD size:%d\n", (int)(i_cardPtr - var_r30)); return 0; } @@ -1900,11 +1900,11 @@ int dSv_info_c::initdata_to_card(char* i_cardPtr, int i_dataNum) { i_cardPtr += sizeof(dSv_save_c); if (i_cardPtr - var_r30 > (QUEST_LOG_SIZE - 8)) { - printf("INIT size over %d/%d\n", (QUEST_LOG_SIZE - 8), i_cardPtr - var_r30); + printf("INIT size over %d/%d\n", (QUEST_LOG_SIZE - 8), (int)(i_cardPtr - var_r30)); return -1; } - printf("INIT size:%d\n", i_cardPtr - var_r30); + printf("INIT size:%d\n", (int)(i_cardPtr - var_r30)); return 0; } diff --git a/src/d/d_shop_system.cpp b/src/d/d_shop_system.cpp index 364c3be7ea..f1636bb093 100644 --- a/src/d/d_shop_system.cpp +++ b/src/d/d_shop_system.cpp @@ -1463,9 +1463,8 @@ bool dShopSystem_c::searchItemActor() { for (int i = 0; i < dShopSystem_sellItemMax; i++) { u32 processId = dShopSystem_itemActor[i]->getProcessID(); mItemCtrl.setItemIndex(i, processId); - mItemCtrl.setMessageIndex(i, (u16)dShopSystem_itemActor[i]->home.angle.x != 0xFFFF ? - (u16)dShopSystem_itemActor[i]->home.angle.x : - -1); + int itemFlowId = dShopSystem_itemActor[i]->getFlowNodeNum(); + mItemCtrl.setMessageIndex(i, itemFlowId); if (processId + 0x10000 == 0xFFFF) { onFlag(i); diff --git a/src/f_pc/f_pc_priority.cpp b/src/f_pc/f_pc_priority.cpp index cbd62a4053..35f331d687 100644 --- a/src/f_pc/f_pc_priority.cpp +++ b/src/f_pc/f_pc_priority.cpp @@ -110,7 +110,7 @@ int fpcPi_Change(process_priority_class* i_procPriority, fpc_ProcID i_layerID, u int fpcPi_Handler() { process_priority_class* i_procPriority; - while (i_procPriority = fpcPi_GetFromQueue()) { + while ((i_procPriority = fpcPi_GetFromQueue())) { base_process_class* process = (base_process_class*)i_procPriority->base.mpTagData; layer_management_tag_class* pLayerTag = &process->layer_tag; line_tag* pLineTag = &process->line_tag_; diff --git a/src/m_Do/m_Do_dvd_thread.cpp b/src/m_Do/m_Do_dvd_thread.cpp index 526b5a255e..8949988c7c 100644 --- a/src/m_Do/m_Do_dvd_thread.cpp +++ b/src/m_Do/m_Do_dvd_thread.cpp @@ -156,7 +156,7 @@ static void cb(void* param_0) { void mDoDvdThd_param_c::mainLoop() { mDoDvdThd_command_c* command; while (this->waitForKick() != 0) { - while (command = this->getFirstCommand()) { + while ((command = this->getFirstCommand())) { this->cut(command); if (mDoDvdThd::SyncWidthSound) { JASDvd::getThreadPointer()->sendCmdMsg(cb, &command, 4); diff --git a/src/m_Do/m_Do_ext.cpp b/src/m_Do/m_Do_ext.cpp index fc0e6d71c3..8d46884de9 100644 --- a/src/m_Do/m_Do_ext.cpp +++ b/src/m_Do/m_Do_ext.cpp @@ -72,11 +72,11 @@ static void mDoExt_setJ3DData(Mtx mtx, const J3DTransformInfo* transformInfo, u1 *mtx_p++ *= sp0C.x; *mtx_p++ *= sp0C.x; *mtx_p++ *= sp0C.x; - *mtx_p++; + UNUSED(*mtx_p++); *mtx_p++ *= sp0C.y; *mtx_p++ *= sp0C.y; *mtx_p++ *= sp0C.y; - *mtx_p++; + UNUSED(*mtx_p++); *mtx_p++ *= sp0C.z; *mtx_p++ *= sp0C.z; *mtx_p++ *= sp0C.z;