fix: Removes support for v4 Client and old gump packet. (#1739)
### Summary * Removes old gump packet support * Removes support for v4 clients * Removes `Unpack` flag and assumes it is always true. * Removes StringToBuffer since this is built into .NET now. > [!Note] > View the file changes with white space off: https://github.com/modernuo/ModernUO/pull/1739/files?diff=split&w=1
This commit is contained in:
parent
98d31bc707
commit
9cd84ba3d6
14 changed files with 1015 additions and 1191 deletions
|
|
@ -282,10 +282,7 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
var v when v >= Version6017 => ProtocolChanges.Version6017,
|
||||
var v when v >= Version6000 => ProtocolChanges.Version6000,
|
||||
var v when v >= Version502b => ProtocolChanges.Version502b,
|
||||
var v when v >= Version500a => ProtocolChanges.Version500a,
|
||||
var v when v >= Version407a => ProtocolChanges.Version407a,
|
||||
var v when v >= Version400a => ProtocolChanges.Version400a,
|
||||
_ => ProtocolChanges.None
|
||||
_ => ProtocolChanges.Version500a, // We do not support versions lower than 5.0.0a
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Network;
|
||||
using Server.Text;
|
||||
using Server.Utilities;
|
||||
|
||||
namespace Server.Gumps;
|
||||
|
|
@ -25,10 +24,6 @@ public partial class Gump
|
|||
{
|
||||
private static Serial _nextSerial = (Serial)1;
|
||||
|
||||
public static readonly byte[] NoMove = StringToBuffer("{ nomove }");
|
||||
public static readonly byte[] NoClose = StringToBuffer("{ noclose }");
|
||||
public static readonly byte[] NoDispose = StringToBuffer("{ nodispose }");
|
||||
public static readonly byte[] NoResize = StringToBuffer("{ noresize }");
|
||||
|
||||
private int _switches;
|
||||
private int _textEntries;
|
||||
|
|
@ -289,8 +284,6 @@ public partial class Gump
|
|||
state.SendDisplayGump(this, out _switches, out _textEntries);
|
||||
}
|
||||
|
||||
public static byte[] StringToBuffer(string str) => str.GetBytesAscii();
|
||||
|
||||
public virtual void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,8 @@ namespace Server.Gumps;
|
|||
|
||||
public class GumpECHandleInput : GumpEntry
|
||||
{
|
||||
private static byte[] _layout = Gump.StringToBuffer("{ echandleinput }");
|
||||
|
||||
public override void AppendTo(ref SpanWriter writer, OrderedHashSet<string> strings, ref int entries, ref int switches)
|
||||
{
|
||||
writer.Write(_layout);
|
||||
writer.Write("{ echandleinput }"u8);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ namespace Server.Gumps;
|
|||
|
||||
public class GumpGroup : GumpEntry
|
||||
{
|
||||
private static byte[] _group1 = Gump.StringToBuffer("{ group 1 }");
|
||||
|
||||
public GumpGroup(int group) => Group = group;
|
||||
|
||||
public int Group { get; set; }
|
||||
|
|
@ -30,7 +28,7 @@ public class GumpGroup : GumpEntry
|
|||
{
|
||||
if (Group == 1)
|
||||
{
|
||||
writer.Write(_group1);
|
||||
writer.Write("{ group 1 }"u8);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ namespace Server.Gumps;
|
|||
|
||||
public class GumpPage : GumpEntry
|
||||
{
|
||||
private static byte[] _page0 = Gump.StringToBuffer("{ page 0 }");
|
||||
|
||||
public GumpPage(int page) => Page = page;
|
||||
|
||||
public int Page { get; set; }
|
||||
|
|
@ -30,7 +28,7 @@ public class GumpPage : GumpEntry
|
|||
{
|
||||
if (Page == 0)
|
||||
{
|
||||
writer.Write(_page0);
|
||||
writer.Write("{ page 0 }"u8);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ public partial class NetState
|
|||
|
||||
public bool NewSpellbook => HasProtocolChanges(ProtocolChanges.NewSpellbook);
|
||||
public bool DamagePacket => HasProtocolChanges(ProtocolChanges.DamagePacket);
|
||||
public bool Unpack => HasProtocolChanges(ProtocolChanges.Unpack);
|
||||
public bool BuffIcon => HasProtocolChanges(ProtocolChanges.BuffIcon);
|
||||
public bool NewHaven => HasProtocolChanges(ProtocolChanges.NewHaven);
|
||||
public bool ContainerGridLines => HasProtocolChanges(ProtocolChanges.ContainerGridLines);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public enum ProtocolChanges
|
|||
None = 0x00000000,
|
||||
NewSpellbook = 0x00000001,
|
||||
DamagePacket = 0x00000002,
|
||||
Unpack = 0x00000004,
|
||||
// Unpack = 0x00000004,
|
||||
BuffIcon = 0x00000008,
|
||||
NewHaven = 0x00000010,
|
||||
ContainerGridLines = 0x00000020,
|
||||
|
|
@ -38,9 +38,7 @@ public enum ProtocolChanges
|
|||
UltimaStore = 0x00004000,
|
||||
EndlessJourney = 0x00008000,
|
||||
|
||||
Version400a = NewSpellbook,
|
||||
Version407a = Version400a | DamagePacket,
|
||||
Version500a = Version407a | Unpack,
|
||||
Version500a = NewSpellbook | DamagePacket /* | Unpack*/,
|
||||
Version502b = Version500a | BuffIcon,
|
||||
Version6000 = Version502b | NewHaven,
|
||||
Version6017 = Version6000 | ContainerGridLines,
|
||||
|
|
|
|||
|
|
@ -105,28 +105,26 @@ public static class OutgoingGumpPackets
|
|||
return;
|
||||
}
|
||||
|
||||
var packed = ns.Unpack;
|
||||
|
||||
var layoutWriter = new SpanWriter(_layoutBuffer);
|
||||
|
||||
if (!gump.Draggable)
|
||||
{
|
||||
layoutWriter.Write(Gump.NoMove);
|
||||
layoutWriter.Write("{ nomove }"u8);
|
||||
}
|
||||
|
||||
if (!gump.Closable)
|
||||
{
|
||||
layoutWriter.Write(Gump.NoClose);
|
||||
layoutWriter.Write("{ noclose }"u8);
|
||||
}
|
||||
|
||||
if (!gump.Disposable)
|
||||
{
|
||||
layoutWriter.Write(Gump.NoDispose);
|
||||
layoutWriter.Write("{ nodispose }"u8);
|
||||
}
|
||||
|
||||
if (!gump.Resizable)
|
||||
{
|
||||
layoutWriter.Write(Gump.NoResize);
|
||||
layoutWriter.Write("{ noresize }"u8);
|
||||
}
|
||||
|
||||
foreach (var entry in gump.Entries)
|
||||
|
|
@ -143,20 +141,12 @@ public static class OutgoingGumpPackets
|
|||
stringsWriter.WriteBigUni(s);
|
||||
}
|
||||
|
||||
int maxLength;
|
||||
if (packed)
|
||||
{
|
||||
var worstLayoutLength = Zlib.MaxPackSize(layoutWriter.BytesWritten);
|
||||
var worstStringsLength = Zlib.MaxPackSize(stringsWriter.BytesWritten);
|
||||
maxLength = 40 + worstLayoutLength + worstStringsLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxLength = 23 + layoutWriter.BytesWritten + stringsWriter.BytesWritten;
|
||||
}
|
||||
var worstLayoutLength = Zlib.MaxPackSize(layoutWriter.BytesWritten);
|
||||
var worstStringsLength = Zlib.MaxPackSize(stringsWriter.BytesWritten);
|
||||
var maxLength = 40 + worstLayoutLength + worstStringsLength;
|
||||
|
||||
var writer = new SpanWriter(maxLength);
|
||||
writer.Write((byte)(packed ? 0xDD : 0xB0)); // Packet ID
|
||||
writer.Write((byte)0xDD); // Packet ID
|
||||
writer.Seek(2, SeekOrigin.Current);
|
||||
|
||||
writer.Write(gump.Serial);
|
||||
|
|
@ -164,22 +154,11 @@ public static class OutgoingGumpPackets
|
|||
writer.Write(gump.X);
|
||||
writer.Write(gump.Y);
|
||||
|
||||
if (packed)
|
||||
{
|
||||
layoutWriter.Write((byte)0); // Layout text terminator
|
||||
WritePacked(layoutWriter.Span, ref writer);
|
||||
layoutWriter.Write((byte)0); // Layout text terminator
|
||||
WritePacked(layoutWriter.Span, ref writer);
|
||||
|
||||
writer.Write(_stringsList.Count);
|
||||
WritePacked(stringsWriter.Span, ref writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write((ushort)layoutWriter.BytesWritten);
|
||||
writer.Write(layoutWriter.Span);
|
||||
|
||||
writer.Write((ushort)_stringsList.Count);
|
||||
writer.Write(stringsWriter.Span);
|
||||
}
|
||||
writer.Write(_stringsList.Count);
|
||||
WritePacked(stringsWriter.Span, ref writer);
|
||||
|
||||
writer.WritePacketLength();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue