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:
Kamron Batman 2023-09-18 23:53:18 -07:00 • committed by GitHub
parent cee4d0fb15
commit 0bec97639f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 284 additions and 103 deletions

View file

@ -24,8 +24,15 @@ namespace Server.Engines.Help
AddBackground(0, 0, 92, 75, 0xA3C);
AddImageTiled(5, 7, 82, 61, 0xA40);
AddAlphaRegion(5, 7, 82, 61);
if (mobile?.NetState?.IsEnhancedClient == true)
{
AddBackground(5, 7, 82, 61, 9300);
}
else
{
AddImageTiled(5, 7, 82, 61, 0xA40);
AddAlphaRegion(5, 7, 82, 61);
}
AddImageTiled(9, 11, 21, 53, 0xBBC);
@ -230,8 +237,15 @@ namespace Server.Engines.Help
if (response == null)
{
AddImageTiled(0, 0, 410, 448, 0xA40);
AddAlphaRegion(1, 1, 408, 446);
if (from.NetState?.IsEnhancedClient == true)
{
AddBackground(1, 1, 408, 446, 9300);
}
else
{
AddImageTiled(0, 0, 410, 448, 0xA40);
AddAlphaRegion(1, 1, 408, 446);
}
AddHtml(10, 10, 390, 20, Color(Center("Predefined Responses"), LabelColor32));
@ -300,7 +314,15 @@ namespace Server.Engines.Help
else if (canEdit)
{
AddImageTiled(0, 0, 410, 250, 0xA40);
AddAlphaRegion(1, 1, 408, 248);
if (from.NetState?.IsEnhancedClient == true)
{
AddBackground(1, 1, 408, 248, 9300);
}
else
{
AddAlphaRegion(1, 1, 408, 248);
}
AddHtml(10, 10, 390, 20, Color(Center("Predefined Response Editor"), LabelColor32));
@ -472,8 +494,15 @@ namespace Server.Engines.Help
AddPage(0);
AddImageTiled(0, 0, 410, 456, 0xA40);
AddAlphaRegion(1, 1, 408, 454);
if (m.NetState?.IsEnhancedClient == true)
{
AddBackground(1, 1, 408, 454, 9300);
}
else
{
AddImageTiled(0, 0, 410, 456, 0xA40);
AddAlphaRegion(1, 1, 408, 454);
}
AddPage(1);

View file

@ -44,7 +44,7 @@ namespace Server.Gumps
36 + line++ * 20,
200,
20,
Color(state.Version?.SourceString ?? "(null)", LabelColor32)
Color(state.Version?.ToString().DefaultIfNullOrEmpty("(null)"), LabelColor32)
);
AddHtml(14, 36 + line * 20, 200, 20, Color("Assistant:", LabelColor32));

View file

@ -242,7 +242,7 @@ namespace Server.Engines.Mahjong
int number = reader.ReadByte();
if (number < 0 || number >= game.Tiles.Length)
if (number >= game.Tiles.Length)
{
return;
}

View file

@ -99,7 +99,8 @@ public partial class Moongate : Item
else if (m.Kills >= 5 && TargetMap != Map.Felucca ||
TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0 ||
TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0 ||
TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0)
TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0 ||
TargetMap == Map.TerMur && (flags & ClientFlags.TerMur) == 0)
{
m.SendLocalizedMessage(1019004); // You are not allowed to travel there.
}

View file

@ -1,4 +1,5 @@
using System;
using System.Numerics;
using Server.Gumps;
using Server.Logging;
using Server.Mobiles;
@ -17,12 +18,17 @@ namespace Server.Misc
private static TimeSpan _ageLeniency;
private static TimeSpan _gameTimeLeniency;
private static string _allowedClientsMessage;
public static ClientType AllowedClientTypes { get; private set; }
public static bool AllowClassic => (AllowedClientTypes & ClientType.Classic) != 0;
public static bool AllowUOTD => (AllowedClientTypes & ClientType.UOTD) != 0;
public static bool AllowKR => (AllowedClientTypes & ClientType.KR) != 0;
public static bool AllowSA => (AllowedClientTypes & ClientType.SA) != 0;
public static ClientVersion MinRequired { get; private set; }
public static ClientVersion MaxRequired { get; private set; }
public static bool AllowRegular => true;
public static bool AllowUOTD => false;
public static TimeSpan KickDelay { get; private set; }
public static void Configure()
@ -39,6 +45,8 @@ namespace Server.Misc
TimeSpan.FromHours(25)
);
KickDelay = ServerConfiguration.GetOrUpdateSetting("clientVerification.kickDelay", TimeSpan.FromSeconds(20.0));
AllowedClientTypes = ServerConfiguration.GetSetting("clientVerification.allowedClientTypes", ClientType.Classic | ClientType.SA);
_allowedClientsMessage = GetAllowedClientsString(AllowedClientTypes);
}
public static void Initialize()
@ -81,6 +89,34 @@ namespace Server.Misc
return _versionExpression;
}
private static string GetAllowedClientsString(ClientType allowedClients)
{
// Get total number of allowed clients
var totalAllowedClients = BitOperations.PopCount((uint)allowedClients) - 1;
if (totalAllowedClients == 0)
{
return "There are no clients supported at this time.";
}
using var builder = ValueStringBuilder.Create();
builder.Append("Please connect with a ");
uint flags = 0;
var i = 0;
while (flags < (uint)allowedClients)
{
flags = 1u << i;
if (i > 0)
{
builder.Append(i == totalAllowedClients ? " or " : ", ");
}
builder.Append(((ClientType)flags).TypeName());
i++;
}
return builder.ToString();
}
private static void EventSink_ClientVersionReceived(NetState state, ClientVersion version)
{
var sb = ValueStringBuilder.Create();
@ -97,22 +133,23 @@ namespace Server.Misc
mobile.GameTime > _gameTimeLeniency;
bool shouldKick = false;
bool isKRClient = version.Type == ClientType.KR;
if (MinRequired != null && version < MinRequired)
if (!isKRClient && MinRequired != null && version < MinRequired)
{
sb.Append($"This server doesn't support clients older than {MinRequired}.");
shouldKick = strictRequirement;
}
else if (MaxRequired != null && version > MaxRequired)
else if (!isKRClient && MaxRequired != null && version > MaxRequired)
{
sb.Append($"This server doesn't support clients newer than {MaxRequired}.");
shouldKick = strictRequirement;
}
else if (!AllowRegular || !AllowUOTD)
else
{
if (!AllowRegular && version.Type == ClientType.Regular)
if (!AllowClassic && version.Type == ClientType.Classic)
{
sb.Append("This server does not allow regular clients to connect.");
sb.Append("This server does not allow classic clients to connect.");
shouldKick = true;
}
else if (!AllowUOTD && state.IsUOTDClient)
@ -120,21 +157,20 @@ namespace Server.Misc
sb.Append("This server does not allow UO:TD clients to connect.");
shouldKick = true;
}
else if (!AllowKR && version.Type == ClientType.KR)
{
sb.Append("This server does not allow UO:KR clients to connect.");
shouldKick = true;
}
else if (!AllowSA && version.Type == ClientType.SA)
{
sb.Append("This server does not allow UO:SA clients to connect.");
shouldKick = true;
}
if (sb.Length > 0)
{
if (AllowRegular && AllowUOTD)
{
sb.Append(" You can use regular or UO:TD clients.");
}
else if (AllowRegular)
{
sb.Append(" You can use regular clients.");
}
else if (AllowUOTD)
{
sb.Append(" You can use UO:TD clients.");
}
sb.Append(_allowedClientsMessage);
}
}

View file

@ -455,8 +455,6 @@ namespace Server.Spells
}
}
private static ClientVersion _insufficientManaClientChange = new ClientVersion("7.0.65.4");
public bool Cast()
{
StartCastTime = Core.TickCount;
@ -577,7 +575,7 @@ namespace Server.Spells
return true;
}
}
else if (Caster.NetState?.Version >= _insufficientManaClientChange)
else if (Caster.NetState?.IsKRClient != true && Caster.NetState?.Version >= ClientVersion.Version70654)
{
// Insufficient mana. You must have at least ~1_MANA_REQUIREMENT~ Mana to use this spell.
Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625, requiredMana.ToString());