]> git.deb.at Git - rhonda/impostor.git/commitdiff
Fix ServerReplay error
authorAeonLucid <aeonlucid@outlook.com>
Sat, 24 Oct 2020 01:51:18 +0000 (03:51 +0200)
committerAeonLucid <aeonlucid@outlook.com>
Sat, 24 Oct 2020 01:51:18 +0000 (03:51 +0200)
src/Impostor.Server/Net/Client.cs
src/Impostor.Server/Net/State/Game.Data.cs
src/Impostor.Tools.ServerReplay/Program.cs

index 93bc4eedc178514f3112ff088f1bd305b01eb4f4..f0711b2ed6678165e0e55a66f8942242795a651a 100644 (file)
@@ -269,7 +269,7 @@ namespace Impostor.Server.Net
                 _logger.LogError(ex, "Exception caught in client disconnection.");
             }
 
-            _logger.LogInformation("Client disconnecting, reason: {0}.", reason);
+            _logger.LogInformation("Client {0} disconnecting, reason: {1}.", Id, reason);
             _clientManager.Remove(this);
         }
 
index b2828d463d521fc565056aa324637ed0c5fd7c9c..d58466f836f4170032c0a6b56a1df87a64240455 100644 (file)
@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
+using Impostor.Api;
 using Impostor.Api.Innersloth.Data;
 using Impostor.Api.Innersloth.Net;
 using Impostor.Api.Innersloth.Net.Objects;
@@ -246,8 +247,7 @@ namespace Impostor.Server.Net.State
                         // Only the host is allowed to despawn objects.
                         if (!sender.IsHost)
                         {
-                            _logger.LogWarning("Player {0} ({1}) tried to send SpawnFlag as non-host.", sender.Client.Name, sender.Client.Id);
-                            return false;
+                            throw new ImpostorCheatException("Tried to send SpawnFlag as non-host.");
                         }
 
                         var objectId = reader.ReadPackedUInt32();
@@ -314,9 +314,9 @@ namespace Impostor.Server.Net.State
                         break;
                     }
 
+                    // Only the host is allowed to despawn objects.
                     case GameDataTag.DespawnFlag:
                     {
-                        // Only the host is allowed to despawn objects.
                         var netId = reader.ReadPackedUInt32();
                         if (_allObjectsFast.TryGetValue(netId, out var obj))
                         {
index c904081610fb0f0782e10c57b47a6c3566d1f108..424a7bf4d3eec2c6bc1128bdaf94bbae45a02589 100644 (file)
@@ -125,7 +125,7 @@ namespace Impostor.Tools.ServerReplay
                     var addressLength = reader.ReadByte();
                     var addressBytes = reader.ReadBytes(addressLength);
                     var addressPort = reader.ReadUInt16();
-                    var address = new IPEndPoint(new IPAddress(addressBytes), addressPort);
+                    var address = new IPEndPoint(new IPAddress(addressBytes), clientId);
                     var name = reader.ReadString();
 
                     // Create and register connection.
@@ -153,9 +153,9 @@ namespace Impostor.Tools.ServerReplay
                     {
                         GameOptions.Add(clientId, Message00HostGameC2S.Deserialize(message));
                     }
-                    else
+                    else if (Connections.TryGetValue(clientId, out var client))
                     {
-                        await Connections[clientId].Client!.HandleMessageAsync(message, messageType);
+                        await client.Client!.HandleMessageAsync(message, messageType);
                     }
                     break;