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

@ -17,6 +17,7 @@ using System;
using System.Buffers.Binary;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using Server.Text;
@ -62,6 +63,7 @@ namespace Server
return intern ? Utility.Intern(str) : str;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public long ReadLong()
{
var v = BinaryPrimitives.ReadInt64LittleEndian(_buffer.AsSpan(_position, 8));
@ -69,6 +71,7 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ulong ReadULong()
{
var v = BinaryPrimitives.ReadUInt64LittleEndian(_buffer.AsSpan(_position, 8));
@ -76,6 +79,7 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int ReadInt()
{
var v = BinaryPrimitives.ReadInt32LittleEndian(_buffer.AsSpan(_position, 4));
@ -83,6 +87,7 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public uint ReadUInt()
{
var v = BinaryPrimitives.ReadUInt32LittleEndian(_buffer.AsSpan(_position, 4));
@ -90,6 +95,7 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public short ReadShort()
{
var v = BinaryPrimitives.ReadInt16LittleEndian(_buffer.AsSpan(_position, 2));
@ -97,6 +103,7 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ushort ReadUShort()
{
var v = BinaryPrimitives.ReadUInt16LittleEndian(_buffer.AsSpan(_position, 2));
@ -104,6 +111,7 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public double ReadDouble()
{
var v = BinaryPrimitives.ReadDoubleLittleEndian(_buffer.AsSpan(_position, 8));
@ -111,6 +119,7 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public float ReadFloat()
{
var v = BinaryPrimitives.ReadSingleLittleEndian(_buffer.AsSpan(_position, 4));
@ -118,12 +127,18 @@ namespace Server
return v;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public byte ReadByte() => _buffer[_position++];
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public sbyte ReadSByte() => (sbyte)_buffer[_position++];
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool ReadBool() => _buffer[_position++] != 0;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Serial ReadSerial() => (Serial)ReadUInt();
public int Read(Span<byte> buffer)
{
var length = buffer.Length;