diff options
| author | LagoLunatic <LagoLunatic@users.noreply.github.com> | 2025-06-20 02:41:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-19 23:41:43 -0700 |
| commit | ac069664149342aff58ed84cf51c62b3eb8399da (patch) | |
| tree | eab73c3959a6f052a388fe96fc46b42d48a16508 /include/JSystem/J3DGraphAnimator | |
| parent | 25d13c76e4080c7b2fabf00b7836ba13de7e9dc0 (diff) | |
Add more J3D_ASSERTs (#2491)
* Fix debug build
* Add more J3D_ASSERTs
* Move J3DShapeMtx to correct header for assert
* Add VSCode task for ninja changes_all
Diffstat (limited to 'include/JSystem/J3DGraphAnimator')
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DAnimation.h | 32 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DCluster.h | 7 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DJointTree.h | 5 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h | 6 | ||||
| -rw-r--r-- | include/JSystem/J3DGraphAnimator/J3DShapeTable.h | 6 |
5 files changed, 44 insertions, 12 deletions
diff --git a/include/JSystem/J3DGraphAnimator/J3DAnimation.h b/include/JSystem/J3DGraphAnimator/J3DAnimation.h index ca556f1546..58a0f1912b 100644 --- a/include/JSystem/J3DGraphAnimator/J3DAnimation.h +++ b/include/JSystem/J3DGraphAnimator/J3DAnimation.h @@ -589,14 +589,23 @@ public: calcTransform(getFrame(), param_0, pSRTInfo); } - u16 getUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx]; } + u16 getUpdateMaterialID(u16 idx) const { + J3D_ASSERT(1029, idx < mTrackNum / 3, "Error : range over."); + return mUpdateMaterialID[idx]; + } u16 getUpdateMaterialNum() const { return mTrackNum / 3; } u16 getPostUpdateMaterialNum() const { return field_0x4a / 3; } - int getUpdateTexMtxID(u16 idx) const { return mUpdateTexMtxID[idx]; } + int getUpdateTexMtxID(u16 idx) const { + J3D_ASSERT(1017, idx < mTrackNum / 3, "Error : range over."); + return mUpdateTexMtxID[idx]; + } bool isValidUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx] != 0xffff; } u32 getTexMtxCalcType() { return mTexMtxCalcType; } - Vec* getSRTCenter(u16 idx) { return &mSRTCenter[idx]; } + Vec* getSRTCenter(u16 idx) { + J3D_ASSERT(1047, idx < mTrackNum / 3, "Error : range over."); + return &mSRTCenter[idx]; + } /* 0x0C */ int mDecShift; /* 0x10 */ J3DAnmTransformKeyTable* mAnmTable; @@ -640,7 +649,10 @@ public: /* 8032BD20 */ virtual ~J3DAnmTexPattern() {} /* 8032BD94 */ virtual s32 getKind() const { return 2; } - u16 getUpdateMaterialID(u16 idx) const { return mUpdateMaterialID[idx]; } + u16 getUpdateMaterialID(u16 idx) const { + J3D_ASSERT(2288, idx < mUpdateMaterialNum, "Error : range over."); + return mUpdateMaterialID[idx]; + } u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; } bool isValidUpdateMaterialID(u16 id) const { return mUpdateMaterialID[id] != 0xFFFF; } J3DAnmTexPatternFullTable* getAnmTable() { return mAnmTable; } @@ -671,8 +683,14 @@ public: u16 getCRegUpdateMaterialNum() const { return mCRegUpdateMaterialNum; } u16 getKRegUpdateMaterialNum() const { return mKRegUpdateMaterialNum; } - u16 getCRegUpdateMaterialID(u16 idx) const { return mCRegUpdateMaterialID[idx]; } - u16 getKRegUpdateMaterialID(u16 idx) const { return mKRegUpdateMaterialID[idx]; } + u16 getCRegUpdateMaterialID(u16 idx) const { + J3D_ASSERT(2100, idx < mCRegUpdateMaterialNum, "Error : range over."); + return mCRegUpdateMaterialID[idx]; + } + u16 getKRegUpdateMaterialID(u16 idx) const { + J3D_ASSERT(2140, idx < mKRegUpdateMaterialNum, "Error : range over."); + return mKRegUpdateMaterialID[idx]; + } const J3DAnmCRegKeyTable* getAnmCRegKeyTable() const { return mAnmCRegKeyTable; } const J3DAnmKRegKeyTable* getAnmKRegKeyTable() const { return mAnmKRegKeyTable; } @@ -722,7 +740,7 @@ public: u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; } bool isValidUpdateMaterialID(u16 id) const { return mUpdateMaterialID[id] != 0xFFFF; } u16 getUpdateMaterialID(u16 idx) const { - J3D_ASSERT(1578, idx < mUpdateMaterialNum, "Error : range over.") + J3D_ASSERT(1578, idx < mUpdateMaterialNum, "Error : range over."); return mUpdateMaterialID[idx]; } diff --git a/include/JSystem/J3DGraphAnimator/J3DCluster.h b/include/JSystem/J3DGraphAnimator/J3DCluster.h index c575e890f9..ded3d1a2ca 100644 --- a/include/JSystem/J3DGraphAnimator/J3DCluster.h +++ b/include/JSystem/J3DGraphAnimator/J3DCluster.h @@ -81,12 +81,15 @@ public: /* 8032E364 */ void setAnm(J3DAnmCluster*); J3DCluster* getClusterPointer(u16 index) { - J3D_ASSERT(186, (index < mClusterNum),"Error : range over."); + J3D_ASSERT(186, (index < mClusterNum), "Error : range over."); return &mClusterPointer[index]; } u16 getClusterNum() const { return mClusterNum; } u16 getClusterKeyNum() const { return mClusterKeyNum; } - J3DClusterKey* getClusterKeyPointer(u16 i) { return &mClusterKeyPointer[i]; } + J3DClusterKey* getClusterKeyPointer(u16 i) { + J3D_ASSERT(199, (i < mClusterKeyNum), "Error : range over."); + return &mClusterKeyPointer[i]; + } f32* getVtxPos() { return mVtxPos; } f32* getVtxNrm() { return mVtxNrm; } diff --git a/include/JSystem/J3DGraphAnimator/J3DJointTree.h b/include/JSystem/J3DGraphAnimator/J3DJointTree.h index 3b9bb85539..01c55620bd 100644 --- a/include/JSystem/J3DGraphAnimator/J3DJointTree.h +++ b/include/JSystem/J3DGraphAnimator/J3DJointTree.h @@ -63,7 +63,10 @@ public: J3DDrawMtxData* getDrawMtxData() { return &mDrawMtxData; } JUTNameTab* getJointName() const { return mJointName; } J3DJoint* getRootNode() { return mRootNode; } - J3DJoint* getJointNodePointer(u16 idx) const { return mJointNodePointer[idx]; } + J3DJoint* getJointNodePointer(u16 idx) const { + J3D_ASSERT(139, idx < mJointNum, "Error : range over."); + return mJointNodePointer[idx]; + } J3DMtxCalc* getBasicMtxCalc() const { return mBasicMtxCalc; } Mtx& getInvJointMtx(int idx) { return mInvJointMtx[idx]; } u32 getModelDataType() const { return mModelDataType; } diff --git a/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h index f0f21a8b2b..eb53887ea4 100644 --- a/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h +++ b/include/JSystem/J3DGraphAnimator/J3DMaterialAttach.h @@ -1,6 +1,7 @@ #ifndef J3DMATERIALATTACH_H #define J3DMATERIALATTACH_H +#include "JSystem/JUtility/JUTAssert.h" #include "dolphin/types.h" class J3DMaterial; @@ -31,7 +32,10 @@ public: /* 8032F604 */ virtual ~J3DMaterialTable(); - J3DMaterial* getMaterialNodePointer(u16 idx) const { return mMaterialNodePointer[idx]; } + J3DMaterial* getMaterialNodePointer(u16 idx) const { + J3D_ASSERT(92, idx < mMaterialNum, "Error : range over."); + return mMaterialNodePointer[idx]; + } J3DTexture* getTexture() const { return mTexture; } JUTNameTab* getTextureName() const { return mTextureName; } diff --git a/include/JSystem/J3DGraphAnimator/J3DShapeTable.h b/include/JSystem/J3DGraphAnimator/J3DShapeTable.h index d95c9054ef..6754b6f83a 100644 --- a/include/JSystem/J3DGraphAnimator/J3DShapeTable.h +++ b/include/JSystem/J3DGraphAnimator/J3DShapeTable.h @@ -2,6 +2,7 @@ #define J3DSHAPETABLE_H #include "JSystem/J3DGraphBase/J3DShape.h" +#include "JSystem/JUtility/JUTAssert.h" class JUTNameTab; @@ -25,7 +26,10 @@ public: virtual ~J3DShapeTable() {} u16 getShapeNum() const { return mShapeNum; } - J3DShape* getShapeNodePointer(u16 idx) const { return mShapeNodePointer[idx]; } + J3DShape* getShapeNodePointer(u16 idx) const { + J3D_ASSERT(85, idx < mShapeNum, "Error : range over."); + return mShapeNodePointer[idx]; + } private: friend class J3DModelLoader; |
