feat: Adds KR/EC client versions (No actual support yet). (#1506)
### Summary - Adds KR/EC client versions to ClientVersion - Adds distinction for enhanced versions in the page queue - Adds KR Expansion flags - Adds ProtocolChange enum support - Adds missing Moongate checks for TerMur - Adds better message for why a client version is not supported, and which ones are supported.
This commit is contained in:
parent
cee4d0fb15
commit
0bec97639f
13 changed files with 284 additions and 103 deletions
28
Projects/Server/Client/ClientType.cs
Normal file
28
Projects/Server/Client/ClientType.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2023 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: ClientType.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server;
|
||||
|
||||
[Flags]
|
||||
public enum ClientType
|
||||
{
|
||||
None = 0x00,
|
||||
Classic = 0x01,
|
||||
UOTD = 0x02,
|
||||
KR = 0x04,
|
||||
SA = 0x08
|
||||
}
|
||||
|
|
@ -16,29 +16,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.Network;
|
||||
using Server.Text;
|
||||
|
||||
namespace Server;
|
||||
|
||||
public enum ClientType
|
||||
{
|
||||
Regular,
|
||||
UOTD,
|
||||
God,
|
||||
SA
|
||||
}
|
||||
|
||||
public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion>
|
||||
public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion>, IEquatable<ClientVersion>
|
||||
{
|
||||
public static readonly ClientVersion Version400a = new("4.0.0a");
|
||||
public static readonly ClientVersion Version407a = new("4.0.7a");
|
||||
public static readonly ClientVersion Version500a = new("5.0.0a");
|
||||
public static readonly ClientVersion Version502b = new("5.0.2b");
|
||||
public static readonly ClientVersion Version6000 = new("6.0.0.0"); // Map & Static diffs are no longer loaded
|
||||
public static readonly ClientVersion Version6000 = new("6.0.0.0");
|
||||
public static readonly ClientVersion Version6000KR = new("66.55.38"); // KR 2.44.0.15 (First release)
|
||||
public static readonly ClientVersion Version6017 = new("6.0.1.7");
|
||||
public static readonly ClientVersion Version60142 = new("6.0.14.2");
|
||||
public static readonly ClientVersion Version60142KR = new("66.55.53"); // KR 2.59.0.2
|
||||
public static readonly ClientVersion Version7000 = new("7.0.0.0");
|
||||
public static readonly ClientVersion Version7090 = new("7.0.9.0"); // HS File format change
|
||||
public static readonly ClientVersion Version7090 = new("7.0.9.0");
|
||||
public static readonly ClientVersion Version70120 = new("7.0.12.0"); // Plant localization change
|
||||
public static readonly ClientVersion Version70130 = new("7.0.13.0");
|
||||
public static readonly ClientVersion Version70160 = new("7.0.16.0");
|
||||
|
|
@ -47,14 +42,24 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
public static readonly ClientVersion Version704565 = new("7.0.45.65");
|
||||
public static readonly ClientVersion Version70500 = new("7.0.50.0");
|
||||
public static readonly ClientVersion Version70610 = new("7.0.61.0");
|
||||
public static readonly ClientVersion Version70654 = new("7.0.65.4"); // Insufficient mana change
|
||||
|
||||
public ClientVersion(int maj, int min, int rev, int pat, ClientType type = ClientType.Regular)
|
||||
public ClientVersion(int maj, int min, int rev, int pat, ClientType type = ClientType.Classic)
|
||||
{
|
||||
Major = maj;
|
||||
if (maj >= 67)
|
||||
{
|
||||
Major = maj - 60;
|
||||
Type = ClientType.SA;
|
||||
}
|
||||
else
|
||||
{
|
||||
Major = maj;
|
||||
Type = maj == 66 ? ClientType.KR : type;
|
||||
}
|
||||
|
||||
Minor = min;
|
||||
Revision = rev;
|
||||
Patch = pat;
|
||||
Type = type;
|
||||
|
||||
SourceString = ToStringImpl().Intern();
|
||||
}
|
||||
|
|
@ -62,7 +67,7 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
public ClientVersion(string fmt)
|
||||
{
|
||||
fmt = fmt.ToLower();
|
||||
SourceString = Utility.Intern(fmt);
|
||||
SourceString = fmt.Intern();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -94,9 +99,14 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
}
|
||||
}
|
||||
|
||||
if (fmt.InsensitiveContains("god") || fmt.InsensitiveContains("gq"))
|
||||
if (Major == 66)
|
||||
{
|
||||
Type = ClientType.God;
|
||||
Type = ClientType.KR;
|
||||
}
|
||||
else if (Major > 66)
|
||||
{
|
||||
Major -= 60;
|
||||
Type = ClientType.SA;
|
||||
}
|
||||
else if (fmt.InsensitiveContains("third dawn") ||
|
||||
fmt.InsensitiveContains("uo:td") ||
|
||||
|
|
@ -106,10 +116,6 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
{
|
||||
Type = ClientType.UOTD;
|
||||
}
|
||||
else
|
||||
{
|
||||
Type = ClientType.Regular;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -117,7 +123,7 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
Minor = 0;
|
||||
Revision = 0;
|
||||
Patch = 0;
|
||||
Type = ClientType.Regular;
|
||||
Type = ClientType.Classic;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +176,12 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
return -1;
|
||||
}
|
||||
|
||||
// Don't test patch for EC since it is always 0 but compatible with classic non-zero
|
||||
if (Type == ClientType.SA || o.Type == ClientType.SA)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Patch > o.Patch)
|
||||
{
|
||||
return 1;
|
||||
|
|
@ -185,10 +197,6 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
|
||||
int IComparer<ClientVersion>.Compare(ClientVersion x, ClientVersion y) => Compare(x, y);
|
||||
|
||||
public static bool operator ==(ClientVersion l, ClientVersion r) => Compare(l, r) == 0;
|
||||
|
||||
public static bool operator !=(ClientVersion l, ClientVersion r) => Compare(l, r) != 0;
|
||||
|
||||
public static bool operator >=(ClientVersion l, ClientVersion r) => Compare(l, r) >= 0;
|
||||
|
||||
public static bool operator >(ClientVersion l, ClientVersion r) => Compare(l, r) > 0;
|
||||
|
|
@ -197,25 +205,19 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
|
||||
public static bool operator <(ClientVersion l, ClientVersion r) => Compare(l, r) < 0;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override int GetHashCode() => HashCode.Combine(Major, Minor, Revision, Patch, Type);
|
||||
public static bool operator ==(ClientVersion l, ClientVersion r) => Equals(l, r);
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var v = obj as ClientVersion;
|
||||
|
||||
return Major == v?.Major
|
||||
&& Minor == v.Minor
|
||||
&& Revision == v.Revision
|
||||
&& Patch == v.Patch
|
||||
&& Type == v.Type;
|
||||
}
|
||||
public static bool operator !=(ClientVersion l, ClientVersion r) => !Equals(l, r);
|
||||
|
||||
private string ToStringImpl()
|
||||
{
|
||||
using var builder = ValueStringBuilder.Create();
|
||||
|
||||
if (Major > 5 || Minor > 0 || Revision > 6)
|
||||
if (Type == ClientType.SA)
|
||||
{
|
||||
builder.Append($"{Major + 60:00}.{Minor:00}.{Revision:00}");
|
||||
}
|
||||
else if (Major > 5 || Minor > 0 || Revision > 6)
|
||||
{
|
||||
builder.Append($"{Major}.{Minor}.{Revision}.{Patch}");
|
||||
}
|
||||
|
|
@ -259,4 +261,41 @@ public class ClientVersion : IComparable<ClientVersion>, IComparer<ClientVersion
|
|||
|
||||
return a.CompareTo(b);
|
||||
}
|
||||
|
||||
public ProtocolChanges ProtocolChanges
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this switch
|
||||
{
|
||||
var v when v.Type is ClientType.KR && v >= Version60142KR => ProtocolChanges.Version60142,
|
||||
var v when v.Type is ClientType.KR => ProtocolChanges.Version6000,
|
||||
var v when v >= Version70610 => ProtocolChanges.Version70610,
|
||||
var v when v >= Version70500 => ProtocolChanges.Version70500,
|
||||
var v when v >= Version704565 => ProtocolChanges.Version704565,
|
||||
var v when v >= Version70331 => ProtocolChanges.Version70331,
|
||||
var v when v >= Version70300 => ProtocolChanges.Version70300,
|
||||
var v when v >= Version70160 => ProtocolChanges.Version70160,
|
||||
var v when v >= Version70130 => ProtocolChanges.Version70130,
|
||||
var v when v >= Version7090 => ProtocolChanges.Version7090,
|
||||
var v when v >= Version7000 => ProtocolChanges.Version7000,
|
||||
var v when v >= Version60142 => ProtocolChanges.Version60142,
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
public bool Equals(ClientVersion other) =>
|
||||
!ReferenceEquals(null, other) && (ReferenceEquals(this, other) || Major == other.Major &&
|
||||
Minor == other.Minor && Revision == other.Revision && Patch == other.Patch && Type == other.Type);
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
!ReferenceEquals(null, obj) &&
|
||||
(ReferenceEquals(this, obj) || obj.GetType() == GetType() && Equals((ClientVersion)obj));
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(Major, Minor, Revision, Patch);
|
||||
}
|
||||
|
|
|
|||
31
Projects/Server/Client/ClientVersionExtensions.cs
Normal file
31
Projects/Server/Client/ClientVersionExtensions.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2023 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: ClientVersionExtensions.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Server;
|
||||
|
||||
public static class ClientVersionExtensions
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string TypeName(this ClientType type) =>
|
||||
type switch
|
||||
{
|
||||
ClientType.UOTD => "UO:TD",
|
||||
ClientType.KR => "UO:KR",
|
||||
ClientType.SA => "UO:SA",
|
||||
_ => "classic",
|
||||
};
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ public static class Effects
|
|||
|
||||
public static bool SendParticlesTo(NetState state) =>
|
||||
ParticleSupportType == ParticleSupportType.Full ||
|
||||
ParticleSupportType == ParticleSupportType.Detect && state.IsUOTDClient;
|
||||
ParticleSupportType == ParticleSupportType.Detect && (state.IsUOTDClient || state.IsEnhancedClient);
|
||||
|
||||
public static void PlaySound(IEntity e, int soundID) => PlaySound(e.Location, e.Map, soundID);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public enum ClientFlags
|
|||
Malas = 0x00000008,
|
||||
Tokuno = 0x00000010,
|
||||
TerMur = 0x00000020,
|
||||
Unk1 = 0x00000040,
|
||||
KR = 0x00000040,
|
||||
Unk2 = 0x00000080,
|
||||
UOTD = 0x00000100
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ public enum CharacterListFlags
|
|||
SixthCharacterSlot = 0x00000040,
|
||||
SE = 0x00000080,
|
||||
ML = 0x00000100,
|
||||
Unk2 = 0x00000200,
|
||||
KR = 0x00000200,
|
||||
UO3DClientType = 0x00000400,
|
||||
Unk3 = 0x00000800,
|
||||
SeventhCharacterSlot = 0x00001000,
|
||||
|
|
|
|||
|
|
@ -28,32 +28,9 @@ public partial class NetState
|
|||
public ClientVersion Version
|
||||
{
|
||||
get => _version;
|
||||
set => ProtocolChanges = ProtocolChangesByVersion(_version = value);
|
||||
set => ProtocolChanges = (_version = value)?.ProtocolChanges ?? ProtocolChanges.None;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ProtocolChanges ProtocolChangesByVersion(ClientVersion version) =>
|
||||
version switch
|
||||
{
|
||||
var v when v >= ClientVersion.Version70610 => ProtocolChanges.Version70610,
|
||||
var v when v >= ClientVersion.Version70500 => ProtocolChanges.Version70500,
|
||||
var v when v >= ClientVersion.Version704565 => ProtocolChanges.Version704565,
|
||||
var v when v >= ClientVersion.Version70331 => ProtocolChanges.Version70331,
|
||||
var v when v >= ClientVersion.Version70300 => ProtocolChanges.Version70300,
|
||||
var v when v >= ClientVersion.Version70160 => ProtocolChanges.Version70160,
|
||||
var v when v >= ClientVersion.Version70130 => ProtocolChanges.Version70130,
|
||||
var v when v >= ClientVersion.Version7090 => ProtocolChanges.Version7090,
|
||||
var v when v >= ClientVersion.Version7000 => ProtocolChanges.Version7000,
|
||||
var v when v >= ClientVersion.Version60142 => ProtocolChanges.Version60142,
|
||||
var v when v >= ClientVersion.Version6017 => ProtocolChanges.Version6017,
|
||||
var v when v >= ClientVersion.Version6000 => ProtocolChanges.Version6000,
|
||||
var v when v >= ClientVersion.Version502b => ProtocolChanges.Version502b,
|
||||
var v when v >= ClientVersion.Version500a => ProtocolChanges.Version500a,
|
||||
var v when v >= ClientVersion.Version407a => ProtocolChanges.Version407a,
|
||||
var v when v >= ClientVersion.Version400a => ProtocolChanges.Version400a,
|
||||
_ => ProtocolChanges.None
|
||||
};
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool HasProtocolChanges(ProtocolChanges changes) => (ProtocolChanges & changes) != 0;
|
||||
|
||||
|
|
@ -72,10 +49,10 @@ public partial class NetState
|
|||
public bool NewMobileIncoming => HasProtocolChanges(ProtocolChanges.NewMobileIncoming);
|
||||
public bool NewSecureTrading => HasProtocolChanges(ProtocolChanges.NewSecureTrading);
|
||||
|
||||
public bool IsUOTDClient =>
|
||||
(Flags & ClientFlags.UOTD) != 0 || _version?.Type == ClientType.UOTD;
|
||||
|
||||
public bool IsUOTDClient => HasFlag(ClientFlags.UOTD) || _version?.Type == ClientType.UOTD;
|
||||
public bool IsKRClient => _version?.Type == ClientType.KR;
|
||||
public bool IsSAClient => _version?.Type == ClientType.SA;
|
||||
public bool IsEnhancedClient => _version?.Type is ClientType.KR or ClientType.SA;
|
||||
|
||||
private ExpansionInfo m_Expansion;
|
||||
|
||||
|
|
@ -89,7 +66,14 @@ public partial class NetState
|
|||
{
|
||||
var info = ExpansionInfo.Table[i];
|
||||
|
||||
if (info.RequiredClient != null && Version >= info.RequiredClient || (Flags & info.ClientFlags) != 0)
|
||||
// KR sends same client flags as EC
|
||||
if (IsKRClient && (info.ClientFlags & ClientFlags.TerMur) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((info.RequiredClient == null || !IsKRClient) &&
|
||||
Version >= info.RequiredClient || HasFlag(info.ClientFlags))
|
||||
{
|
||||
m_Expansion = info;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue