diff options
| author | Nicholas Estelami <NEstelami@users.noreply.github.com> | 2023-05-01 19:24:14 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-01 19:24:14 -0400 |
| commit | 53e140e8419f9c067de22949bcea45ede750bf75 (patch) | |
| tree | 1ce185f1d1ddbfe998cbded0dcbca6a28fe22f5b /ZAPD/ZCollision.cpp | |
| parent | c5aff7567927be4c0fa468614f545b886e09ffe6 (diff) | |
Use ARRAY_COUNT where possible. (#287)
* ZCollision updated to use ARRAY_COUNT
* ZPath updated to use ARRAY_COUNT
* Updated ZCollision and ZPath to only use array count when array size > 0
Diffstat (limited to 'ZAPD/ZCollision.cpp')
| -rw-r--r-- | ZAPD/ZCollision.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/ZAPD/ZCollision.cpp b/ZAPD/ZCollision.cpp index 5bd3d93..25d4c7e 100644 --- a/ZAPD/ZCollision.cpp +++ b/ZAPD/ZCollision.cpp @@ -219,11 +219,19 @@ std::string ZCollisionHeader::GetBodySourceCode() const std::string vtxName; Globals::Instance->GetSegmentedPtrName(vtxAddress, parent, "Vec3s", vtxName); - declaration += StringHelper::Sprintf("\t%i, %s,\n", numVerts, vtxName.c_str()); + + if (numVerts > 0) + declaration += StringHelper::Sprintf("\tARRAY_COUNT(%s), %s,\n", vtxName.c_str(), vtxName.c_str()); + else + declaration += StringHelper::Sprintf("\t%i, %s,\n", numVerts, vtxName.c_str()); std::string polyName; Globals::Instance->GetSegmentedPtrName(polyAddress, parent, "CollisionPoly", polyName); - declaration += StringHelper::Sprintf("\t%i, %s,\n", numPolygons, polyName.c_str()); + + if (numPolygons > 0) + declaration += StringHelper::Sprintf("\tARRAY_COUNT(%s), %s,\n", polyName.c_str(), polyName.c_str()); + else + declaration += StringHelper::Sprintf("\t%i, %s,\n", numPolygons, polyName.c_str()); std::string surfaceName; Globals::Instance->GetSegmentedPtrName(polyTypeDefAddress, parent, "SurfaceType", surfaceName); @@ -235,7 +243,11 @@ std::string ZCollisionHeader::GetBodySourceCode() const std::string waterBoxName; Globals::Instance->GetSegmentedPtrName(waterBoxAddress, parent, "WaterBox", waterBoxName); - declaration += StringHelper::Sprintf("\t%i, %s\n", numWaterBoxes, waterBoxName.c_str()); + + if (numWaterBoxes > 0) + declaration += StringHelper::Sprintf("\tARRAY_COUNT(%s), %s\n", waterBoxName.c_str(), waterBoxName.c_str()); + else + declaration += StringHelper::Sprintf("\t%i, %s\n", numWaterBoxes, waterBoxName.c_str()); return declaration; } |
