mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-23 19:55:18 +00:00
move the client.CurrentCostume update to the PacketHandler and log the packet
(cherry picked from commit 47505dbdd5
)
This commit is contained in:
parent
53442b598e
commit
472c8856bc
2 changed files with 9 additions and 11 deletions
|
@ -153,18 +153,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"]!;
|
||||
|
@ -175,6 +180,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): {
|
||||
|
@ -205,7 +211,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) {
|
||||
|
@ -666,4 +672,4 @@ if (restartRequested) //need to do this here because this needs to happen after
|
|||
}
|
||||
else
|
||||
consoleLogger.Info(unableToStartMsg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)]);
|
||||
|
|
Loading…
Reference in a new issue