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:
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
{
|
||||
public static class WavReader
|
||||
{
|
||||
enum WaveType { Pcm = 0x1, MsAdpcm = 0x2, ImaAdpcm = 0x11 }
|
||||
enum WaveType : short { Pcm = 0x1, MsAdpcm = 0x2, ImaAdpcm = 0x11 }
|
||||
|
||||
public static bool LoadSound(Stream s, out Func<Stream> result, out short channels, out int sampleBits, out int sampleRate, out float lengthInSeconds)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
while (s.Position < s.Length)
|
||||
{
|
||||
if ((s.Position & 1) == 1)
|
||||
s.ReadByte(); // Alignment
|
||||
s.ReadUInt8(); // Alignment
|
||||
|
||||
if (s.Position == s.Length)
|
||||
break; // Break if we aligned with end of stream
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.FileSystem
|
||||
s.Position += 12;
|
||||
var chunkSize = s.ReadUInt16();
|
||||
s.Position += 4;
|
||||
var nameLength = s.ReadByte();
|
||||
var nameLength = s.ReadUInt8();
|
||||
var fileName = dirName + "\\" + s.ReadASCII(nameLength);
|
||||
|
||||
// Use index syntax to overwrite any duplicate entries with the last value
|
||||
|
||||
Reference in New Issue
Block a user