CGameState: Silence implicit truncation warnings

Ensures boolean conditions are used where applicable.
This commit is contained in:
Lioncash 2020-04-16 19:55:59 -04:00
parent f844f2028b
commit a551dbc21d
1 changed files with 17 additions and 11 deletions

View File

@ -24,16 +24,17 @@ union BitsToDouble {
};
CWorldLayerState::CWorldLayerState(CBitStreamReader& reader, const CSaveWorld& saveWorld) {
u32 bitCount = reader.ReadEncoded(10);
const u32 bitCount = reader.ReadEncoded(10);
x10_saveLayers.reserve(bitCount);
for (u32 i = 0; i < bitCount; ++i) {
bool bit = reader.ReadEncoded(1);
if (bit)
const bool bit = reader.ReadEncoded(1) != 0;
if (bit) {
x10_saveLayers.setBit(i);
else
} else {
x10_saveLayers.unsetBit(i);
}
}
}
void CWorldLayerState::PutTo(CBitStreamWriter& writer) const {
@ -53,11 +54,14 @@ void CWorldLayerState::PutTo(CBitStreamWriter& writer) const {
}
void CWorldLayerState::InitializeWorldLayers(const std::vector<CWorldLayers::Area>& layers) {
if (x0_areaLayers.size())
if (!x0_areaLayers.empty()) {
return;
}
x0_areaLayers = layers;
if (x10_saveLayers.getBitCount() == 0)
if (x10_saveLayers.getBitCount() == 0) {
return;
}
u32 a = 0;
u32 b = 0;
@ -102,9 +106,9 @@ CGameState::GameFileStateInfo CGameState::LoadGameFileState(const u8* data) {
}
ret.x14_timestamp = stream.ReadEncoded(32);
ret.x20_hardMode = stream.ReadEncoded(1);
ret.x20_hardMode = stream.ReadEncoded(1) != 0;
stream.ReadEncoded(1);
CAssetId origMLVL = u32(stream.ReadEncoded(32));
const CAssetId origMLVL = u32(stream.ReadEncoded(32));
ret.x8_mlvlId = origMLVL;
BitsToDouble conv;
@ -139,8 +143,10 @@ CGameState::CGameState() {
x9c_transManager = std::make_shared<CWorldTransManager>();
x228_24_hardMode = false;
x228_25_initPowerupsAtFirstSpawn = true;
if (g_MemoryCardSys)
if (g_MemoryCardSys != nullptr) {
InitializeMemoryStates();
}
}
CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx(saveIdx) {
@ -153,8 +159,8 @@ CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx
}
stream.ReadEncoded(32);
x228_24_hardMode = stream.ReadEncoded(1);
x228_25_initPowerupsAtFirstSpawn = stream.ReadEncoded(1);
x228_24_hardMode = stream.ReadEncoded(1) != 0;
x228_25_initPowerupsAtFirstSpawn = stream.ReadEncoded(1) != 0;
x84_mlvlId = u32(stream.ReadEncoded(32));
MP1::CMain::EnsureWorldPakReady(x84_mlvlId);