Skip to content

Commit 6d132b7

Browse files
committed
Fix some warnings.
1 parent af1ad30 commit 6d132b7

File tree

15 files changed

+31
-31
lines changed

15 files changed

+31
-31
lines changed

Ultima/ASCIIFont.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static unsafe void Initialize()
8787
using (var reader = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
8888
{
8989
var buffer = new byte[(int)reader.Length];
90-
reader.Read(buffer, 0, (int)reader.Length);
90+
reader.ReadExactly(buffer, 0, (int)reader.Length);
9191
fixed (byte* bin = buffer)
9292
{
9393
byte* read = bin;

Ultima/Art.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static bool IsValidStatic(int index)
181181
}
182182

183183
stream.Seek(4, SeekOrigin.Current);
184-
stream.Read(_validBuffer, 0, 4);
184+
stream.ReadExactly(_validBuffer, 0, 4);
185185

186186
short width = (short)(_validBuffer[0] | (_validBuffer[1] << 8));
187187
short height = (short)(_validBuffer[2] | (_validBuffer[3] << 8));
@@ -272,7 +272,7 @@ public static byte[] GetRawLand(int index)
272272
}
273273

274274
var buffer = new byte[length];
275-
stream.Read(buffer, 0, length);
275+
stream.ReadExactly(buffer, 0, length);
276276
stream.Close();
277277
return buffer;
278278
}
@@ -344,7 +344,7 @@ public static byte[] GetRawStatic(int index)
344344
}
345345

346346
var buffer = new byte[length];
347-
stream.Read(buffer, 0, length);
347+
stream.ReadExactly(buffer, 0, length);
348348
stream.Close();
349349
return buffer;
350350
}
@@ -429,7 +429,7 @@ private static unsafe Bitmap LoadStatic(Stream stream, int length)
429429
_streamBuffer = new byte[length];
430430
}
431431

432-
stream.Read(_streamBuffer, 0, length);
432+
stream.ReadExactly(_streamBuffer, 0, length);
433433
stream.Close();
434434

435435
Bitmap bmp;
@@ -504,7 +504,7 @@ private static unsafe Bitmap LoadLand(Stream stream, int length)
504504
_streamBuffer = new byte[length];
505505
}
506506

507-
stream.Read(_streamBuffer, 0, length);
507+
stream.ReadExactly(_streamBuffer, 0, length);
508508
stream.Close();
509509
fixed (byte* binData = _streamBuffer)
510510
{

Ultima/Client.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static int Read(ProcessStream pc, int bytes)
9090
{
9191
var buffer = new byte[bytes];
9292

93-
pc.Read(buffer, 0, bytes);
93+
pc.ReadExactly(buffer, 0, bytes);
9494

9595
switch (bytes)
9696
{

Ultima/Gumps.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static byte[] GetRawGump(int index, out int width, out int height)
157157
_streamBuffer = new byte[entry.Length];
158158
}
159159

160-
stream.Read(_streamBuffer, 0, entry.Length);
160+
stream.ReadExactly(_streamBuffer, 0, entry.Length);
161161

162162
var result = UopUtils.Decompress(_streamBuffer);
163163
if (result.success is false)
@@ -272,7 +272,7 @@ public static unsafe Bitmap GetGump(int index, Hue hue, bool onlyHueGrayPixels,
272272
_colorTable = colorTable = new byte[128];
273273
}
274274

275-
stream.Read(streamBuffer, 0, length);
275+
stream.ReadExactly(streamBuffer, 0, length);
276276

277277
fixed (ushort* psHueColors = hue.Colors)
278278
{
@@ -445,7 +445,7 @@ public static unsafe Bitmap GetGump(int index, out bool patched)
445445
_streamBuffer = new byte[length];
446446
}
447447

448-
stream.Read(_streamBuffer, 0, length);
448+
stream.ReadExactly(_streamBuffer, 0, length);
449449

450450
uint width = (uint)entry.Extra1;
451451
uint height = (uint)entry.Extra2;

Ultima/Hues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void Initialize()
4747
GCHandle gc = GCHandle.Alloc(buffer, GCHandleType.Pinned);
4848
try
4949
{
50-
fs.Read(buffer, 0, buffer.Length);
50+
fs.ReadExactly(buffer, 0, buffer.Length);
5151
long currentPos = 0;
5252

5353
for (int i = 0; i < blockCount; ++i)

Ultima/RadarCol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void Initialize()
4444
Colors = new ushort[fs.Length / 2];
4545
GCHandle gc = GCHandle.Alloc(Colors, GCHandleType.Pinned);
4646
var buffer = new byte[(int)fs.Length];
47-
fs.Read(buffer, 0, (int)fs.Length);
47+
fs.ReadExactly(buffer, 0, (int)fs.Length);
4848
Marshal.Copy(buffer, 0, gc.AddrOfPinnedObject(), (int)fs.Length);
4949
gc.Free();
5050
}

Ultima/Sound.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ public static UoSound GetSound(int soundId, out bool translated)
130130
var stringBuffer = new byte[32];
131131
var buffer = new byte[length];
132132

133-
stream.Read(stringBuffer, 0, 32);
134-
stream.Read(buffer, 0, length);
133+
stream.ReadExactly(stringBuffer, 0, 32);
134+
stream.ReadExactly(buffer, 0, length);
135135
stream.Close();
136136

137137
var resultBuffer = new byte[buffer.Length + (waveHeader.Length << 2)];
@@ -233,7 +233,7 @@ public static bool IsValidSound(int soundId, out string name, out bool translate
233233
}
234234

235235
var stringBuffer = new byte[32];
236-
stream.Read(stringBuffer, 0, 32);
236+
stream.ReadExactly(stringBuffer, 0, 32);
237237
stream.Close();
238238
name = Encoding.ASCII.GetString(stringBuffer); // seems that the null terminator's not being properly recognized :/
239239
if (name.IndexOf('\0') > 0)
@@ -303,7 +303,7 @@ public static void Add(int id, string name, string file)
303303
{
304304
byte[] resultBuffer = new byte[wav.Length];
305305
wav.Seek(0, SeekOrigin.Begin);
306-
wav.Read(resultBuffer, 0, (int)wav.Length);
306+
wav.ReadExactly(resultBuffer, 0, (int)wav.Length);
307307

308308
resultBuffer = CheckAndFixWave(resultBuffer);
309309

@@ -376,7 +376,7 @@ public static void Save(string path)
376376
{
377377
m.Seek(headerLength, SeekOrigin.Begin);
378378
var resultBuffer = new byte[m.Length - headerLength];
379-
m.Read(resultBuffer, 0, (int)m.Length - headerLength);
379+
m.ReadExactly(resultBuffer, 0, (int)m.Length - headerLength);
380380
binmul.Write(resultBuffer);
381381
}
382382

Ultima/Textures.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public static unsafe Bitmap GetTexture(int index, out bool patched)
140140

141141
byte[] streamBuffer = new byte[max];
142142

143-
stream.Read(streamBuffer, 0, max);
143+
stream.ReadExactly(streamBuffer, 0, max);
144144

145145
fixed (byte* data = streamBuffer)
146146
{

Ultima/TileData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ public static unsafe void Initialize()
13211321
long currentPos = 0;
13221322
try
13231323
{
1324-
fs.Read(buffer, 0, buffer.Length);
1324+
fs.ReadExactly(buffer, 0, buffer.Length);
13251325
for (int i = 0; i < 0x4000; i += 32)
13261326
{
13271327
var ptrHeader = new IntPtr(gc.AddrOfPinnedObject() + currentPos);

Ultima/TileMatrix.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ private void InitStatics()
241241

242242
GCHandle gc = GCHandle.Alloc(_staticIndex, GCHandleType.Pinned);
243243
var buffer = new byte[index.Length];
244-
index.Read(buffer, 0, (int)index.Length);
244+
index.ReadExactly(buffer, 0, (int)index.Length);
245245
Marshal.Copy(buffer, 0, gc.AddrOfPinnedObject(), (int)Math.Min(index.Length, BlockHeight * BlockWidth * 12));
246246
gc.Free();
247247
for (var i = (int)Math.Min(index.Length, BlockHeight * BlockWidth); i < BlockHeight * BlockWidth; ++i)
@@ -297,7 +297,7 @@ private unsafe HuedTile[][][] ReadStaticBlock(int x, int y)
297297
GCHandle gc = GCHandle.Alloc(_buffer, GCHandleType.Pinned);
298298
try
299299
{
300-
_statics.Read(_buffer, 0, length);
300+
_statics.ReadExactly(_buffer, 0, length);
301301

302302
if (_lists == null)
303303
{
@@ -496,7 +496,7 @@ private Tile[] ReadLandBlock(int x, int y)
496496
_buffer = new byte[192];
497497
}
498498

499-
_map.Read(_buffer, 0, 192);
499+
_map.ReadExactly(_buffer, 0, 192);
500500

501501
Marshal.Copy(_buffer, 0, gc.AddrOfPinnedObject(), 192);
502502
}

0 commit comments

Comments
 (0)