From 802ac13812281e15a3041334dbcdcadf018f71ce Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 30 Mar 2020 00:53:10 -0400 Subject: [PATCH] CWorld: Make use of std::array where applicable --- Runtime/World/CWorld.cpp | 23 ++++++++++++++--------- Runtime/World/CWorld.hpp | 3 ++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Runtime/World/CWorld.cpp b/Runtime/World/CWorld.cpp index fb8910c12..69b56de8d 100644 --- a/Runtime/World/CWorld.cpp +++ b/Runtime/World/CWorld.cpp @@ -233,15 +233,18 @@ TAreaId CWorld::IGetAreaId(CAssetId id) const { } void CWorld::MoveToChain(CGameArea* area, EChain chain) { - if (area->x138_curChain == chain) + if (area->x138_curChain == chain) { return; + } - if (area->x138_curChain != EChain::Invalid) - if (x4c_chainHeads[int(area->x138_curChain)] == area) - x4c_chainHeads[int(area->x138_curChain)] = area->x130_next; + if (area->x138_curChain != EChain::Invalid) { + if (x4c_chainHeads[size_t(area->x138_curChain)] == area) { + x4c_chainHeads[size_t(area->x138_curChain)] = area->x130_next; + } + } - area->SetChain(x4c_chainHeads[int(chain)], chain); - x4c_chainHeads[int(chain)] = area; + area->SetChain(x4c_chainHeads[size_t(chain)], chain); + x4c_chainHeads[size_t(chain)] = area; } void CWorld::MoveAreaToAliveChain(TAreaId aid) { MoveToChain(x18_areas[aid].get(), EChain::Alive); } @@ -307,12 +310,14 @@ bool CWorld::CheckWorldComplete(CStateManager* mgr, TAreaId id, CAssetId mreaId) r.readUint32Big(); x18_areas.reserve(areaCount); - for (u32 i = 0; i < areaCount; ++i) + for (u32 i = 0; i < areaCount; ++i) { x18_areas.push_back(std::make_unique(r, i, version)); + } - if (x48_chainCount < 5) { - for (int i = x48_chainCount; i < 5; ++i) + if (x48_chainCount < x4c_chainHeads.size()) { + for (size_t i = x48_chainCount; i < x4c_chainHeads.size(); ++i) { x4c_chainHeads[i] = nullptr; + } x48_chainCount = 5; } diff --git a/Runtime/World/CWorld.hpp b/Runtime/World/CWorld.hpp index 90c02aec1..2e2065d21 100644 --- a/Runtime/World/CWorld.hpp +++ b/Runtime/World/CWorld.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -123,7 +124,7 @@ private: std::unique_ptr x40_loadBuf; u32 x44_bufSz; u32 x48_chainCount = 0; - CGameArea* x4c_chainHeads[5] = {}; + std::array x4c_chainHeads{}; IObjectStore& x60_objectStore; IFactory& x64_resFactory;