Prefer ReadUInt8 over ReadByte.

The former will throw when the end of the stream is reached, rather than requiring the caller to check for -1.
This commit is contained in:
RoosterDragon
2020-10-18 11:35:21 +01:00
committed by abcdefg30
parent f5f2f58664
commit aac1bae899
10 changed files with 39 additions and 39 deletions

View File

@@ -93,8 +93,8 @@ namespace OpenRA.Mods.Cnc.FileFormats
// Audio
SampleRate = stream.ReadUInt16();
AudioChannels = stream.ReadByte();
SampleBits = stream.ReadByte();
AudioChannels = stream.ReadUInt8();
SampleBits = stream.ReadUInt8();
/*var unknown3 =*/stream.ReadUInt32();
/*var unknown4 =*/stream.ReadUInt16();
@@ -221,7 +221,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
}
// Chunks are aligned on even bytes; advance by a byte if the next one is null
if (stream.Peek() == 0) stream.ReadByte();
if (stream.Peek() == 0) stream.ReadUInt8();
}
}
@@ -300,7 +300,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
DecodeVQFR(stream);
break;
case "\0VQF":
stream.ReadByte();
stream.ReadUInt8();
DecodeVQFR(stream);
break;
case "VQFL":
@@ -313,7 +313,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
}
// Chunks are aligned on even bytes; advance by a byte if the next one is null
if (stream.Peek() == 0) stream.ReadByte();
if (stream.Peek() == 0) stream.ReadUInt8();
}
// Now that the frame data has been loaded (in the relevant private fields), decode it into CurrentFrameData.
@@ -340,7 +340,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
while (true)
{
// Chunks are aligned on even bytes; may be padded with a single null
if (s.Peek() == 0) s.ReadByte();
if (s.Peek() == 0) s.ReadUInt8();
var type = s.ReadASCII(4);
var subchunkLength = (int)int2.Swap(s.ReadUInt32());