From bcc27ddd5c4caa1205d4ca931e8e59bddc5c1a85 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Jun 2020 19:38:20 -0400 Subject: [PATCH] CAudioGroupLoader: Make use of unsigned stream helpers where applicable Same behavior, minus implicit sign conversions. --- .../Resource/Factory/CAudioGroupLoader.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Core/Resource/Factory/CAudioGroupLoader.cpp b/src/Core/Resource/Factory/CAudioGroupLoader.cpp index 22148254..d0513b54 100644 --- a/src/Core/Resource/Factory/CAudioGroupLoader.cpp +++ b/src/Core/Resource/Factory/CAudioGroupLoader.cpp @@ -4,8 +4,8 @@ std::unique_ptr CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR { // For now we only load sound define IDs and the group ID! // Version check - uint32 Check = rAGSC.PeekLong(); - EGame Game = (Check == 0x1 ? EGame::Echoes : EGame::Prime); + const uint32 Check = rAGSC.PeekULong(); + const EGame Game = Check == 0x1 ? EGame::Echoes : EGame::Prime; auto pOut = std::make_unique(pEntry); // Read header, navigate to Proj chunk @@ -13,7 +13,7 @@ std::unique_ptr CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR { rAGSC.ReadString(); pOut->mGroupName = rAGSC.ReadString(); - uint32 PoolSize = rAGSC.ReadLong(); + const uint32 PoolSize = rAGSC.ReadULong(); rAGSC.Seek(PoolSize + 0x4, SEEK_CUR); } @@ -21,22 +21,22 @@ std::unique_ptr CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR { rAGSC.Seek(0x4, SEEK_CUR); pOut->mGroupName = rAGSC.ReadString(); - pOut->mGroupID = rAGSC.ReadShort(); - uint32 PoolSize = rAGSC.ReadLong(); + pOut->mGroupID = rAGSC.ReadUShort(); + const uint32 PoolSize = rAGSC.ReadULong(); rAGSC.Seek(0xC + PoolSize, SEEK_CUR); } // Read needed data from the Proj chunk - uint16 Peek = rAGSC.PeekShort(); + const uint16 Peek = rAGSC.PeekUShort(); if (Peek != 0xFFFF) { - uint32 ProjStart = rAGSC.Tell(); + const uint32 ProjStart = rAGSC.Tell(); rAGSC.Seek(0x4, SEEK_CUR); - uint16 GroupID = rAGSC.ReadShort(); - uint16 GroupType = rAGSC.ReadShort(); + const uint16 GroupID = rAGSC.ReadUShort(); + const uint16 GroupType = rAGSC.ReadUShort(); rAGSC.Seek(0x14, SEEK_CUR); - uint32 SfxTableStart = rAGSC.ReadLong(); + const uint32 SfxTableStart = rAGSC.ReadULong(); if (Game == EGame::Prime) pOut->mGroupID = GroupID; @@ -46,12 +46,12 @@ std::unique_ptr CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR if (GroupType == 1) { rAGSC.Seek(ProjStart + SfxTableStart, SEEK_SET); - uint16 NumSounds = rAGSC.ReadShort(); + const uint16 NumSounds = rAGSC.ReadUShort(); rAGSC.Seek(0x2, SEEK_CUR); for (uint32 iSfx = 0; iSfx < NumSounds; iSfx++) { - pOut->mDefineIDs.push_back( rAGSC.ReadShort() ); + pOut->mDefineIDs.push_back(rAGSC.ReadUShort()); rAGSC.Seek(0x8, SEEK_CUR); } } @@ -63,7 +63,7 @@ std::unique_ptr CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR std::unique_ptr CAudioGroupLoader::LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry) { auto pOut = std::make_unique(pEntry); - uint32 NumMacroIDs = rATBL.ReadLong(); + const uint32 NumMacroIDs = rATBL.ReadULong(); for (uint32 iMacro = 0; iMacro < NumMacroIDs; iMacro++) pOut->mDefineIDs.push_back( rATBL.ReadShort() ); @@ -74,11 +74,11 @@ std::unique_ptr CAudioGroupLoader::LoadATBL(IInputStream& rAT std::unique_ptr CAudioGroupLoader::LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry) { auto pOut = std::make_unique(pEntry); - uint32 NumStrings = rSTLC.ReadLong(); + const uint32 NumStrings = rSTLC.ReadULong(); pOut->mStringList.reserve(NumStrings); for (uint32 iStr = 0; iStr < NumStrings; iStr++) - pOut->mStringList.push_back( rSTLC.ReadString() ); + pOut->mStringList.push_back(rSTLC.ReadString()); return pOut; }