fix: Adds expansion specific mobile status version (#1145)
This commit is contained in:
parent
61f77df892
commit
2d95fb20a6
5 changed files with 363 additions and 324 deletions
|
|
@ -60,7 +60,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "The Second Age",
|
"Name": "The Second Age",
|
||||||
|
|
@ -123,7 +124,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Renaissance",
|
"Name": "Renaissance",
|
||||||
|
|
@ -186,7 +188,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Third Dawn",
|
"Name": "Third Dawn",
|
||||||
|
|
@ -249,7 +252,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Blackthorn's Revenge",
|
"Name": "Blackthorn's Revenge",
|
||||||
|
|
@ -312,7 +316,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 3
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Age of Shadows",
|
"Name": "Age of Shadows",
|
||||||
|
|
@ -375,7 +380,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Samurai Empire",
|
"Name": "Samurai Empire",
|
||||||
|
|
@ -438,7 +444,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Mondain's Legacy",
|
"Name": "Mondain's Legacy",
|
||||||
|
|
@ -501,7 +508,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Stygian Abyss",
|
"Name": "Stygian Abyss",
|
||||||
|
|
@ -564,7 +572,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "High Seas",
|
"Name": "High Seas",
|
||||||
|
|
@ -627,7 +636,8 @@
|
||||||
"Shadowguard": false,
|
"Shadowguard": false,
|
||||||
"TOL": false,
|
"TOL": false,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Time of Legends",
|
"Name": "Time of Legends",
|
||||||
|
|
@ -690,7 +700,8 @@
|
||||||
"Shadowguard": true,
|
"Shadowguard": true,
|
||||||
"TOL": true,
|
"TOL": true,
|
||||||
"EJ": false
|
"EJ": false
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 6
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "Endless Journey",
|
"Name": "Endless Journey",
|
||||||
|
|
@ -753,6 +764,7 @@
|
||||||
"Shadowguard": true,
|
"Shadowguard": true,
|
||||||
"TOL": true,
|
"TOL": true,
|
||||||
"EJ": true
|
"EJ": true
|
||||||
}
|
},
|
||||||
|
"MobileStatusVersion": 6
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -232,11 +232,23 @@ namespace Server.Tests.Network
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData(ProtocolChanges.Version70610)]
|
[InlineData(ProtocolChanges.Version70610, "7.0.61.0", ClientFlags.TerMur, Expansion.HS, 6)]
|
||||||
[InlineData(ProtocolChanges.Version400a)]
|
[InlineData(ProtocolChanges.Version400a, "4.0.0a", ClientFlags.Malas, Expansion.AOS, 4)]
|
||||||
[InlineData(ProtocolChanges.Version502b)]
|
[InlineData(ProtocolChanges.Version502b, "5.0.2b", ClientFlags.Malas, Expansion.ML, 5)]
|
||||||
public void TestMobileStatusExtendedSelf(ProtocolChanges changes)
|
public void TestMobileStatusExtendedSelf(
|
||||||
|
ProtocolChanges changes,
|
||||||
|
string version,
|
||||||
|
ClientFlags clientFlags,
|
||||||
|
Expansion expansion,
|
||||||
|
int mobileStatusVersion
|
||||||
|
)
|
||||||
{
|
{
|
||||||
|
var expansionInfo = ExpansionInfo.GetInfo(Core.Expansion);
|
||||||
|
var oldExpansion = Core.Expansion;
|
||||||
|
var oldVersion = expansionInfo.MobileStatusVersion;
|
||||||
|
Core.Expansion = expansion;
|
||||||
|
ExpansionInfo.GetInfo(Core.Expansion).MobileStatusVersion = mobileStatusVersion;
|
||||||
|
|
||||||
var m = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
var m = new Mobile((Serial)0x1) { Name = "Random Mobile 1" };
|
||||||
m.DefaultMobileInit();
|
m.DefaultMobileInit();
|
||||||
m.Str = 50;
|
m.Str = 50;
|
||||||
|
|
@ -248,12 +260,16 @@ namespace Server.Tests.Network
|
||||||
|
|
||||||
var ns = PacketTestUtilities.CreateTestNetState();
|
var ns = PacketTestUtilities.CreateTestNetState();
|
||||||
ns.ProtocolChanges = changes;
|
ns.ProtocolChanges = changes;
|
||||||
|
ns.Version = new ClientVersion(version);
|
||||||
|
ns.Flags = clientFlags;
|
||||||
|
|
||||||
var expected = new MobileStatusExtended(m, ns).Compile();
|
var expected = new MobileStatusExtended(m, ns).Compile();
|
||||||
ns.SendMobileStatus(m, m);
|
ns.SendMobileStatus(m, m);
|
||||||
|
|
||||||
var result = ns.SendPipe.Reader.TryRead();
|
var result = ns.SendPipe.Reader.TryRead();
|
||||||
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
|
||||||
|
Core.Expansion = oldExpansion;
|
||||||
|
expansionInfo.MobileStatusVersion = oldVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ using System.IO;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using Server.Json;
|
using Server.Json;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
{
|
|
||||||
public enum Expansion
|
public enum Expansion
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
|
@ -206,7 +206,8 @@ namespace Server
|
||||||
expansion.ClientVersion,
|
expansion.ClientVersion,
|
||||||
expansion.FeatureFlags,
|
expansion.FeatureFlags,
|
||||||
expansion.CharacterListFlags,
|
expansion.CharacterListFlags,
|
||||||
expansion.HousingFlags
|
expansion.HousingFlags,
|
||||||
|
expansion.MobileStatusVersion
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -217,7 +218,8 @@ namespace Server
|
||||||
expansion.ClientFlags ?? ClientFlags.None,
|
expansion.ClientFlags ?? ClientFlags.None,
|
||||||
expansion.FeatureFlags,
|
expansion.FeatureFlags,
|
||||||
expansion.CharacterListFlags,
|
expansion.CharacterListFlags,
|
||||||
expansion.HousingFlags
|
expansion.HousingFlags,
|
||||||
|
expansion.MobileStatusVersion
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -229,8 +231,10 @@ namespace Server
|
||||||
ClientFlags clientFlags,
|
ClientFlags clientFlags,
|
||||||
FeatureFlags supportedFeatures,
|
FeatureFlags supportedFeatures,
|
||||||
CharacterListFlags charListFlags,
|
CharacterListFlags charListFlags,
|
||||||
HousingFlags customHousingFlag
|
HousingFlags customHousingFlag,
|
||||||
) : this(id, name, supportedFeatures, charListFlags, customHousingFlag) => ClientFlags = clientFlags;
|
int mobileStatusVersion
|
||||||
|
) : this(id, name, supportedFeatures, charListFlags, customHousingFlag, mobileStatusVersion) =>
|
||||||
|
ClientFlags = clientFlags;
|
||||||
|
|
||||||
public ExpansionInfo(
|
public ExpansionInfo(
|
||||||
int id,
|
int id,
|
||||||
|
|
@ -238,15 +242,18 @@ namespace Server
|
||||||
ClientVersion requiredClient,
|
ClientVersion requiredClient,
|
||||||
FeatureFlags supportedFeatures,
|
FeatureFlags supportedFeatures,
|
||||||
CharacterListFlags charListFlags,
|
CharacterListFlags charListFlags,
|
||||||
HousingFlags customHousingFlag
|
HousingFlags customHousingFlag,
|
||||||
) : this(id, name, supportedFeatures, charListFlags, customHousingFlag) => RequiredClient = requiredClient;
|
int mobileStatusVersion
|
||||||
|
) : this(id, name, supportedFeatures, charListFlags, customHousingFlag, mobileStatusVersion) =>
|
||||||
|
RequiredClient = requiredClient;
|
||||||
|
|
||||||
private ExpansionInfo(
|
private ExpansionInfo(
|
||||||
int id,
|
int id,
|
||||||
string name,
|
string name,
|
||||||
FeatureFlags supportedFeatures,
|
FeatureFlags supportedFeatures,
|
||||||
CharacterListFlags charListFlags,
|
CharacterListFlags charListFlags,
|
||||||
HousingFlags customHousingFlag
|
HousingFlags customHousingFlag,
|
||||||
|
int mobileStatusVersion
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ID = id;
|
ID = id;
|
||||||
|
|
@ -255,6 +262,7 @@ namespace Server
|
||||||
SupportedFeatures = supportedFeatures;
|
SupportedFeatures = supportedFeatures;
|
||||||
CharacterListFlags = charListFlags;
|
CharacterListFlags = charListFlags;
|
||||||
CustomHousingFlag = customHousingFlag;
|
CustomHousingFlag = customHousingFlag;
|
||||||
|
MobileStatusVersion = mobileStatusVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ExpansionInfo CoreExpansion => GetInfo(Core.Expansion);
|
public static ExpansionInfo CoreExpansion => GetInfo(Core.Expansion);
|
||||||
|
|
@ -263,12 +271,12 @@ namespace Server
|
||||||
|
|
||||||
public int ID { get; }
|
public int ID { get; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public ClientFlags ClientFlags { get; set; }
|
public ClientFlags ClientFlags { get; set; }
|
||||||
public FeatureFlags SupportedFeatures { get; set; }
|
public FeatureFlags SupportedFeatures { get; set; }
|
||||||
public CharacterListFlags CharacterListFlags { get; set; }
|
public CharacterListFlags CharacterListFlags { get; set; }
|
||||||
public ClientVersion RequiredClient { get; set; }
|
public ClientVersion RequiredClient { get; set; }
|
||||||
public HousingFlags CustomHousingFlag { get; set; }
|
public HousingFlags CustomHousingFlag { get; set; }
|
||||||
|
public int MobileStatusVersion { get; set; }
|
||||||
|
|
||||||
public static ExpansionInfo GetInfo(Expansion ex) => GetInfo((int)ex);
|
public static ExpansionInfo GetInfo(Expansion ex) => GetInfo((int)ex);
|
||||||
|
|
||||||
|
|
@ -303,5 +311,6 @@ namespace Server
|
||||||
|
|
||||||
[JsonConverter(typeof(FlagsConverter<HousingFlags>))]
|
[JsonConverter(typeof(FlagsConverter<HousingFlags>))]
|
||||||
public HousingFlags HousingFlags { get; init; }
|
public HousingFlags HousingFlags { get; init; }
|
||||||
}
|
|
||||||
|
public int MobileStatusVersion { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,6 @@ public static class OutgoingMobilePackets
|
||||||
public const int MobileStatusMLLength = 91;
|
public const int MobileStatusMLLength = 91;
|
||||||
public const int MobileStatusHSLength = 121;
|
public const int MobileStatusHSLength = 121;
|
||||||
|
|
||||||
public static bool ExtendedStatus { get; private set; } = true;
|
|
||||||
|
|
||||||
public static void Configure()
|
|
||||||
{
|
|
||||||
ExtendedStatus = ServerConfiguration.GetSetting("client.showExtendedStatus", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void CreateBondedStatus(Span<byte> buffer, Serial serial, bool bonded)
|
public static void CreateBondedStatus(Span<byte> buffer, Serial serial, bool bonded)
|
||||||
{
|
{
|
||||||
if (buffer[0] != 0)
|
if (buffer[0] != 0)
|
||||||
|
|
@ -467,17 +460,22 @@ public static class OutgoingMobilePackets
|
||||||
version = 0;
|
version = 0;
|
||||||
length = MobileStatusCompactLength;
|
length = MobileStatusCompactLength;
|
||||||
}
|
}
|
||||||
else if (ExtendedStatus && ns.ExtendedStatus)
|
else
|
||||||
|
{
|
||||||
|
var maxVersion = ExpansionInfo.CoreExpansion.MobileStatusVersion;
|
||||||
|
var nsExpansion = (Expansion)ns.ExpansionInfo.ID;
|
||||||
|
|
||||||
|
if (maxVersion >= 6 && nsExpansion >= Expansion.HS && ns.ExtendedStatus)
|
||||||
{
|
{
|
||||||
version = 6;
|
version = 6;
|
||||||
length = MobileStatusHSLength;
|
length = MobileStatusHSLength;
|
||||||
}
|
}
|
||||||
else if (Core.ML && ns.SupportsExpansion(Expansion.ML))
|
else if (maxVersion >= 5 && nsExpansion >= Expansion.ML)
|
||||||
{
|
{
|
||||||
version = 5;
|
version = 5;
|
||||||
length = MobileStatusMLLength;
|
length = MobileStatusMLLength;
|
||||||
}
|
}
|
||||||
else if (Core.AOS)
|
else if (maxVersion >= 4 && nsExpansion >= Expansion.AOS)
|
||||||
{
|
{
|
||||||
version = 4;
|
version = 4;
|
||||||
length = MobileStatusAOSLength;
|
length = MobileStatusAOSLength;
|
||||||
|
|
@ -487,6 +485,7 @@ public static class OutgoingMobilePackets
|
||||||
version = 3;
|
version = 3;
|
||||||
length = MobileStatusLength;
|
length = MobileStatusLength;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Span<byte> buffer = stackalloc byte[length];
|
Span<byte> buffer = stackalloc byte[length];
|
||||||
CreateMobileStatus(buffer, beheld, version, beheld.CanBeRenamedBy(beholder));
|
CreateMobileStatus(buffer, beheld, version, beheld.CanBeRenamedBy(beholder));
|
||||||
|
|
@ -563,6 +562,8 @@ public static class OutgoingMobilePackets
|
||||||
|
|
||||||
if (version >= 6)
|
if (version >= 6)
|
||||||
{
|
{
|
||||||
|
// TODO: Once the new statuses are added, the length should be capped by expansion.
|
||||||
|
// This will allow newer clients to see AOS stats, but not newer ones.
|
||||||
for (var i = 0; i < 15; ++i)
|
for (var i = 0; i < 15; ++i)
|
||||||
{
|
{
|
||||||
writer.Write((short)beheld.GetAOSStatus(i));
|
writer.Write((short)beheld.GetAOSStatus(i));
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ public static class AssistantProtocol
|
||||||
{
|
{
|
||||||
private static PacketHandler[] _handlers;
|
private static PacketHandler[] _handlers;
|
||||||
|
|
||||||
|
[CallPriority(10)]
|
||||||
public static void Configure()
|
public static void Configure()
|
||||||
{
|
{
|
||||||
_handlers = ProtocolExtensions<AssistantsProtocolInfo>.Register(new AssistantsProtocolInfo());
|
_handlers = ProtocolExtensions<AssistantsProtocolInfo>.Register(new AssistantsProtocolInfo());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue