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

@ -21,6 +21,6 @@ namespace Server
public EntityTypeIndex(string typeName) => TypeName = typeName;
public Serial CreateIndex(uint num) => num;
public Serial CreateIndex(uint num) => (Serial)num;
}
}

View file

@ -55,22 +55,23 @@ namespace Server
private const uint _maxItems = MaxItemSerial - ItemOffset + 1;
private static Serial _lastMobile = Serial.Zero;
private static Serial _lastItem = ItemOffset;
private static Serial _lastItem = (Serial)ItemOffset;
private static Serial _lastGuild = Serial.Zero;
public static Serial NewMobile
{
get
{
uint last = _lastMobile;
var last = _lastMobile;
var maxMobile = (Serial)MaxMobileSerial;
for (int i = 0; i < MaxMobileSerial; i++)
{
last++;
if (last > MaxMobileSerial)
if (last > maxMobile)
{
last = 1;
last = (Serial)1;
}
if (FindMobile(last) == null)
@ -88,7 +89,7 @@ namespace Server
{
get
{
uint last = _lastItem;
var last = _lastItem;
for (int i = 0; i < _maxItems; i++)
{
@ -96,7 +97,7 @@ namespace Server
if (last > MaxItemSerial)
{
last = ItemOffset;
last = (Serial)ItemOffset;
}
if (FindItem(last) == null)
@ -648,7 +649,7 @@ namespace Server
public static T ReadEntity<T>(this IGenericReader reader) where T : class, ISerializable
{
Serial serial = reader.ReadUInt();
Serial serial = reader.ReadSerial();
var typeT = typeof(T);
// Add to this list when creating new serializable types