From 53e140e8419f9c067de22949bcea45ede750bf75 Mon Sep 17 00:00:00 2001 From: Nicholas Estelami Date: Mon, 1 May 2023 19:24:14 -0400 Subject: 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 --- ZAPD/ZCollision.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'ZAPD/ZCollision.cpp') 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; } -- cgit v1.2.3