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

@ -7,7 +7,7 @@ namespace Server.Gumps
{
public class Gump
{
private static uint m_NextSerial = 1;
private static Serial _nextSerial = (Serial)1;
public static readonly byte[] NoMove = StringToBuffer("{ nomove }");
public static readonly byte[] NoClose = StringToBuffer("{ noclose }");
@ -20,7 +20,7 @@ namespace Server.Gumps
{
do
{
Serial = m_NextSerial++;
Serial = _nextSerial++;
} while (Serial == 0); // standard client apparently doesn't send a gump response packet if serial == 0
X = x;
@ -186,7 +186,7 @@ namespace Server.Gumps
Add(new GumpTextEntryLimited(x, y, width, height, hue, entryID, initialText, size));
}
public void AddItemProperty(uint serial)
public void AddItemProperty(Serial serial)
{
Add(new GumpItemProperty(serial));
}

View file

@ -22,18 +22,18 @@ namespace Server.Gumps
{
public static readonly byte[] LayoutName = Gump.StringToBuffer("itemproperty");
public GumpItemProperty(uint serial) => Serial = serial;
public GumpItemProperty(Serial serial) => Serial = serial;
public uint Serial { get; set; }
public Serial Serial { get; set; }
public override string Compile(OrderedHashSet<string> strings) => $"{{ itemproperty {Serial} }}";
public override string Compile(OrderedHashSet<string> strings) => $"{{ itemproperty {Serial.Value} }}";
public override void AppendTo(ref SpanWriter writer, OrderedHashSet<string> strings, ref int entries, ref int switches)
{
writer.Write((ushort)0x7B20); // "{ "
writer.Write(LayoutName);
writer.WriteAscii(' ');
writer.WriteAscii(Serial.ToString());
writer.WriteAscii(Serial.Value.ToString());
writer.Write((ushort)0x207D); // " }"
}
}