/// </summary>
IClientPlayer? Player { get; }
+ /// <summary>
+ /// Gets the version of the game the client is using.
+ /// </summary>
+ int GameVersion { get; }
+
/// <summary>
/// Gets platform specific data of the <see cref="IClient" />.
/// </summary>
--- /dev/null
+using System;
+
+namespace Impostor.Api.Net.Messages.S2C
+{
+ public static class Message07JoinedGameS2CPre20220202
+ {
+ public static void Serialize(IMessageWriter writer, bool clear, int gameCode, int playerId, int hostId, IClientPlayer[] otherPlayers)
+ {
+ if (clear)
+ {
+ writer.Clear(MessageType.Reliable);
+ }
+
+ writer.StartMessage(MessageFlags.JoinedGame);
+ writer.Write(gameCode);
+ writer.Write(playerId);
+ writer.Write(hostId);
+ writer.WritePacked(otherPlayers.Length);
+
+ foreach (var ply in otherPlayers)
+ {
+ writer.WritePacked(ply.Client.Id);
+ writer.Write(ply.Client.Name);
+ ply.Client.PlatformSpecificData.Serialize(writer);
+ writer.WritePacked(ply.Character?.PlayerInfo.PlayerLevel ?? 1);
+ }
+
+ writer.EndMessage();
+ }
+
+ public static void Deserialize(IMessageReader reader)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
.Select(x => x.Value)
.ToArray();
- Message07JoinedGameS2C.Serialize(message, clear, Code, player.Client.Id, HostId, players);
+ // TODO: clean up Pre20220202 when versions before it are no longer supported.
+ if (player.Client.GameVersion >= GameVersion.GetVersion(2022, 2, 2))
+ {
+ Message07JoinedGameS2C.Serialize(message, clear, Code, player.Client.Id, HostId, players);
+ }
+ else
+ {
+ Message07JoinedGameS2CPre20220202.Serialize(message, clear, Code, player.Client.Id, HostId, players);
+ }
}
private void WriteAlterGameMessage(IMessageWriter message, bool clear, bool isPublic)