From abd576a43aefb2c4cb5c077c247ea48595bfddbc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 12 Apr 2020 11:03:47 -0400 Subject: [PATCH] CBabygoth: Make use of std::array where applicable Same behavior, no implicit array to pointer decay. We can also move all this data into the cpp file fully. --- Runtime/MP1/World/CBabygoth.cpp | 23 +++++++++++++++-------- Runtime/MP1/World/CBabygoth.hpp | 5 +---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Runtime/MP1/World/CBabygoth.cpp b/Runtime/MP1/World/CBabygoth.cpp index 775fa57ee..d021b159d 100644 --- a/Runtime/MP1/World/CBabygoth.cpp +++ b/Runtime/MP1/World/CBabygoth.cpp @@ -1,5 +1,7 @@ #include "Runtime/MP1/World/CBabygoth.hpp" +#include + #include "Runtime/CSimplePool.hpp" #include "Runtime/CStateManager.hpp" #include "Runtime/GameGlobalObjects.hpp" @@ -21,7 +23,15 @@ #include "TCastTo.hpp" // Generated file, do not modify include path namespace urde::MP1 { -const std::string_view CBabygoth::skpMouthDamageJoint = "LCTR_SHEMOUTH"sv; +constexpr std::string_view skpMouthDamageJoint = "LCTR_SHEMOUTH"sv; + +constexpr std::array skSphereJointList{{ + {"L_knee", 1.2f}, + {"R_knee", 1.2f}, + {"LCTR_SHEMOUTH", 1.7f}, + {"Pelvis", 1.2f}, + {"butt_LCTR", 0.9f}, +}}; CBabygothData::CBabygothData(CInputStream& in) : x0_fireballAttackTime(in.readFloatBig()) @@ -298,13 +308,10 @@ void CBabygoth::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, E CPatterned::DoUserAnimEvent(mgr, node, type, dt); } -const SSphereJointInfo CBabygoth::skSphereJointList[skSphereJointCount] = { - {"L_knee", 1.2f}, {"R_knee", 1.2f}, {"LCTR_SHEMOUTH", 1.7f}, {"Pelvis", 1.2f}, {"butt_LCTR", 0.9f}}; - -void CBabygoth::AddSphereCollisionList(const SSphereJointInfo* sphereJointInfo, s32 jointCount, +void CBabygoth::AddSphereCollisionList(const SSphereJointInfo* sphereJointInfo, size_t jointCount, std::vector& jointList) { - for (s32 i = 0; i < jointCount; ++i) { - CSegId seg = GetModelData()->GetAnimationData()->GetLocatorSegId(sphereJointInfo[i].name); + for (size_t i = 0; i < jointCount; ++i) { + const CSegId seg = GetModelData()->GetAnimationData()->GetLocatorSegId(sphereJointInfo[i].name); jointList.push_back( CJointCollisionDescription::SphereCollision(seg, sphereJointInfo[i].radius, sphereJointInfo[i].name, 1000.f)); } @@ -312,7 +319,7 @@ void CBabygoth::AddSphereCollisionList(const SSphereJointInfo* sphereJointInfo, void CBabygoth::SetupCollisionManager(CStateManager& mgr) { std::vector joints; - AddSphereCollisionList(skSphereJointList, skSphereJointCount, joints); + AddSphereCollisionList(skSphereJointList.data(), skSphereJointList.size(), joints); x928_colActMgr = std::make_unique(mgr, GetUniqueId(), GetAreaIdAlways(), joints, false); x928_colActMgr->SetActive(mgr, GetActive()); diff --git a/Runtime/MP1/World/CBabygoth.hpp b/Runtime/MP1/World/CBabygoth.hpp index a39674db2..0a8159faf 100644 --- a/Runtime/MP1/World/CBabygoth.hpp +++ b/Runtime/MP1/World/CBabygoth.hpp @@ -63,9 +63,6 @@ public: enum class EShellState { Default, CrackOne, CrackTwo, Destroyed }; private: - static constexpr s32 skSphereJointCount = 5; - static const SSphereJointInfo skSphereJointList[skSphereJointCount]; - static const std::string_view skpMouthDamageJoint; s32 x568_stateProg = -1; EShellState x56c_shellState = EShellState::Default; CBabygothData x570_babyData; @@ -115,7 +112,7 @@ private: bool xa49_28_onApproachPath : 1; bool xa49_29_objectSpaceCollision : 1; - void AddSphereCollisionList(const SSphereJointInfo*, s32, std::vector&); + void AddSphereCollisionList(const SSphereJointInfo*, size_t, std::vector&); void SetupCollisionManager(CStateManager&);