From 45ea19040da65f060cbf608dc0cb38643d4f03f5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 29 Mar 2020 20:54:29 -0400 Subject: [PATCH] CGameState: Make use of std::array where applicable --- Runtime/CGameState.cpp | 10 ++++++---- Runtime/CGameState.hpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Runtime/CGameState.cpp b/Runtime/CGameState.cpp index 92d312eb8..9c4bf141c 100644 --- a/Runtime/CGameState.cpp +++ b/Runtime/CGameState.cpp @@ -143,8 +143,9 @@ CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx x9c_transManager = std::make_shared(); x228_25_initPowerupsAtFirstSpawn = true; - for (u32 i = 0; i < 128; i++) - x0_[i] = stream.ReadEncoded(8); + for (bool& value : x0_) { + value = stream.ReadEncoded(8) != 0; + } stream.ReadEncoded(32); x228_24_hardMode = stream.ReadEncoded(1); @@ -206,8 +207,9 @@ void CGameState::WriteBackupBuf() { } void CGameState::PutTo(CBitStreamWriter& writer) { - for (u32 i = 0; i < 128; i++) - writer.WriteEncoded(x0_[i], 8); + for (const bool value : x0_) { + writer.WriteEncoded(u32(value), 8); + } writer.WriteEncoded(CBasics::ToWiiTime(std::chrono::system_clock::now()) / CBasics::TICKS_PER_SECOND, 32); writer.WriteEncoded(x228_24_hardMode, 1); diff --git a/Runtime/CGameState.hpp b/Runtime/CGameState.hpp index 1c954fddf..32349f8d9 100644 --- a/Runtime/CGameState.hpp +++ b/Runtime/CGameState.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -67,7 +68,7 @@ public: class CGameState { friend class CStateManager; - bool x0_[128] = {}; + std::array x0_{}; u32 x80_; CAssetId x84_mlvlId; std::vector x88_worldStates;