chore: Code cleanup (#399)

- [X] Code cleanup
This commit is contained in:
Kamron Batman 2021-01-10 09:14:03 -08:00 committed by GitHub
parent a6e1172f97
commit 764d303543
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 93 additions and 265 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
@ -60,7 +61,13 @@ namespace Server
fixed (LandTile* pTiles = tiles)
{
NativeReader.Read(fsData.SafeFileHandle.DangerousGetHandle(), pTiles, 192);
var ptr = fsData.SafeFileHandle?.DangerousGetHandle();
if (ptr == null)
{
throw new Exception($"Cannot open {fsData.Name}");
}
NativeReader.Read(ptr.Value, pTiles, 192);
}
matrix.SetLandBlock(x, y, tiles);
@ -123,7 +130,14 @@ namespace Server
fixed (StaticTile* pTiles = staTiles)
{
NativeReader.Read(fsData.SafeFileHandle.DangerousGetHandle(), pTiles, length);
var ptr = fsData.SafeFileHandle?.DangerousGetHandle();
if (ptr == null)
{
throw new Exception($"Cannot open {fsData.Name}");
}
NativeReader.Read(ptr.Value, pTiles, length);
StaticTile* pCur = pTiles, pEnd = pTiles + tileCount;
while (pCur < pEnd)