Code (style) fixes

This commit is contained in:
Sanae 2022-03-03 22:24:33 -06:00
parent f6df86f927
commit 9e1a53a231
1 changed files with 6 additions and 3 deletions

View File

@ -28,10 +28,11 @@ server.ClientJoined += async (c, _) => {
async Task ClientSyncShineBag(Client client) { async Task ClientSyncShineBag(Client client) {
try { try {
foreach (int shine in shineBag.Except((ConcurrentBag<int>) client.Metadata["shineSync"])) foreach (int shine in shineBag.Except((ConcurrentBag<int>) client.Metadata["shineSync"]).ToArray()) {
await client.Send(new ShinePacket { await client.Send(new ShinePacket {
ShineId = shine ShineId = shine
}); });
}
} catch { } catch {
// errors that can happen when sending will crash the server :) // errors that can happen when sending will crash the server :)
} }
@ -39,7 +40,7 @@ async Task ClientSyncShineBag(Client client) {
async void SyncShineBag() { async void SyncShineBag() {
try { try {
await Parallel.ForEachAsync(server.Clients, async (client, _) => { await ClientSyncShineBag(client); }); await Parallel.ForEachAsync(server.Clients.ToArray(), async (client, _) => await ClientSyncShineBag(client));
} catch { } catch {
// errors that can happen shines change will crash the server :) // errors that can happen shines change will crash the server :)
} }
@ -75,7 +76,9 @@ server.PacketHandler = (c, p) => {
SyncShineBag(); SyncShineBag();
break; break;
} }
case PlayerPacket playerPacket when flipEnabled && Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Others && Settings.Instance.Flip.Players.Contains(c.Id): { case PlayerPacket playerPacket when flipEnabled
&& Settings.Instance.Flip.Pov is FlipOptions.Both or FlipOptions.Others
&& Settings.Instance.Flip.Players.Contains(c.Id): {
playerPacket.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d); playerPacket.Position += Vector3.UnitY * MarioSize(playerPacket.Is2d);
playerPacket.Rotation *= Quaternion.CreateFromRotationMatrix(Matrix4x4.CreateRotationX(MathF.PI)) * Quaternion.CreateFromRotationMatrix(Matrix4x4.CreateRotationY(MathF.PI)); playerPacket.Rotation *= Quaternion.CreateFromRotationMatrix(Matrix4x4.CreateRotationX(MathF.PI)) * Quaternion.CreateFromRotationMatrix(Matrix4x4.CreateRotationY(MathF.PI));
server.Broadcast(playerPacket, c); server.Broadcast(playerPacket, c);