0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-10 13:45:06 +00:00

move the client.CurrentCostume update to the PacketHandler and log the packet

(cherry picked from commit 47505dbdd5)
This commit is contained in:
Robin C. Ladiges 2022-09-03 23:10:27 +02:00
parent e14616030c
commit 272669cd2d
No known key found for this signature in database
GPG key ID: B494D3DF92661B99
2 changed files with 9 additions and 11 deletions

View file

@ -154,18 +154,23 @@ server.PacketHandler = (c, p) => {
break;
}
case TagPacket tagPacket: {
if ((tagPacket.UpdateType & TagPacket.TagUpdate.State) != 0) c.Metadata["seeking"] = tagPacket.IsIt;
if ((tagPacket.UpdateType & TagPacket.TagUpdate.Time) != 0)
c.Metadata["time"] = new Time(tagPacket.Minutes, tagPacket.Seconds, DateTime.Now);
break;
}
case CostumePacket:
case CostumePacket costumePacket:
c.Logger.Info($"Got costume packet: {costumePacket.BodyName}, {costumePacket.CapName}");
c.CurrentCostume = costumePacket;
#pragma warning disable CS4014
ClientSyncShineBag(c); //no point logging since entire def has try/catch
#pragma warning restore CS4014
c.Metadata["loadedSave"] = true;
break;
case ShinePacket shinePacket: {
if (c.Metadata["loadedSave"] is false) break;
ConcurrentBag<int> playerBag = (ConcurrentBag<int>)c.Metadata["shineSync"]!;
@ -176,6 +181,7 @@ server.PacketHandler = (c, p) => {
SyncShineBag();
break;
}
case PlayerPacket playerPacket when Settings.Instance.Flip.Enabled
&& Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Others
&& Settings.Instance.Flip.Players.Contains(c.Id): {
@ -206,7 +212,7 @@ server.PacketHandler = (c, p) => {
}
}
return true;
return true; // Broadcast packet to all other clients
};
(HashSet<string> failToFind, HashSet<Client> toActUpon, List<(string arg, IEnumerable<string> amb)> ambig) MultiUserCommandHelper(string[] args) {

View file

@ -264,14 +264,6 @@ public class Server {
throw new Exception($"Client {client.Name} sent packet with invalid client id {header.Id} instead of {client.Id}");
}
if (header.Type == PacketType.Costume) {
CostumePacket costumePacket = new CostumePacket {
BodyName = ""
};
costumePacket.Deserialize(memory.Memory.Span[Constants.HeaderSize..(Constants.HeaderSize + costumePacket.Size)]);
client.CurrentCostume = costumePacket;
}
try {
IPacket packet = (IPacket) Activator.CreateInstance(Constants.PacketIdMap[header.Type])!;
packet.Deserialize(memory.Memory.Span[Constants.HeaderSize..(Constants.HeaderSize + packet.Size)]);