fix(core): Removes implicit cast between Serial and uint (#728)

* Fixes spellbooks using serial ctor
* Fixes misc items where someone thought they had an amount and it didn't
* Fixes all `Food` types.
This commit is contained in:
Kamron Batman 2021-08-25 00:27:19 -07:00 committed by GitHub
parent 17521c9cd7
commit 0dc4acc164
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 319 additions and 248 deletions

View file

@ -15,6 +15,7 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
namespace Server
{
@ -26,40 +27,59 @@ namespace Server
public BinaryFileReader(Stream stream) => _reader = new BinaryReader(stream);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Close() => _reader.Close();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public string ReadString(bool intern = false)
{
var str = _reader.ReadString();
return intern ? Utility.Intern(str) : str;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long ReadLong() => _reader.ReadInt64();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong ReadULong() => _reader.ReadUInt64();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int ReadInt() => _reader.ReadInt32();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public uint ReadUInt() => _reader.ReadUInt32();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public short ReadShort() => _reader.ReadInt16();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ushort ReadUShort() => _reader.ReadUInt16();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double ReadDouble() => _reader.ReadDouble();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float ReadFloat() => _reader.ReadSingle();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public byte ReadByte() => _reader.ReadByte();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public sbyte ReadSByte() => _reader.ReadSByte();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool ReadBool() => _reader.ReadBoolean();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Serial ReadSerial() => (Serial)_reader.ReadUInt32();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int Read(Span<byte> buffer) => _reader.Read(buffer);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long Seek(long offset, SeekOrigin origin) => _reader.BaseStream.Seek(offset, origin);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose() => Close();
}
}