From 175502cb0db0d5d9136d95fdf3ee19f6bd1fafee Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 12 Apr 2020 15:23:26 -0400 Subject: [PATCH] CScriptMazeNode: Make use of std::array where applicable Same behavior, stronger typing. --- Runtime/World/CScriptMazeNode.cpp | 11 ++++++----- Runtime/World/CScriptMazeNode.hpp | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Runtime/World/CScriptMazeNode.cpp b/Runtime/World/CScriptMazeNode.cpp index 198a1f7fe..2fa0d173e 100644 --- a/Runtime/World/CScriptMazeNode.cpp +++ b/Runtime/World/CScriptMazeNode.cpp @@ -8,7 +8,7 @@ namespace urde { -atUint32 CScriptMazeNode::sMazeSeeds[300] = {0}; +std::array CScriptMazeNode::sMazeSeeds{}; CScriptMazeNode::CScriptMazeNode(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, bool active, s32 w1, s32 w2, s32 w3, @@ -29,10 +29,11 @@ void CScriptMazeNode::Accept(IVisitor& visitor) { visitor.Visit(this); } void CScriptMazeNode::LoadMazeSeeds() { const SObjectTag* tag = g_ResFactory->GetResourceIdByName("DUMB_MazeSeeds"); - u32 resSize = g_ResFactory->ResourceSize(*tag); - std::unique_ptr buf = g_ResFactory->LoadResourceSync(*tag); + const u32 resSize = g_ResFactory->ResourceSize(*tag); + const std::unique_ptr buf = g_ResFactory->LoadResourceSync(*tag); CMemoryInStream in(buf.get(), resSize); - for (u32 i = 0; i < 300; ++i) - sMazeSeeds[i] = in.readUint32Big(); + for (auto& seed : sMazeSeeds) { + seed = in.readUint32Big(); + } } } // namespace urde diff --git a/Runtime/World/CScriptMazeNode.hpp b/Runtime/World/CScriptMazeNode.hpp index 18072f7d0..7ad096af6 100644 --- a/Runtime/World/CScriptMazeNode.hpp +++ b/Runtime/World/CScriptMazeNode.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include "Runtime/RetroTypes.hpp" @@ -9,7 +10,7 @@ namespace urde { class CScriptMazeNode : public CActor { - static u32 sMazeSeeds[300]; + static std::array sMazeSeeds; s32 xe8_; s32 xec_; s32 xf0_;