]> git.deb.at Git - rhonda/impostor.git/commitdiff
Added missing checks in InnerShipStatus
authorAeonLucid <aeonlucid@outlook.com>
Fri, 23 Oct 2020 22:04:43 +0000 (00:04 +0200)
committerAeonLucid <aeonlucid@outlook.com>
Fri, 23 Oct 2020 22:04:43 +0000 (00:04 +0200)
src/Impostor.Api/Extensions/SystemTypesExtensions.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/Net/Objects/InnerPlayerControl.cs
src/Impostor.Api/Innersloth/Net/Objects/InnerShipStatus.cs

diff --git a/src/Impostor.Api/Extensions/SystemTypesExtensions.cs b/src/Impostor.Api/Extensions/SystemTypesExtensions.cs
new file mode 100644 (file)
index 0000000..e927e2e
--- /dev/null
@@ -0,0 +1,12 @@
+using Impostor.Api.Innersloth.Net.Objects.Systems;
+
+namespace Impostor.Api
+{
+    public static class SystemTypesExtensions
+    {
+        public static string GetFriendlyName(this SystemTypes type)
+        {
+            return SystemTypeHelpers.Names[(int)type];
+        }
+    }
+}
\ No newline at end of file
index 103ea06b572be0c4b76c427e31b5461711ecd594..f84de762bd7ac478a2ffb27918980323d385fc03 100644 (file)
@@ -108,16 +108,15 @@ namespace Impostor.Api.Innersloth.Net.Objects
                 {
                     if (!sender.IsHost)
                     {
-                        throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.SetInfected)} but was not a host.");
+                        throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.Exiled)} but was not a host.");
                     }
 
                     if (target != null)
                     {
-                        throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.SetInfected)} to a specific player instead of broadcast.");
+                        throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.Exiled)} to a specific player instead of broadcast.");
                     }
 
-                    Console.WriteLine(PlayerInfo.PlayerName + " was voted out.");
-
+                    // TODO: Not hit?
                     Die(DeathReason.Exile);
                     break;
                 }
@@ -250,6 +249,11 @@ namespace Impostor.Api.Innersloth.Net.Objects
                     }
 
                     var player = reader.ReadNetObject<InnerPlayerControl>(_game);
+                    if (!player.PlayerInfo.IsDead)
+                    {
+                        player.Die(DeathReason.Kill);
+                    }
+
                     break;
                 }
 
index f3960d91bbeb415d851292cc36216872296ee1b8..3bbf9b108c988efa1ba027d0312192e895e78bff 100644 (file)
@@ -48,24 +48,38 @@ namespace Impostor.Api.Innersloth.Net.Objects
             {
                 case RpcCalls.CloseDoorsOfType:
                 {
+                    if (target == null || !target.IsHost)
+                    {
+                        throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.CloseDoorsOfType)} to wrong destinition, must be host.");
+                    }
+
                     if (!sender.Character.PlayerInfo.IsImpostor)
                     {
-                        Console.WriteLine($"OOPS Fake Impostor: {sender.Character.PlayerInfo.PlayerName} did doors");
+                        // throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.CloseDoorsOfType)} as crewmate.");
                     }
 
+                    var systemType = (SystemTypes)reader.ReadByte();
+
                     break;
                 }
 
                 case RpcCalls.RepairSystem:
                 {
+                    if (target == null || !target.IsHost)
+                    {
+                        throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.RepairSystem)} to wrong destinition, must be host.");
+                    }
+
+                    if (!sender.Character.PlayerInfo.IsImpostor)
+                    {
+                        // throw new ImpostorCheatException($"Client sent {nameof(RpcCalls.RepairSystem)} as crewmate.");
+                    }
+
                     var systemType = (SystemTypes)reader.ReadByte();
                     var player = reader.ReadNetObject<InnerPlayerControl>(_game);
                     var amount = reader.ReadByte();
 
-                    if (systemType == SystemTypes.Sabotage && !player.PlayerInfo.IsImpostor)
-                    {
-                        Console.WriteLine($"OOPS Fake Impostor: {player.PlayerInfo.PlayerName} did {(SystemTypes) amount}");
-                    }
+                    // TODO: Modify data (?)
 
                     break;
                 }
@@ -80,7 +94,7 @@ namespace Impostor.Api.Innersloth.Net.Objects
 
         public override bool Serialize(IMessageWriter writer, bool initialState)
         {
-            throw new System.NotImplementedException();
+            throw new NotImplementedException();
         }
 
         public override void Deserialize(IClientPlayer sender, IMessageReader reader, bool initialState)