summaryrefslogtreecommitdiff
path: root/ZAPD
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2023-05-01 19:24:14 -0400
committerGitHub <noreply@github.com>2023-05-01 19:24:14 -0400
commit53e140e8419f9c067de22949bcea45ede750bf75 (patch)
tree1ce185f1d1ddbfe998cbded0dcbca6a28fe22f5b /ZAPD
parentc5aff7567927be4c0fa468614f545b886e09ffe6 (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')
-rw-r--r--ZAPD/ZCollision.cpp18
-rw-r--r--ZAPD/ZPath.cpp8
2 files changed, 22 insertions, 4 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;
}
diff --git a/ZAPD/ZPath.cpp b/ZAPD/ZPath.cpp
index 5dae65a..ae50f8a 100644
--- a/ZAPD/ZPath.cpp
+++ b/ZAPD/ZPath.cpp
@@ -186,7 +186,13 @@ std::string PathwayEntry::GetBodySourceCode() const
declaration +=
StringHelper::Sprintf("%i, %i, %i, %s", numPoints, unk1, unk2, listName.c_str());
else
- declaration += StringHelper::Sprintf("%i, %s", numPoints, listName.c_str());
+ {
+ if (numPoints > 0)
+ declaration +=
+ StringHelper::Sprintf("ARRAY_COUNT(%s), %s", listName.c_str(), listName.c_str());
+ else
+ declaration += StringHelper::Sprintf("%i, %s", numPoints, listName.c_str());
+ }
return declaration;
}