mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-24 20:25:18 +00:00
move the client.CurrentCostume update to the PacketHandler and log the packet
This commit is contained in:
parent
2f4cd0509a
commit
47505dbdd5
2 changed files with 9 additions and 11 deletions
|
@ -153,18 +153,23 @@ server.PacketHandler = (c, p) => {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TagPacket tagPacket: {
|
case TagPacket tagPacket: {
|
||||||
if ((tagPacket.UpdateType & TagPacket.TagUpdate.State) != 0) c.Metadata["seeking"] = tagPacket.IsIt;
|
if ((tagPacket.UpdateType & TagPacket.TagUpdate.State) != 0) c.Metadata["seeking"] = tagPacket.IsIt;
|
||||||
if ((tagPacket.UpdateType & TagPacket.TagUpdate.Time) != 0)
|
if ((tagPacket.UpdateType & TagPacket.TagUpdate.Time) != 0)
|
||||||
c.Metadata["time"] = new Time(tagPacket.Minutes, tagPacket.Seconds, DateTime.Now);
|
c.Metadata["time"] = new Time(tagPacket.Minutes, tagPacket.Seconds, DateTime.Now);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CostumePacket:
|
|
||||||
|
case CostumePacket costumePacket:
|
||||||
|
c.Logger.Info($"Got costume packet: {costumePacket.BodyName}, {costumePacket.CapName}");
|
||||||
|
c.CurrentCostume = costumePacket;
|
||||||
#pragma warning disable CS4014
|
#pragma warning disable CS4014
|
||||||
ClientSyncShineBag(c); //no point logging since entire def has try/catch
|
ClientSyncShineBag(c); //no point logging since entire def has try/catch
|
||||||
#pragma warning restore CS4014
|
#pragma warning restore CS4014
|
||||||
c.Metadata["loadedSave"] = true;
|
c.Metadata["loadedSave"] = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ShinePacket shinePacket: {
|
case ShinePacket shinePacket: {
|
||||||
if (c.Metadata["loadedSave"] is false) break;
|
if (c.Metadata["loadedSave"] is false) break;
|
||||||
ConcurrentBag<int> playerBag = (ConcurrentBag<int>)c.Metadata["shineSync"]!;
|
ConcurrentBag<int> playerBag = (ConcurrentBag<int>)c.Metadata["shineSync"]!;
|
||||||
|
@ -175,6 +180,7 @@ server.PacketHandler = (c, p) => {
|
||||||
SyncShineBag();
|
SyncShineBag();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PlayerPacket playerPacket when Settings.Instance.Flip.Enabled
|
case PlayerPacket playerPacket when Settings.Instance.Flip.Enabled
|
||||||
&& Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Others
|
&& Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Others
|
||||||
&& Settings.Instance.Flip.Players.Contains(c.Id): {
|
&& 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) {
|
(HashSet<string> failToFind, HashSet<Client> toActUpon, List<(string arg, IEnumerable<string> amb)> ambig) MultiUserCommandHelper(string[] args) {
|
||||||
|
|
|
@ -253,14 +253,6 @@ public class Server {
|
||||||
throw new Exception($"Client {client.Name} sent packet with invalid client id {header.Id} instead of {client.Id}");
|
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 {
|
try {
|
||||||
IPacket packet = (IPacket) Activator.CreateInstance(Constants.PacketIdMap[header.Type])!;
|
IPacket packet = (IPacket) Activator.CreateInstance(Constants.PacketIdMap[header.Type])!;
|
||||||
packet.Deserialize(memory.Memory.Span[Constants.HeaderSize..(Constants.HeaderSize + packet.Size)]);
|
packet.Deserialize(memory.Memory.Span[Constants.HeaderSize..(Constants.HeaderSize + packet.Size)]);
|
||||||
|
|
Loading…
Reference in a new issue