mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
Simplify Message07JoinedGameS2CPre20220202
This commit is contained in:
3 files changed
+9
-49
No files matched your search
@@ -4,7 +4,7 @@ namespace Impostor.Api.Net.Messages.S2C
|
||||
{
|
||||
public static class Message07JoinedGameS2C
|
||||
{
|
||||
public static void Serialize(IMessageWriter writer, bool clear, int gameCode, int playerId, int hostId, IClientPlayer[] otherPlayers)
|
||||
public static void Serialize(IMessageWriter writer, bool clear, int gameCode, int playerId, int hostId, IClientPlayer[] otherPlayers, bool post20220202 = true)
|
||||
{
|
||||
if (clear)
|
||||
{
|
||||
@@ -24,9 +24,12 @@ namespace Impostor.Api.Net.Messages.S2C
|
||||
ply.Client.PlatformSpecificData.Serialize(writer);
|
||||
writer.WritePacked(ply.Character?.PlayerInfo.PlayerLevel ?? 1);
|
||||
|
||||
// ProductUserId and FriendCode are not yet known, so set them to an empty string
|
||||
writer.Write(string.Empty);
|
||||
writer.Write(string.Empty);
|
||||
if (post20220202)
|
||||
{
|
||||
// ProductUserId and FriendCode are not yet known, so set them to an empty string
|
||||
writer.Write(string.Empty);
|
||||
writer.Write(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
writer.EndMessage();
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,15 +83,8 @@ namespace Impostor.Server.Net.State
|
||||
.Select(x => x.Value)
|
||||
.ToArray();
|
||||
|
||||
// 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);
|
||||
}
|
||||
// TODO: clean up post20220202 when versions before it are no longer supported.
|
||||
Message07JoinedGameS2C.Serialize(message, clear, Code, player.Client.Id, HostId, players, player.Client.GameVersion >= GameVersion.GetVersion(2022, 2, 2));
|
||||
}
|
||||
|
||||
private void WriteAlterGameMessage(IMessageWriter message, bool clear, bool isPublic)
|
||||
|
||||
Reference in new issue
Block a user