CAudioGroupLoader: Make use of unsigned stream helpers where applicable

Same behavior, minus implicit sign conversions.
This commit is contained in:
Lioncash 2020-06-18 19:38:20 -04:00
parent 59cfe6fc02
commit bcc27ddd5c
1 changed files with 15 additions and 15 deletions

View File

@ -4,8 +4,8 @@ std::unique_ptr<CAudioGroup> CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR
{ {
// For now we only load sound define IDs and the group ID! // For now we only load sound define IDs and the group ID!
// Version check // Version check
uint32 Check = rAGSC.PeekLong(); const uint32 Check = rAGSC.PeekULong();
EGame Game = (Check == 0x1 ? EGame::Echoes : EGame::Prime); const EGame Game = Check == 0x1 ? EGame::Echoes : EGame::Prime;
auto pOut = std::make_unique<CAudioGroup>(pEntry); auto pOut = std::make_unique<CAudioGroup>(pEntry);
// Read header, navigate to Proj chunk // Read header, navigate to Proj chunk
@ -13,7 +13,7 @@ std::unique_ptr<CAudioGroup> CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR
{ {
rAGSC.ReadString(); rAGSC.ReadString();
pOut->mGroupName = rAGSC.ReadString(); pOut->mGroupName = rAGSC.ReadString();
uint32 PoolSize = rAGSC.ReadLong(); const uint32 PoolSize = rAGSC.ReadULong();
rAGSC.Seek(PoolSize + 0x4, SEEK_CUR); rAGSC.Seek(PoolSize + 0x4, SEEK_CUR);
} }
@ -21,22 +21,22 @@ std::unique_ptr<CAudioGroup> CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR
{ {
rAGSC.Seek(0x4, SEEK_CUR); rAGSC.Seek(0x4, SEEK_CUR);
pOut->mGroupName = rAGSC.ReadString(); pOut->mGroupName = rAGSC.ReadString();
pOut->mGroupID = rAGSC.ReadShort(); pOut->mGroupID = rAGSC.ReadUShort();
uint32 PoolSize = rAGSC.ReadLong(); const uint32 PoolSize = rAGSC.ReadULong();
rAGSC.Seek(0xC + PoolSize, SEEK_CUR); rAGSC.Seek(0xC + PoolSize, SEEK_CUR);
} }
// Read needed data from the Proj chunk // Read needed data from the Proj chunk
uint16 Peek = rAGSC.PeekShort(); const uint16 Peek = rAGSC.PeekUShort();
if (Peek != 0xFFFF) if (Peek != 0xFFFF)
{ {
uint32 ProjStart = rAGSC.Tell(); const uint32 ProjStart = rAGSC.Tell();
rAGSC.Seek(0x4, SEEK_CUR); rAGSC.Seek(0x4, SEEK_CUR);
uint16 GroupID = rAGSC.ReadShort(); const uint16 GroupID = rAGSC.ReadUShort();
uint16 GroupType = rAGSC.ReadShort(); const uint16 GroupType = rAGSC.ReadUShort();
rAGSC.Seek(0x14, SEEK_CUR); rAGSC.Seek(0x14, SEEK_CUR);
uint32 SfxTableStart = rAGSC.ReadLong(); const uint32 SfxTableStart = rAGSC.ReadULong();
if (Game == EGame::Prime) if (Game == EGame::Prime)
pOut->mGroupID = GroupID; pOut->mGroupID = GroupID;
@ -46,12 +46,12 @@ std::unique_ptr<CAudioGroup> CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR
if (GroupType == 1) if (GroupType == 1)
{ {
rAGSC.Seek(ProjStart + SfxTableStart, SEEK_SET); rAGSC.Seek(ProjStart + SfxTableStart, SEEK_SET);
uint16 NumSounds = rAGSC.ReadShort(); const uint16 NumSounds = rAGSC.ReadUShort();
rAGSC.Seek(0x2, SEEK_CUR); rAGSC.Seek(0x2, SEEK_CUR);
for (uint32 iSfx = 0; iSfx < NumSounds; iSfx++) for (uint32 iSfx = 0; iSfx < NumSounds; iSfx++)
{ {
pOut->mDefineIDs.push_back( rAGSC.ReadShort() ); pOut->mDefineIDs.push_back(rAGSC.ReadUShort());
rAGSC.Seek(0x8, SEEK_CUR); rAGSC.Seek(0x8, SEEK_CUR);
} }
} }
@ -63,7 +63,7 @@ std::unique_ptr<CAudioGroup> CAudioGroupLoader::LoadAGSC(IInputStream& rAGSC, CR
std::unique_ptr<CAudioLookupTable> CAudioGroupLoader::LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry) std::unique_ptr<CAudioLookupTable> CAudioGroupLoader::LoadATBL(IInputStream& rATBL, CResourceEntry *pEntry)
{ {
auto pOut = std::make_unique<CAudioLookupTable>(pEntry); auto pOut = std::make_unique<CAudioLookupTable>(pEntry);
uint32 NumMacroIDs = rATBL.ReadLong(); const uint32 NumMacroIDs = rATBL.ReadULong();
for (uint32 iMacro = 0; iMacro < NumMacroIDs; iMacro++) for (uint32 iMacro = 0; iMacro < NumMacroIDs; iMacro++)
pOut->mDefineIDs.push_back( rATBL.ReadShort() ); pOut->mDefineIDs.push_back( rATBL.ReadShort() );
@ -74,11 +74,11 @@ std::unique_ptr<CAudioLookupTable> CAudioGroupLoader::LoadATBL(IInputStream& rAT
std::unique_ptr<CStringList> CAudioGroupLoader::LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry) std::unique_ptr<CStringList> CAudioGroupLoader::LoadSTLC(IInputStream& rSTLC, CResourceEntry *pEntry)
{ {
auto pOut = std::make_unique<CStringList>(pEntry); auto pOut = std::make_unique<CStringList>(pEntry);
uint32 NumStrings = rSTLC.ReadLong(); const uint32 NumStrings = rSTLC.ReadULong();
pOut->mStringList.reserve(NumStrings); pOut->mStringList.reserve(NumStrings);
for (uint32 iStr = 0; iStr < NumStrings; iStr++) for (uint32 iStr = 0; iStr < NumStrings; iStr++)
pOut->mStringList.push_back( rSTLC.ReadString() ); pOut->mStringList.push_back(rSTLC.ReadString());
return pOut; return pOut;
} }