]> git.deb.at Git - rhonda/impostor.git/commitdiff
Remove Impostor.Shared
authorAeonLucid <aeonlucid@gmail.com>
Mon, 19 Oct 2020 10:55:26 +0000 (12:55 +0200)
committerAeonLucid <aeonlucid@gmail.com>
Mon, 19 Oct 2020 10:55:26 +0000 (12:55 +0200)
120 files changed:
src/Impostor.Api/Events/Attributes/EventListenerAttribute.cs
src/Impostor.Api/Events/EventPriority.cs
src/Impostor.Api/Events/Game/GameCreatedEvent.cs
src/Impostor.Api/Events/Game/GameDestroyedEvent.cs
src/Impostor.Api/Events/Game/IGameEvent.cs
src/Impostor.Api/Events/Game/PlayerJoinedGameEvent.cs
src/Impostor.Api/Events/Game/PlayerLeftGameEvent.cs
src/Impostor.Api/Events/IEvent.cs
src/Impostor.Api/Events/IEventCancelable.cs
src/Impostor.Api/Events/IEventListener.cs
src/Impostor.Api/Events/Managers/IEventManager.cs
src/Impostor.Api/Exceptions/ImpostorException.cs
src/Impostor.Api/Games/Extensions/GameManagerExtensions.cs
src/Impostor.Api/Games/GameCode.cs
src/Impostor.Api/Games/GameJoinError.cs
src/Impostor.Api/Games/GameJoinResult.cs
src/Impostor.Api/Games/IGame.cs
src/Impostor.Api/Games/Managers/IGameManager.cs
src/Impostor.Api/Impostor.Api.csproj
src/Impostor.Api/Innersloth/Data/AlterGameTags.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/Data/DisconnectReason.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/Data/GameKeywords.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/Data/GameStates.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/Data/MapFlags.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/FloatRange.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/GameCodeParser.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/GameData/GameDataTag.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/GameOptionsData.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/GameVersion.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/RegionInfo.cs [new file with mode: 0644]
src/Impostor.Api/Innersloth/ServerInfo.cs [new file with mode: 0644]
src/Impostor.Api/Net/Extensions/GameMessageWriterExtensions.cs
src/Impostor.Api/Net/IClient.cs
src/Impostor.Api/Net/IClientPlayer.cs
src/Impostor.Api/Net/IConnection.cs
src/Impostor.Api/Net/LimboStates.cs
src/Impostor.Api/Net/Manager/IClientManager.cs
src/Impostor.Api/Net/Messages/IConnectionMessageWriter.cs
src/Impostor.Api/Net/Messages/IGameMessageWriter.cs
src/Impostor.Api/Net/Messages/IMessage.cs
src/Impostor.Api/Net/Messages/IMessageReader.cs
src/Impostor.Api/Net/Messages/IMessageWriter.cs
src/Impostor.Api/Net/Messages/MessageType.cs
src/Impostor.Api/Plugins/IPlugin.cs
src/Impostor.Api/Plugins/PluginBase.cs
src/Impostor.Api/Unity/Mathf.cs [new file with mode: 0644]
src/Impostor.Patcher/Impostor.Patcher.Shared/AmongUsModifier.cs
src/Impostor.Patcher/Impostor.Patcher.Shared/Impostor.Patcher.Shared.csproj
src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/RegionInfo.cs [new file with mode: 0644]
src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/ServerInfo.cs [new file with mode: 0644]
src/Impostor.Plugins.Debugger/DebugPlugin.cs
src/Impostor.Plugins.Debugger/Pages/Index.razor
src/Impostor.Server/Events/EventHandler.cs
src/Impostor.Server/Events/EventManager.cs
src/Impostor.Server/Events/RegisteredEventListener.cs
src/Impostor.Server/Events/TemporaryEventRegister.cs
src/Impostor.Server/GameData/InnerNetObject.cs
src/Impostor.Server/GameData/Objects/Components/InnerCustomNetworkTransform.cs
src/Impostor.Server/GameData/Objects/Components/InnerPlayerPhysics.cs
src/Impostor.Server/GameData/Objects/Components/InnerVoteBanSystem.cs
src/Impostor.Server/GameData/Objects/InnerGameData.PlayerInfo.cs
src/Impostor.Server/GameData/Objects/InnerGameData.TaskInfo.cs
src/Impostor.Server/GameData/Objects/InnerGameData.cs
src/Impostor.Server/GameData/Objects/InnerLobbyBehaviour.cs
src/Impostor.Server/GameData/Objects/InnerMeetingHud.cs
src/Impostor.Server/GameData/Objects/InnerPlayerControl.cs
src/Impostor.Server/GameData/Objects/InnerShipStatus.cs
src/Impostor.Server/Impostor.Server.csproj
src/Impostor.Server/Net/Client.cs
src/Impostor.Server/Net/ClientBase.Api.cs
src/Impostor.Server/Net/ClientBase.cs
src/Impostor.Server/Net/Hazel/HazelConnection.Api.cs
src/Impostor.Server/Net/Hazel/HazelConnection.cs
src/Impostor.Server/Net/Hazel/Messages/BufferMessageReader.cs
src/Impostor.Server/Net/Hazel/Messages/HazelConnectionMessageWriter.cs
src/Impostor.Server/Net/Hazel/Messages/HazelGameMessageWriter.cs
src/Impostor.Server/Net/Hazel/Messages/HazelMessage.cs
src/Impostor.Server/Net/Hazel/Messages/HazelMessageWriter.cs
src/Impostor.Server/Net/Manager/ClientManager.Api.cs
src/Impostor.Server/Net/Manager/ClientManager.cs
src/Impostor.Server/Net/Manager/GameManager.Api.cs
src/Impostor.Server/Net/Manager/GameManager.cs
src/Impostor.Server/Net/Messages/Message00HostGame.cs
src/Impostor.Server/Net/Messages/Message01JoinGame.cs
src/Impostor.Server/Net/Messages/Message04RemovePlayer.cs
src/Impostor.Server/Net/Messages/Message07JoinedGame.cs
src/Impostor.Server/Net/Messages/Message10AlterGame.cs
src/Impostor.Server/Net/Messages/Message11KickPlayer.cs
src/Impostor.Server/Net/Messages/Message12WaitForHost.cs
src/Impostor.Server/Net/Messages/Message13Redirect.cs
src/Impostor.Server/Net/Messages/Message16GetGameListV2.cs
src/Impostor.Server/Net/Redirector/ClientRedirector.cs
src/Impostor.Server/Net/State/ClientPlayer.Api.cs
src/Impostor.Server/Net/State/ClientPlayer.cs
src/Impostor.Server/Net/State/Game.Api.cs
src/Impostor.Server/Net/State/Game.Data.cs
src/Impostor.Server/Net/State/Game.Incoming.cs
src/Impostor.Server/Net/State/Game.Outgoing.cs
src/Impostor.Server/Net/State/Game.State.cs
src/Impostor.Server/Net/State/Game.cs
src/Impostor.Server/Plugins/PluginLoader.cs
src/Impostor.Server/Program.cs
src/Impostor.Shared/Impostor.Shared.csproj [deleted file]
src/Impostor.Shared/Innersloth/Data/AlterGameTags.cs [deleted file]
src/Impostor.Shared/Innersloth/Data/DisconnectReason.cs [deleted file]
src/Impostor.Shared/Innersloth/Data/GameKeywords.cs [deleted file]
src/Impostor.Shared/Innersloth/Data/GameStates.cs [deleted file]
src/Impostor.Shared/Innersloth/Data/MapFlags.cs [deleted file]
src/Impostor.Shared/Innersloth/FloatRange.cs [deleted file]
src/Impostor.Shared/Innersloth/GameCodeParser.cs [deleted file]
src/Impostor.Shared/Innersloth/GameData/GameDataTag.cs [deleted file]
src/Impostor.Shared/Innersloth/GameOptionsData.cs [deleted file]
src/Impostor.Shared/Innersloth/GameVersion.cs [deleted file]
src/Impostor.Shared/Innersloth/RegionInfo.cs [deleted file]
src/Impostor.Shared/Innersloth/ServerInfo.cs [deleted file]
src/Impostor.Shared/Unity/Mathf.cs [deleted file]
src/Impostor.Shared/Utils/HexUtils.cs [deleted file]
src/Impostor.Tests/GameCodeTests.cs
src/Impostor.Tests/Hazel/BufferMessageReaderTests.cs
src/Impostor.sln

index c8b9360dd437c3622361aadf506120dea4d48d64..a37394653be3f07b5dd149e8ad69ecadbf061185 100644 (file)
@@ -1,6 +1,6 @@
 using System;
 
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
     public class EventListenerAttribute : Attribute
index dbf506e44712e96ab597849cfec9313067c2a9c7..641f4aa96a3ca5501d1bb2cb0c25007f32ac202c 100644 (file)
@@ -1,4 +1,4 @@
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     public enum EventPriority
     {
index a9162272b975f40d7c6a08c0d7e1751291fb10a4..dc96faec15dff2e36b2f3c4bc007806b78b29d1f 100644 (file)
@@ -1,6 +1,6 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
 
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     /// <summary>
     ///     Called whenever a new <see cref="IGame"/> is created.
index 5d32143fc1ff61ec349496bc3de79d60107cc793..36fec11dc1a016bcd8dba6e144432b8325e618c0 100644 (file)
@@ -1,6 +1,6 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
 
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     /// <summary>
     ///     Called whenever a new <see cref="IGame"/> is destroyed.
index 8d77c4b6b70b203f95c67ea04ad720ef27510ee7..4aacd18480ab5ec8a09fdc0d1b40a2fd783e1311 100644 (file)
@@ -1,6 +1,6 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
 
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     public interface IGameEvent : IEvent
     {
index 0a47f64a50e72fe7b3915b90ea17eceb04d1b2a1..3c165aab3975d99cdc4e13ade840e4a81fd5b02c 100644 (file)
@@ -1,7 +1,7 @@
-using Impostor.Server.Games;
-using Impostor.Server.Net;
+using Impostor.Api.Games;
+using Impostor.Api.Net;
 
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     public class PlayerJoinedGameEvent : IGameEvent
     {
index e17c33374b94e64f2deb70a4dce08546a0de3a46..5947ff2de1c397182d7414806838175a0233cdea 100644 (file)
@@ -1,7 +1,7 @@
-using Impostor.Server.Games;
-using Impostor.Server.Net;
+using Impostor.Api.Games;
+using Impostor.Api.Net;
 
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     public class PlayerLeftGameEvent : IGameEvent
     {
index e9b35052e9d14be5c191175b2872b6d127eb99ff..796898e1af6ed74a022e0a82d3b78d84cca260b1 100644 (file)
@@ -1,4 +1,4 @@
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     public interface IEvent
     {
index 75e2364e63e20d6a4143cb3e42ca15e18397f4cb..319f02a22da3827f0f22dfd080c023ae10831fc7 100644 (file)
@@ -1,4 +1,4 @@
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     public interface IEventCancelable : IEvent
     {
index 3e08c36cc88293b1fa6ab9c132d40197285b8982..76392fcc5fc8db544010886a849fcbd59f1201b7 100644 (file)
@@ -1,4 +1,4 @@
-namespace Impostor.Server.Events
+namespace Impostor.Api.Events
 {
     public interface IEventListener
     {
index 11ae01d61d2173680fd3dd37ade64a27450bccd2..a9d433bfe24165e1ef3b84c47c6912e9313d136b 100644 (file)
@@ -1,7 +1,7 @@
 using System;
 using System.Threading.Tasks;
 
-namespace Impostor.Server.Events.Managers
+namespace Impostor.Api.Events.Managers
 {
     public interface IEventManager
     {
index 9e9b8f7c6c389dedcc72666c2728602b78451b10..188c50e85dad95190b4104edb29e9b0ee8949acf 100644 (file)
@@ -1,7 +1,7 @@
 using System;
 using System.Runtime.Serialization;
 
-namespace Impostor.Server
+namespace Impostor.Api
 {
     public class ImpostorException : Exception
     {
index db173c2ab5eb5ea234d1951b130dfa217028f3db..1f4bd5dc472ab78b55463689dba287cf0811622b 100644 (file)
@@ -1,8 +1,8 @@
 using System.Linq;
-using Impostor.Server.Games.Managers;
-using Impostor.Shared.Innersloth.Data;
+using Impostor.Api.Games.Managers;
+using Impostor.Api.Innersloth.Data;
 
-namespace Impostor.Server.Games
+namespace Impostor.Api.Games
 {
     public static class GameManagerExtensions
     {
index 0d1fd37eaec79ccde2ab36d36f7a1683d4d38772..2c30e7e9d47d2df4120dbf4f85777fb0a96c61cd 100644 (file)
@@ -1,7 +1,7 @@
 using System;
-using Impostor.Shared.Innersloth;
+using Impostor.Api.Innersloth;
 
-namespace Impostor.Server.Games
+namespace Impostor.Api.Games
 {
     public readonly struct GameCode : IEquatable<GameCode>
     {
index c4d7c6dc83cbb8817efcdff15da4eb70b56d0717..4889ea965bc3c646001e9d77b45f89faccd23c44 100644 (file)
@@ -1,4 +1,4 @@
-namespace Impostor.Server.Games
+namespace Impostor.Api.Games
 {
     public enum GameJoinError
     {
index 40babeb9de5b4a9d86d37160250a3da1ca4dc331..b33a2b669591a0bda8155f3567c4523a466fde57 100644 (file)
@@ -1,8 +1,8 @@
 using System;
 using System.Diagnostics.CodeAnalysis;
-using Impostor.Server.Net;
+using Impostor.Api.Net;
 
-namespace Impostor.Server.Games
+namespace Impostor.Api.Games
 {
     public readonly struct GameJoinResult
     {
index dcd25a2061d499d4beabd850457f1ef0011f79be..6de41f08d52f85655733237da51d84857490dd2d 100644 (file)
@@ -1,11 +1,11 @@
 using System.Collections.Generic;
 using System.Net;
-using Impostor.Server.Net;
-using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth;
-using Impostor.Shared.Innersloth.Data;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 
-namespace Impostor.Server.Games
+namespace Impostor.Api.Games
 {
     public interface IGame
     {
index d089772349f4983fbf02b586bebc484811b774a9..10a05f0773cbe74c41c7f2283c747cc2f36ce4e4 100644 (file)
@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace Impostor.Server.Games.Managers
+namespace Impostor.Api.Games.Managers
 {
     public interface IGameManager
     {
index 0e72d47c51e472c97142ec6bca6601e4ef89affa..7a1d3bb4b66e7af9ce93d6d353f0bc3063716ab3 100644 (file)
@@ -2,16 +2,11 @@
 
     <PropertyGroup>
         <TargetFramework>net5.0</TargetFramework>
-        <RootNamespace>Impostor.Server</RootNamespace>
-        <Nullable>enable</Nullable>
         <DebugType Condition=" '$(Configuration)' == 'Release' ">None</DebugType>
         <CodeAnalysisRuleSet>ProjectRules.ruleset</CodeAnalysisRuleSet>
+        <LangVersion>9</LangVersion>
     </PropertyGroup>
 
-    <ItemGroup>
-      <ProjectReference Include="..\Impostor.Shared\Impostor.Shared.csproj" />
-    </ItemGroup>
-
     <ItemGroup>
       <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0-rc.1.20451.14" />
       <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0-rc.1.20451.14" />
diff --git a/src/Impostor.Api/Innersloth/Data/AlterGameTags.cs b/src/Impostor.Api/Innersloth/Data/AlterGameTags.cs
new file mode 100644 (file)
index 0000000..ee13ae2
--- /dev/null
@@ -0,0 +1,7 @@
+namespace Impostor.Api.Innersloth.Data
+{
+    public enum AlterGameTags : byte
+    {
+        ChangePrivacy = 1
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/Data/DisconnectReason.cs b/src/Impostor.Api/Innersloth/Data/DisconnectReason.cs
new file mode 100644 (file)
index 0000000..e1a8e3a
--- /dev/null
@@ -0,0 +1,54 @@
+namespace Impostor.Api.Innersloth.Data
+{
+    public enum DisconnectReason
+    {
+        ExitGame = 0,
+        // The game you tried to join is full.
+        // Check with the host to see if you can join next round.
+        GameFull = 1,
+        // The game you tried to join already started.
+        // Check with the host to see if you can join next round.
+        GameStarted = 2,
+        // Could not find the game you're looking for.
+        GameMissing = 3,
+        IncorrectGame = 18,
+        // For these a message can be given, specifying an empty message shows
+        // "An unknown error disconnected you from the server."
+        CustomMessage1 = 4,
+        Custom = 8,
+        // CustomMessage3 = 11,
+        // CustomMessage4 = 12,
+        // CustomMessage5 = 13,
+        // CustomMessage6 = 14,
+        // CustomMessage7 = 15,
+        // You are running an older version of the game.
+        // Please update to play with others.
+        IncorrectVersion = 5,
+        // You cannot rejoin that room.
+        // You were banned
+        Banned = 6,
+        // You can rejoin if the room hasn't started
+        // You were kicked
+        Kicked = 7,
+        // You were banned for hacking.
+        // Please stop.
+        Hacking = 10,
+        Destroy = 16,
+        // You disconnected from the host.
+        // If this happens often, check your WiFi strength.
+        //
+        // You disconnected from the server.
+        // If this happens often, check your network strength.
+        // This may also be a server issue.
+        Error = 17,
+        // The server stopped this game. Possibly due to inactivity.
+        ServerRequest = 19,
+        // The Among Us servers are overloaded.
+        // Sorry! Please try again later!
+        ServerFull = 20,
+        FocusLostBackground = 207,
+        IntentionalLeaving = 208,
+        FocusLost = 209,
+        NewConnection = 210
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/Data/GameKeywords.cs b/src/Impostor.Api/Innersloth/Data/GameKeywords.cs
new file mode 100644 (file)
index 0000000..f3b37cc
--- /dev/null
@@ -0,0 +1,19 @@
+using System;
+
+namespace Impostor.Api.Innersloth.Data
+{
+    [Flags]
+    public enum GameKeywords : uint
+    {
+        All = 0,
+        Other = 1,
+        Spanish = 2,
+        Korean = 4,
+        Russian = 8,
+        Portuguese = 16,
+        Arabic = 32,
+        Filipone = 64,
+        Polish = 128,
+        English = 256
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/Data/GameStates.cs b/src/Impostor.Api/Innersloth/Data/GameStates.cs
new file mode 100644 (file)
index 0000000..986e2d2
--- /dev/null
@@ -0,0 +1,10 @@
+namespace Impostor.Api.Innersloth.Data
+{
+    public enum GameStates : byte
+    {
+        NotStarted = 0,
+        Started = 1,
+        Ended = 2,
+        Destroyed = 3
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/Data/MapFlags.cs b/src/Impostor.Api/Innersloth/Data/MapFlags.cs
new file mode 100644 (file)
index 0000000..66e0c95
--- /dev/null
@@ -0,0 +1,12 @@
+using System;
+
+namespace Impostor.Api.Innersloth.Data
+{
+    [Flags]
+    public enum MapFlags
+    {
+        Skeld = 1,
+        MiraHQ = 2,
+        Polus = 4
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/FloatRange.cs b/src/Impostor.Api/Innersloth/FloatRange.cs
new file mode 100644 (file)
index 0000000..c8a0824
--- /dev/null
@@ -0,0 +1,22 @@
+using Impostor.Api.Unity;
+
+namespace Impostor.Api.Innersloth
+{
+    public class FloatRange
+    {
+        private readonly float _min;
+        private readonly float _max;
+
+        public FloatRange(float min, float max)
+        {
+            _min = min;
+            _max = max;
+        }
+
+        public float Width => _max - _min;
+
+        public float Lerp(float v) => Mathf.Lerp(_min, _max, v);
+
+        public float ReverseLerp(float t) => Mathf.Clamp((t - _min) / Width, 0.0f, 1f);
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/GameCodeParser.cs b/src/Impostor.Api/Innersloth/GameCodeParser.cs
new file mode 100644 (file)
index 0000000..9717cff
--- /dev/null
@@ -0,0 +1,142 @@
+using System;
+using System.Buffers.Binary;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace Impostor.Api.Innersloth
+{
+    public static class GameCodeParser
+    {
+        private const string V2 = "QWXRTYLPESDFGHUJKZOCVBINMA";
+        private static readonly int[] V2Map = {
+            25,
+            21,
+            19,
+            10,
+            8,
+            11,
+            12,
+            13,
+            22,
+            15,
+            16,
+            6,
+            24,
+            23,
+            18,
+            7,
+            0,
+            3,
+            9,
+            4,
+            14,
+            20,
+            1,
+            2,
+            5,
+            17
+        };
+        private static readonly RNGCryptoServiceProvider Random = new RNGCryptoServiceProvider();
+        
+        public static string IntToGameName(int input)
+        {
+            // V2.
+            if (input < -1)
+            {
+                return IntToGameNameV2(input);
+            }
+
+            // V1.
+            Span<byte> code = stackalloc byte[4];
+            BinaryPrimitives.WriteInt32LittleEndian(code, input);
+#if NETSTANDARD2_0
+            return Encoding.UTF8.GetString(code.Slice(0, 4).ToArray());
+#else
+            return Encoding.UTF8.GetString(code.Slice(0, 4));
+#endif
+        }
+
+        private static string IntToGameNameV2(int input)
+        {
+            var a = input & 0x3FF;
+            var b = (input >> 10) & 0xFFFFF;
+
+            return new string(new []
+            {
+                V2[a % 26],
+                V2[a / 26],
+                V2[b % 26],
+                V2[b / 26 % 26],
+                V2[b / (26 * 26) % 26],
+                V2[b / (26 * 26 * 26) % 26]
+            });
+        }
+
+        public static int GameNameToInt(string code)
+        {
+            var upper = code.ToUpperInvariant();
+            if (upper.Any(x => !char.IsLetter(x)))
+            {
+                return -1;
+            }
+            
+            var len = code.Length;
+            if (len == 6)
+            {
+                return GameNameToIntV2(upper);
+            }
+
+            if (len == 4)
+            {
+                return code[0] | ((code[1] | ((code[2] | (code[3] << 8)) << 8)) << 8);
+            }
+            
+            return -1;
+        }
+        
+        private static int GameNameToIntV2(string code)
+        {
+            var a = V2Map[code[0] - 65];
+            var b = V2Map[code[1] - 65];
+            var c = V2Map[code[2] - 65];
+            var d = V2Map[code[3] - 65];
+            var e = V2Map[code[4] - 65];
+            var f = V2Map[code[5] - 65];
+
+            var one = (a + 26 * b) & 0x3FF;
+            var two = (c + 26 * (d + 26 * (e + 26 * f)));
+
+            return (int) (one | ((two << 10) & 0x3FFFFC00) | 0x80000000);
+        }
+
+        public static int GenerateCode(int len)
+        {
+            if (len != 4 && len != 6)
+            {
+                throw new ArgumentException("should be 4 or 6", nameof(len));
+            }
+            
+            // Generate random bytes.
+#if NETSTANDARD2_0
+            var data = new byte[len];
+#else
+            Span<byte> data = stackalloc byte[len];
+#endif
+            Random.GetBytes(data);
+            
+            // Convert to their char representation.
+            Span<char> dataChar = stackalloc char[len];
+            for (var i = 0; i < len; i++)
+            {
+                dataChar[i] = V2[V2Map[data[i] % 26]];
+            }
+
+#if NETSTANDARD2_0
+            return GameNameToInt(new string(dataChar.ToArray()));
+#else
+            return GameNameToInt(new string(dataChar));
+#endif
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/GameData/GameDataTag.cs b/src/Impostor.Api/Innersloth/GameData/GameDataTag.cs
new file mode 100644 (file)
index 0000000..d5f3fc5
--- /dev/null
@@ -0,0 +1,13 @@
+namespace Impostor.Api.Innersloth.GameData
+{
+    public static class GameDataTag
+    {
+        public const byte DataFlag = 1;
+        public const byte RpcFlag = 2;
+        public const byte SpawnFlag = 4;
+        public const byte DespawnFlag = 5;
+        public const byte SceneChangeFlag = 6;
+        public const byte ReadyFlag = 7;
+        public const byte ChangeSettingsFlag = 8;
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/GameOptionsData.cs b/src/Impostor.Api/Innersloth/GameOptionsData.cs
new file mode 100644 (file)
index 0000000..cac6371
--- /dev/null
@@ -0,0 +1,104 @@
+using System;
+using System.IO;
+using Impostor.Api.Innersloth.Data;
+
+namespace Impostor.Api.Innersloth
+{
+    public class GameOptionsData
+    {
+        public byte Version { get; set; }
+        public byte MaxPlayers { get; set; }
+        public GameKeywords Keywords { get; set; }
+        public byte MapId { get; set; }
+        public float PlayerSpeedMod { get; set; }
+        public float CrewLightMod { get; set; }
+        public float ImpostorLightMod { get; set; }
+        public float KillCooldown { get; set; }
+        public int NumCommonTasks { get; set; }
+        public int NumLongTasks { get; set; }
+        public int NumShortTasks { get; set; }
+        public int NumEmergencyMeetings { get; set; }
+        public int EmergencyCooldown { get; set; }
+        public int NumImpostors { get; set; }
+        public bool GhostsDoTasks { get; set; }
+        public int KillDistance { get; set; }
+        public int DiscussionTime { get; set; }
+        public int VotingTime { get; set; }
+        public bool ConfirmImpostor { get; set; }
+        public bool VisualTasks { get; set; }
+        public bool IsDefaults { get; set; }
+        
+        public void Serialize(BinaryWriter writer, byte version)
+        {
+            writer.Write((byte) version);
+            writer.Write((byte) MaxPlayers);
+            writer.Write((uint) Keywords);
+            writer.Write((byte) MapId);
+            writer.Write((float) PlayerSpeedMod);
+            writer.Write((float) CrewLightMod);
+            writer.Write((float) ImpostorLightMod);
+            writer.Write((float) KillCooldown);
+            writer.Write((byte) NumCommonTasks);
+            writer.Write((byte) NumLongTasks);
+            writer.Write((byte) NumShortTasks);
+            writer.Write((int) NumEmergencyMeetings);
+            writer.Write((byte) NumImpostors);
+            writer.Write((byte) KillDistance);
+            writer.Write((uint) DiscussionTime);
+            writer.Write((uint) VotingTime);
+            writer.Write((bool) IsDefaults);
+            if (version > 1)
+            {
+                writer.Write((byte) EmergencyCooldown);
+            }
+
+            if (version > 2)
+            {
+                writer.Write((bool) ConfirmImpostor);
+                writer.Write((bool) VisualTasks);
+            }
+        }
+
+        public static GameOptionsData Deserialize(ReadOnlyMemory<byte> bytes)
+        {
+            // TODO: Remove memory allocation.
+
+            using (var stream = new MemoryStream(bytes.ToArray()))
+            using (var reader = new BinaryReader(stream))
+            {
+                var result = new GameOptionsData();
+
+                result.Version = reader.ReadByte();
+                result.MaxPlayers = reader.ReadByte();
+                result.Keywords = (GameKeywords) reader.ReadUInt32();
+                result.MapId = reader.ReadByte();
+                result.PlayerSpeedMod = reader.ReadSingle();
+                result.CrewLightMod = reader.ReadSingle();
+                result.ImpostorLightMod = reader.ReadSingle();
+                result.KillCooldown = reader.ReadSingle();
+                result.NumCommonTasks = reader.ReadByte();
+                result.NumLongTasks = reader.ReadByte();
+                result.NumShortTasks = reader.ReadByte();
+                result.NumEmergencyMeetings = reader.ReadInt32();
+                result.NumImpostors = reader.ReadByte();
+                result.KillDistance = reader.ReadByte();
+                result.DiscussionTime = reader.ReadInt32();
+                result.VotingTime = reader.ReadInt32();
+                result.IsDefaults = reader.ReadBoolean();
+
+                if (result.Version > 1)
+                {
+                    result.EmergencyCooldown = reader.ReadByte();
+                }
+
+                if (result.Version > 2)
+                {
+                    result.ConfirmImpostor = reader.ReadBoolean();
+                    result.VisualTasks = reader.ReadBoolean();
+                }
+                
+                return result;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/GameVersion.cs b/src/Impostor.Api/Innersloth/GameVersion.cs
new file mode 100644 (file)
index 0000000..c11933e
--- /dev/null
@@ -0,0 +1,10 @@
+namespace Impostor.Api.Innersloth
+{
+    public class GameVersion
+    {
+        public static int GetVersion(int year, int month, int day, int rev = 0)
+        {
+            return (year * 25000) + (month * 1800) + (day * 50) + rev;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/RegionInfo.cs b/src/Impostor.Api/Innersloth/RegionInfo.cs
new file mode 100644 (file)
index 0000000..c78978b
--- /dev/null
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using System.IO;
+
+namespace Impostor.Api.Innersloth
+{
+    public class RegionInfo
+    {
+        public RegionInfo(string name, string ping, IReadOnlyList<ServerInfo> servers)
+        {
+            Name = name;
+            Ping = ping;
+            Servers = servers;
+        }
+
+        public string Name { get; }
+        public string Ping { get; }
+        public IReadOnlyList<ServerInfo> Servers { get; }
+
+        public void Serialize(BinaryWriter writer)
+        {
+            writer.Write(0);
+            writer.Write(Name);
+            writer.Write(Ping);
+            writer.Write(Servers.Count);
+
+            foreach (var server in Servers)
+            {
+                server.Serialize(writer);
+            }
+        }
+
+        public static RegionInfo Deserialize(BinaryReader reader)
+        {
+            var unknown = reader.ReadInt32();
+            var name = reader.ReadString();
+            var ping = reader.ReadString();
+            var servers = new List<ServerInfo>();
+            var serverCount = reader.ReadInt32();
+
+            for (var i = 0; i < serverCount; i++)
+            {
+                servers.Add(ServerInfo.Deserialize(reader));
+            }
+
+            return new RegionInfo(name, ping, servers);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Api/Innersloth/ServerInfo.cs b/src/Impostor.Api/Innersloth/ServerInfo.cs
new file mode 100644 (file)
index 0000000..7785823
--- /dev/null
@@ -0,0 +1,37 @@
+using System.IO;
+using System.Net;
+
+namespace Impostor.Api.Innersloth
+{
+    public class ServerInfo
+    {
+        public string Name { get; }
+        public string Ip { get; }
+        public ushort Port { get; }
+
+        public ServerInfo(string name, string ip, ushort port)
+        {
+            Name = name;
+            Ip = ip;
+            Port = port;
+        }
+        
+        public void Serialize(BinaryWriter writer)
+        {
+            writer.Write(Name);
+            writer.Write(IPAddress.Parse(Ip).GetAddressBytes());
+            writer.Write(Port);
+            writer.Write(0);
+        }
+
+        public static ServerInfo Deserialize(BinaryReader reader)
+        {
+            var name = reader.ReadString();
+            var ip = new IPAddress(reader.ReadBytes(4)).ToString();
+            var port = reader.ReadUInt16();
+            var unknown = reader.ReadInt32();
+            
+            return new ServerInfo(name, ip, port);
+        }
+    }
+}
\ No newline at end of file
index d995b5a055e87c4796739bcd7becee9e8ec8abbd..5f90bb53fce4d523f7c5926ff916a57da190c867 100644 (file)
@@ -1,8 +1,8 @@
 using System;
 using System.Threading.Tasks;
-using Impostor.Server.Net.Messages;
+using Impostor.Api.Net.Messages;
 
-namespace Impostor.Server.Net
+namespace Impostor.Api.Net
 {
     public static class GameMessageWriterExtensions
     {
index 0c508c47425a0954eab44216463d8c84fe950700..137ace0813c388fb4792917b255557ce04807db1 100644 (file)
@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace Impostor.Server.Net
+namespace Impostor.Api.Net
 {
     /// <summary>
     ///     Represents a connected game client.
index 4e4252f66661e8d560fb6f55543311bec4079375..bb28b844efdff5435b8281d7d2e53ce5441887e8 100644 (file)
@@ -1,7 +1,7 @@
 using System.Threading.Tasks;
-using Impostor.Server.Games;
+using Impostor.Api.Games;
 
-namespace Impostor.Server.Net
+namespace Impostor.Api.Net
 {
     /// <summary>
     ///     Represents a player in <see cref="IGame"/>.
index f619dfaac5377ce5b390d7f20cd820ae4f6c1dc1..70edd01e1eb334aa6ad8922fe701dbc20fcb8c56 100644 (file)
@@ -1,8 +1,8 @@
 using System.Net;
-using Impostor.Server.Games;
-using Impostor.Server.Net.Messages;
+using Impostor.Api.Games;
+using Impostor.Api.Net.Messages;
 
-namespace Impostor.Server.Net
+namespace Impostor.Api.Net
 {
     /// <summary>
     ///     Represents the connection of the client.
index 1812f5ae89daf083c1ad422aca72a3a06068f52a..d6e66bdc6308bafed6ccecb73641a60863a905c3 100644 (file)
@@ -1,6 +1,6 @@
 using System;
 
-namespace Impostor.Server.Net
+namespace Impostor.Api.Net
 {
     [Flags]
     public enum LimboStates
index 6405a653e8f5a163b3da9735296fd30c7b700451..92bf89f0d97dead94a1fe14ff879b14f9f8d019a 100644 (file)
@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace Impostor.Server.Net.Manager
+namespace Impostor.Api.Net.Manager
 {
     public interface IClientManager
     {
index 453eb7e93980ebe67c9bbd37952d5e4ca1780c6e..620046c75c368a818e0464a9689e4d12ecc2d654 100644 (file)
@@ -1,6 +1,6 @@
 using System.Threading.Tasks;
 
-namespace Impostor.Server.Net.Messages
+namespace Impostor.Api.Net.Messages
 {
     /// <summary>
     ///     Represents the message writer for <see cref="IConnection"/>.
index d1d769cce10f2871fe19110dae7d3f45ce6f6936..69c286c926a1c0577730dab776baaf5bcfbd973b 100644 (file)
@@ -1,7 +1,7 @@
 using System.Threading.Tasks;
-using Impostor.Server.Games;
+using Impostor.Api.Games;
 
-namespace Impostor.Server.Net.Messages
+namespace Impostor.Api.Net.Messages
 {
     /// <summary>
     ///     Represents the message writer for <see cref="IGame"/>.
index 854a0d279be339522b4a2405fd96c888201e2e83..a7eb63ebd48cc99213e45b0e27278fb6895e8b30 100644 (file)
@@ -1,4 +1,4 @@
-namespace Impostor.Server.Net.Messages
+namespace Impostor.Api.Net.Messages
 {
     public interface IMessage
     {
index aeefcc69992b216cad30b4c582cd9f7825f984c2..99e2e4d1eaf3a0b05ba905b82d66bb0f0ce252bb 100644 (file)
@@ -1,6 +1,6 @@
 using System;
 
-namespace Impostor.Server.Net.Messages
+namespace Impostor.Api.Net.Messages
 {
     public interface IMessageReader
     {
index add3154e96e1dc6740fcf6dd28f9174466284b85..eb009abbc593627750ac49d2025386790505a4d5 100644 (file)
@@ -1,8 +1,8 @@
 using System;
 using System.Net;
-using Impostor.Server.Games;
+using Impostor.Api.Games;
 
-namespace Impostor.Server.Net.Messages
+namespace Impostor.Api.Net.Messages
 {
     /// <summary>
     ///     Base message writer.
index a350cb650a76ca0f02264852270d461cef65342a..66335eba536ef7058f85dbdc3682491e2addcec9 100644 (file)
@@ -1,4 +1,4 @@
-namespace Impostor.Server.Net.Messages
+namespace Impostor.Api.Net.Messages
 {
     /// <summary>
     ///     Specifies how a message should be sent between connections.
index e5f86458d226fda224fd6d251857266e13a30002..f66f112d7844221b65c27ee176dcee6ccae5a1b5 100644 (file)
@@ -1,9 +1,9 @@
 using System.Threading.Tasks;
-using Impostor.Server.Events;
+using Impostor.Api.Events;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 
-namespace Impostor.Server.Plugins
+namespace Impostor.Api.Plugins
 {
     public interface IPlugin : IEventListener
     {
index 5ef6cf3c02324add6ddc91657ecb3b4278a2420a..cf641905e1f48d800b6b4ddeff7efdd8e91345ba 100644 (file)
@@ -2,7 +2,7 @@
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 
-namespace Impostor.Server.Plugins
+namespace Impostor.Api.Plugins
 {
     public class PluginBase : IPlugin
     {
diff --git a/src/Impostor.Api/Unity/Mathf.cs b/src/Impostor.Api/Unity/Mathf.cs
new file mode 100644 (file)
index 0000000..ed883c8
--- /dev/null
@@ -0,0 +1,45 @@
+namespace Impostor.Api.Unity
+{
+    public static class Mathf
+    {
+        /// <summary>
+        ///   <para>Clamps the given value between the given minimum float and maximum float values.  Returns the given value if it is within the min and max range.</para>
+        /// </summary>
+        /// <param name="value">The floating point value to restrict inside the range defined by the min and max values.</param>
+        /// <param name="min">The minimum floating point value to compare against.</param>
+        /// <param name="max">The maximum floating point value to compare against.</param>
+        /// <returns>
+        ///   <para>The float result between the min and max values.</para>
+        /// </returns>
+        public static float Clamp(float value, float min, float max)
+        {
+            if ((double) value < (double) min)
+                value = min;
+            else if ((double) value > (double) max)
+                value = max;
+            return value;
+        }
+
+        /// <summary>
+        ///   <para>Clamps value between 0 and 1 and returns value.</para>
+        /// </summary>
+        /// <param name="value"></param>
+        public static float Clamp01(float value)
+        {
+            if ((double) value < 0.0)
+                return 0.0f;
+            return (double) value > 1.0 ? 1f : value;
+        }
+
+        /// <summary>
+        ///   <para>Linearly interpolates between a and b by t.</para>
+        /// </summary>
+        /// <param name="a">The start value.</param>
+        /// <param name="b">The end value.</param>
+        /// <param name="t">The interpolation value between the two floats.</param>
+        /// <returns>
+        ///   <para>The interpolated float result between the two float values.</para>
+        /// </returns>
+        public static float Lerp(float a, float b, float t) => a + (b - a) * Mathf.Clamp01(t);
+    }
+}
\ No newline at end of file
index 130a6a462fe8b9e9c8d29f604c49898ef4f7a2b0..95f552480d5be790eade8455af6d1c24125880ff 100644 (file)
@@ -9,7 +9,7 @@ using System.Threading.Tasks;
 using Gameloop.Vdf;
 using Gameloop.Vdf.Linq;
 using Impostor.Patcher.Shared.Events;
-using Impostor.Shared.Innersloth;
+using Impostor.Patcher.Shared.Innersloth;
 using ErrorEventArgs = Impostor.Patcher.Shared.Events.ErrorEventArgs;
 
 namespace Impostor.Patcher.Shared
index 604bf319e3cc92ec599148664bb45dfc589e7710..e480870c8860e4fb92a2a6e93b1afbb37c0f7a08 100644 (file)
@@ -6,7 +6,6 @@
     </PropertyGroup>
 
     <ItemGroup>
-        <ProjectReference Include="..\..\Impostor.Shared\Impostor.Shared.csproj" />
         <PackageReference Include="Gameloop.Vdf" Version="0.6.1" />
     </ItemGroup>
     
diff --git a/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/RegionInfo.cs b/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/RegionInfo.cs
new file mode 100644 (file)
index 0000000..01b74d1
--- /dev/null
@@ -0,0 +1,48 @@
+using System.Collections.Generic;
+using System.IO;
+
+namespace Impostor.Patcher.Shared.Innersloth
+{
+    public class RegionInfo
+    {
+        public RegionInfo(string name, string ping, IReadOnlyList<ServerInfo> servers)
+        {
+            Name = name;
+            Ping = ping;
+            Servers = servers;
+        }
+
+        public string Name { get; }
+        public string Ping { get; }
+        public IReadOnlyList<ServerInfo> Servers { get; }
+
+        public void Serialize(BinaryWriter writer)
+        {
+            writer.Write(0);
+            writer.Write(Name);
+            writer.Write(Ping);
+            writer.Write(Servers.Count);
+
+            foreach (var server in Servers)
+            {
+                server.Serialize(writer);
+            }
+        }
+
+        public static RegionInfo Deserialize(BinaryReader reader)
+        {
+            var unknown = reader.ReadInt32();
+            var name = reader.ReadString();
+            var ping = reader.ReadString();
+            var servers = new List<ServerInfo>();
+            var serverCount = reader.ReadInt32();
+
+            for (var i = 0; i < serverCount; i++)
+            {
+                servers.Add(ServerInfo.Deserialize(reader));
+            }
+
+            return new RegionInfo(name, ping, servers);
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/ServerInfo.cs b/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/ServerInfo.cs
new file mode 100644 (file)
index 0000000..7203c84
--- /dev/null
@@ -0,0 +1,37 @@
+using System.IO;
+using System.Net;
+
+namespace Impostor.Patcher.Shared.Innersloth
+{
+    public class ServerInfo
+    {
+        public string Name { get; }
+        public string Ip { get; }
+        public ushort Port { get; }
+
+        public ServerInfo(string name, string ip, ushort port)
+        {
+            Name = name;
+            Ip = ip;
+            Port = port;
+        }
+        
+        public void Serialize(BinaryWriter writer)
+        {
+            writer.Write(Name);
+            writer.Write(IPAddress.Parse(Ip).GetAddressBytes());
+            writer.Write(Port);
+            writer.Write(0);
+        }
+
+        public static ServerInfo Deserialize(BinaryReader reader)
+        {
+            var name = reader.ReadString();
+            var ip = new IPAddress(reader.ReadBytes(4)).ToString();
+            var port = reader.ReadUInt16();
+            var unknown = reader.ReadInt32();
+            
+            return new ServerInfo(name, ip, port);
+        }
+    }
+}
\ No newline at end of file
index 53c544a95d5d2139ff1f24880b608a198b851b88..3521a6542d073ae08a4e36a1d000e301606d36e6 100644 (file)
@@ -1,4 +1,4 @@
-using Impostor.Server.Plugins;
+using Impostor.Api.Plugins;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.Extensions.DependencyInjection;
index 7ca76ed7a8183371e8260fb8ef66b0337ac7dbe1..4d53b08731b581cfffb2a3cfd2770b402ce4ea98 100644 (file)
@@ -1,9 +1,9 @@
 @page "/"
-@using Impostor.Server.Events
-@using Impostor.Server.Events.Managers
-@using Impostor.Server.Games.Managers
 @implements IDisposable
-@implements IEventListener
+@using Impostor.Api.Events.Managers
+@using Impostor.Api.Games.Managers
+@using Impostor.Api.Events
+@implements Impostor.Api.Events.IEventListener
 @inject IEventManager EventManager
 @inject IGameManager GameManager
 
index 61ac4d85a44396d415519e412b93130d50aebe06..e4582ca7a8e4e48199d71ed78d3dd4447ee9162d 100644 (file)
@@ -1,4 +1,6 @@
-namespace Impostor.Server.Events
+using Impostor.Api.Events;
+
+namespace Impostor.Server.Events
 {
     internal readonly struct EventHandler
     {
index 69ceef53fef45c3f59428ec036e31a25c9b49cf2..05a3e70d90a574aa1155a726fe2e559817a30633 100644 (file)
@@ -4,7 +4,8 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Reflection;
 using System.Threading.Tasks;
-using Impostor.Server.Events.Managers;
+using Impostor.Api.Events;
+using Impostor.Api.Events.Managers;
 using Microsoft.Extensions.DependencyInjection;
 
 namespace Impostor.Server.Events
index d0021b340b47cf0e5eac99890c848a4296acbc66..80df9d8a37da0ec36690b12db963ea4e4a9ee544 100644 (file)
@@ -5,6 +5,7 @@ using System.Linq;
 using System.Linq.Expressions;
 using System.Reflection;
 using System.Threading.Tasks;
+using Impostor.Api.Events;
 using Microsoft.Extensions.DependencyInjection;
 
 namespace Impostor.Server.Events
index 834fe41ab8bbe2e0460241bbb15bd0a649f473dd..8bcb643b85dc342e8b40a9b8d0f834c327440bd7 100644 (file)
@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
+using Impostor.Api.Events;
 
 namespace Impostor.Server.Events
 {
index 6f153ed3e6a15958715087b9d0271d522808188b..78ce960e95adf9a108a9d608148d43a1794f8e86 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Net.Messages;
+using Impostor.Api.Net.Messages;
+using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData
 {
index d3b5c051763f2afa3af03f9cc3b1beff74cf2ed5..c6804ed921512641c3e75934859dfe175d669b5b 100644 (file)
@@ -1,6 +1,6 @@
 using System.Numerics;
-using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Net.Messages;
 using Microsoft.Extensions.Logging;
 
 namespace Impostor.Server.GameData.Objects.Components
index edc01e0156c85d1ca4480d0d17c6d30d5108d292..df7f7aa76c49b5dee8a52d392669a95ec31dd477 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Net.Messages;
+using Impostor.Api.Net.Messages;
+using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects.Components
 {
index cd71ba783c562f4afa7959a5e4d1f26ce9548142..9c3d5de33f59cf94390e13592897f1c7f20dea9e 100644 (file)
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects.Components
index 1283e2bee8064ec51a387af751bdf0716124cdf4..2abf5c84cd22bd307a2b7fffabfcfb1c9a729536 100644 (file)
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects
index 0f0a99c0b3203645fb17e6c3c42765542159fc6e..e317bd2e4a0d13de6cbe7a2ad2b3a626caec385e 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Net.Messages;
+using Impostor.Api.Net.Messages;
+using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects
 {
index 87a196fe13e634de66f056d893321f6d5c459d33..5e23d17565511f61524589f2d3eb88ef3d8f0637 100644 (file)
@@ -1,7 +1,8 @@
 using System;
 using System.Collections.Generic;
+using Impostor.Api.Games;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.GameData.Objects.Components;
-using Impostor.Server.Games;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects
index d2533fa05b04f683d7daac68bc166ee9f95c99dd..bdfcdf4de7ce2a334a4b418ea3311aee24a2b8ab 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects
index 12c1054721e0f84a505095f82f1a4d29311375b4..6fc30bc09e0d1308a82d206dc35b8667e9db4375 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects
index 5da19a95ae017e356f103194594cc69089628b0c..821f495fe4bab03e97bdb746f24eedc0206848af 100644 (file)
@@ -1,6 +1,7 @@
 using System;
+using Impostor.Api.Games;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.GameData.Objects.Components;
-using Impostor.Server.Games;
 using Impostor.Server.Net.Messages;
 using Microsoft.Extensions.DependencyInjection;
 
index 8662983cbe1f0128279fc7450820b37c8e0bf4b2..17f9931db6a7b5a10afbd0b0ea0f076dfcbc4c35 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.GameData.Objects
index e045ac025003304bb86821a16023ab3225523a11..27370687dd72728fa5df31ef479350367f85c18d 100644 (file)
@@ -23,7 +23,6 @@
     <ItemGroup>
         <ProjectReference Include="..\Impostor.Api\Impostor.Api.csproj" />
         <ProjectReference Include="..\Impostor.Hazel\Impostor.Hazel.csproj" />
-        <ProjectReference Include="..\Impostor.Shared\Impostor.Shared.csproj" />
     </ItemGroup>
 
     <ItemGroup>
index 25075d355b29052c0c9b3496c29dd57ab315e02c..dec73df86d4236639b711143b405655d33f3bc15 100644 (file)
@@ -1,12 +1,13 @@
 using System;
 using System.Threading.Tasks;
+using Impostor.Api.Games;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Data;
-using Impostor.Server.Games;
 using Impostor.Server.Net.Hazel;
 using Impostor.Server.Net.Manager;
 using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth;
-using Impostor.Shared.Innersloth.Data;
 using Microsoft.Extensions.Logging;
 
 namespace Impostor.Server.Net
index c227d9bb7646fc7180d316194b7bdf9f33b5dfe3..4b34987a0ef065da321da04c47a07d2f2a2c3ea0 100644 (file)
@@ -1,4 +1,6 @@
-namespace Impostor.Server.Net
+using Impostor.Api.Net;
+
+namespace Impostor.Server.Net
 {
     internal abstract partial class ClientBase : IClient
     {
index 71baab46804ec706ca3d5abeeedae4608c28874e..ec2efcb9bd6ce0e6ae90ec76070671f6fd6e3ff4 100644 (file)
@@ -1,6 +1,7 @@
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Hazel;
 using Impostor.Server.Net.Messages;
 using Impostor.Server.Net.State;
index 324782d0d1341b848d8610c888859b0472583f8e..c7056d2d14d7a566cc133275e2107ad38166c1e0 100644 (file)
@@ -1,4 +1,6 @@
-namespace Impostor.Server.Net.Hazel
+using Impostor.Api.Net;
+
+namespace Impostor.Server.Net.Hazel
 {
     internal partial class HazelConnection : IConnection
     {
index 390c3bf26817b26ce50df59e017710884a14609c..e2694f8d31f94e14cb52aaf7c5f5521e327f43ab 100644 (file)
@@ -2,6 +2,7 @@
 using System.Net;
 using System.Threading.Tasks;
 using Hazel;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Hazel.Messages;
 using Impostor.Server.Net.Hazel.Messages;
 using Impostor.Server.Net.Messages;
index 3e560c7cb851c189a46cf0894992fc871c811201..84918350bf78ac9ea7b2ac563046951d554ba40e 100644 (file)
@@ -2,6 +2,7 @@
 using System.Buffers.Binary;
 using System.Runtime.CompilerServices;
 using System.Text;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.Hazel.Messages
index 1bde8f858be3560a9dd0cbb77e4badcb47b564a8..4c77514aa4fa449c1fdcff02f5d309fae5ea163b 100644 (file)
@@ -1,4 +1,6 @@
 using System.Threading.Tasks;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net;
 using Impostor.Server.Net.Messages;
 
index 2deddaf362616847a153218483fb0c78d9683662..3e4f6e2484642edc7383dbecdfa084cfc23889f3 100644 (file)
@@ -3,6 +3,8 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using Hazel;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net;
 using Impostor.Server.Net.Messages;
 using Impostor.Server.Net.State;
index 32ad51432a19085aa3bc643a60d8f87f45adede2..8799c4892fc37b6a969169645f7139307d586145 100644 (file)
@@ -1,5 +1,6 @@
 using System;
 using Hazel;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Hazel.Messages;
 using Impostor.Server.Net.Messages;
 
index 0d4031393007812782ed38bde309b7a9245c472a..c43cdfbb60cb4cef1c4fa92814fa8dbc814f2d6c 100644 (file)
@@ -1,7 +1,8 @@
 using System;
 using System.Net;
 using Hazel;
-using Impostor.Server.Games;
+using Impostor.Api.Games;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
 
 namespace Impostor.Server.Hazel.Messages
index ba065969aa38439a64af467bbb289a812abcbbad..6cbe5bf61f0caed3843c7a7f6f0a04acac002995 100644 (file)
@@ -1,4 +1,6 @@
 using System.Collections.Generic;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Manager;
 
 namespace Impostor.Server.Net.Manager
 {
index 23ee7bbd4a329044f81fbdae81bfc577193659ac..7a62fdeaf2b7e3be92ad112872ed084c09584f4b 100644 (file)
@@ -2,12 +2,14 @@
 using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Data;
 using Impostor.Server.Net.Factories;
 using Impostor.Server.Net.Hazel;
 using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth;
-using Impostor.Shared.Innersloth.Data;
 using Microsoft.Extensions.Logging;
 
 namespace Impostor.Server.Net.Manager
index 68b10cfc31b57d4ceaa745a4bb77f8becf7a0e26..8ddb19b5b0d3473d0e3c7ed7e9f5a353218766cf 100644 (file)
@@ -1,7 +1,7 @@
 using System.Collections.Generic;
 using System.Linq;
-using Impostor.Server.Games;
-using Impostor.Server.Games.Managers;
+using Impostor.Api.Games;
+using Impostor.Api.Games.Managers;
 
 namespace Impostor.Server.Net.Manager
 {
index 057c71662f9884eed287ade91b5b4870918002b6..d05eac8c90e6bb779d8f4c795fd0af57805d9924 100644 (file)
@@ -4,14 +4,15 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Net;
 using System.Threading.Tasks;
+using Impostor.Api;
+using Impostor.Api.Events;
+using Impostor.Api.Events.Managers;
+using Impostor.Api.Games;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Data;
 using Impostor.Server.Data;
-using Impostor.Server.Events;
-using Impostor.Server.Events.Managers;
-using Impostor.Server.Games;
 using Impostor.Server.Net.Redirector;
 using Impostor.Server.Net.State;
-using Impostor.Shared.Innersloth;
-using Impostor.Shared.Innersloth.Data;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Logging;
 using Microsoft.Extensions.Options;
index c1462e2cfad7743244aceb5aa77de10ebc3470a9..835424b892094fc593bd9253f810ee2e58bea78c 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Shared.Innersloth;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Net.Messages;
 
 namespace Impostor.Server.Net.Messages
 {
index 745d9f3c63ff80a1bfd3600f9f4e4e91679d3965..fb254b508538099e57d47e5122eb26a0c8ec8634 100644 (file)
@@ -1,5 +1,6 @@
 using System;
-using Impostor.Shared.Innersloth.Data;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net.Messages;
 
 namespace Impostor.Server.Net.Messages
 {
index bb06b6354e86725fbfeb1d6473dd4ad6b7ae9af8..e8e669e13d5b6ae8ebe7dda40775bc49c1197843 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Shared.Innersloth.Data;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net.Messages;
 
 namespace Impostor.Server.Net.Messages
 {
index 7fba0d7b4489c9f922c9a1a643d3e8db1614ddde..d1957dc2f00d13ce22d6c3f8d67d5da0792344d5 100644 (file)
@@ -1,4 +1,6 @@
-namespace Impostor.Server.Net.Messages
+using Impostor.Api.Net.Messages;
+
+namespace Impostor.Server.Net.Messages
 {
     internal static class Message07JoinedGame
     {
index ed3980aa94af3a7ab16158b7ab70483993aa6981..eedf1bd937441f8997822574a1278ee4b0a7bdf3 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Shared.Innersloth.Data;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net.Messages;
 
 namespace Impostor.Server.Net.Messages
 {
index 9a9c2093e892e8a11eea09b801abe6d352f4a780..4d36f20c85951340e35817afd9665076326620fa 100644 (file)
@@ -1,4 +1,6 @@
-namespace Impostor.Server.Net.Messages
+using Impostor.Api.Net.Messages;
+
+namespace Impostor.Server.Net.Messages
 {
     internal static class Message11KickPlayer
     {
index 2f1cd0326e04f224fe6093b61afda648e2095ecd..67b75b908a816dc15e574206d23bb1e350c5b352 100644 (file)
@@ -1,4 +1,6 @@
-namespace Impostor.Server.Net.Messages
+using Impostor.Api.Net.Messages;
+
+namespace Impostor.Server.Net.Messages
 {
     internal static class Message12WaitForHost
     {
index 17ba12f21abcc9a44de327d7dfbb4ca73440f386..3b8a092b54cd4e7a046cfd11c6b098c2901f82fa 100644 (file)
@@ -1,4 +1,5 @@
 using System.Net;
+using Impostor.Api.Net.Messages;
 
 namespace Impostor.Server.Net.Messages
 {
index 86e7f284dde205e46ef5ddd17393e2176b746a14..da8f6304aaa0ac107ceb6f2158d0d9e050b7bdb8 100644 (file)
@@ -1,6 +1,7 @@
 using System.Collections.Generic;
-using Impostor.Server.Games;
-using Impostor.Shared.Innersloth;
+using Impostor.Api.Games;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Net.Messages;
 
 namespace Impostor.Server.Net.Messages
 {
index c15f3294e97d472955f6458d6b3b72185f58523f..acdb9cf1088ba63ec7798f61a90c7d48505e760f 100644 (file)
@@ -1,10 +1,11 @@
 using System.Threading.Tasks;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Data;
 using Impostor.Server.Net.Hazel;
 using Impostor.Server.Net.Manager;
 using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth;
-using Impostor.Shared.Innersloth.Data;
 using Serilog;
 using ILogger = Serilog.ILogger;
 
index d1003e5db565c16e4945cd67f0a1be0574b83f56..b8b48f5a29d0bc451d997b16ab1f824017c97384 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
+using Impostor.Api.Net;
 
 namespace Impostor.Server.Net.State
 {
index 596760178d9a75d511d54172217c2bc65989419f..7d54f12b5402d63383aaef5505c5cfacdf5e7c5e 100644 (file)
@@ -1,4 +1,5 @@
 using System.Threading.Tasks;
+using Impostor.Api.Net;
 
 namespace Impostor.Server.Net.State
 {
index 96ba18a7f8c734c0030a61bac53572968e4af7ab..b90394f60db6f33166d0a4b49d7dfc07a0a84b34 100644 (file)
@@ -1,4 +1,5 @@
-using Impostor.Server.Games;
+using Impostor.Api.Games;
+using Impostor.Api.Net;
 
 namespace Impostor.Server.Net.State
 {
index d3577b3bbe24a295cecbd017a161a5482dc798ed..aff5ce624fb5cbeed5b9fa24ffc551064a403b56 100644 (file)
@@ -1,10 +1,10 @@
 using System;
 using System.Collections.Generic;
 using System.Threading.Tasks;
+using Impostor.Api.Innersloth.GameData;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.GameData;
 using Impostor.Server.GameData.Objects;
-using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth.GameData;
 using Microsoft.Extensions.DependencyInjection;
 
 namespace Impostor.Server.Net.State
index fdc2e8587dff6c091a479f8051a73a0ef41735ac..9a502b407290d98c1a7fba58a7134aca2921bfb8 100644 (file)
@@ -1,7 +1,9 @@
 using System.Threading.Tasks;
-using Impostor.Server.Games;
+using Impostor.Api.Games;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth.Data;
 
 namespace Impostor.Server.Net.State
 {
index 446668c2f240f645a6dc0d382b664a2c9e726cd3..2fc4f3cacc6e0a399e7d6e24c0ac805847a09751 100644 (file)
@@ -1,6 +1,8 @@
 using System.Linq;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth.Data;
 
 namespace Impostor.Server.Net.State
 {
index 710e62f2369d6df38db0b9e0643cd3ec7f444791..ab9dfbbdfdb0a29dc770944eef0f007013231071 100644 (file)
@@ -1,8 +1,10 @@
 using System.Linq;
 using System.Threading.Tasks;
-using Impostor.Server.Events;
-using Impostor.Server.Net.Messages;
-using Impostor.Shared.Innersloth.Data;
+using Impostor.Api;
+using Impostor.Api.Events;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 
 namespace Impostor.Server.Net.State
 {
index 8e3549c349397bc0153bc00a201be72ee3a2589f..4654c34acd15a6ae059a4b9b6e19f7c153326a36 100644 (file)
@@ -4,15 +4,17 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Net;
 using System.Threading.Tasks;
-using Impostor.Server.Events.Managers;
-using Impostor.Server.Games;
+using Impostor.Api.Events.Managers;
+using Impostor.Api.Games;
+using Impostor.Api.Innersloth;
+using Impostor.Api.Innersloth.Data;
+using Impostor.Api.Net;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Hazel;
 using Impostor.Server.Hazel.Messages;
 using Impostor.Server.Net.Manager;
 using Impostor.Server.Net.Messages;
 using Impostor.Server.Net.Redirector;
-using Impostor.Shared.Innersloth;
-using Impostor.Shared.Innersloth.Data;
 using Serilog;
 using ILogger = Serilog.ILogger;
 
index 4fc0997e405cf74c4a3cf5a96ff7cb7c8841d365..8a1bcfcccbb99e58e47d1bb992413572d9fb0f66 100644 (file)
@@ -4,6 +4,7 @@ using System.IO;
 using System.Linq;
 using System.Reflection;
 using System.Runtime.Loader;
+using Impostor.Api.Plugins;
 using Microsoft.Extensions.FileSystemGlobbing;
 using Microsoft.Extensions.Hosting;
 
index 16d4c30fb3941c1aa4bc07f0db99efc406687dd4..12c9588fa95ed00193fda7bd8e48c08197dabcbc 100644 (file)
@@ -1,8 +1,9 @@
 using System;
+using Impostor.Api.Events.Managers;
+using Impostor.Api.Games.Managers;
+using Impostor.Api.Net.Manager;
 using Impostor.Server.Data;
 using Impostor.Server.Events;
-using Impostor.Server.Events.Managers;
-using Impostor.Server.Games.Managers;
 using Impostor.Server.Hazel;
 using Impostor.Server.Net;
 using Impostor.Server.Net.Factories;
diff --git a/src/Impostor.Shared/Impostor.Shared.csproj b/src/Impostor.Shared/Impostor.Shared.csproj
deleted file mode 100644 (file)
index b63fd9f..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
-    <PropertyGroup>
-        <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
-        <DebugType Condition=" '$(Configuration)' == 'Release' ">None</DebugType>
-    </PropertyGroup>
-
-    <ItemGroup>
-        <PackageReference Include="System.Memory" Version="4.5.4" />
-    </ItemGroup>
-
-</Project>
diff --git a/src/Impostor.Shared/Innersloth/Data/AlterGameTags.cs b/src/Impostor.Shared/Innersloth/Data/AlterGameTags.cs
deleted file mode 100644 (file)
index c246183..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Impostor.Shared.Innersloth.Data
-{
-    public enum AlterGameTags : byte
-    {
-        ChangePrivacy = 1
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/Data/DisconnectReason.cs b/src/Impostor.Shared/Innersloth/Data/DisconnectReason.cs
deleted file mode 100644 (file)
index e2705b4..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-namespace Impostor.Shared.Innersloth.Data
-{
-    public enum DisconnectReason
-    {
-        ExitGame = 0,
-        // The game you tried to join is full.
-        // Check with the host to see if you can join next round.
-        GameFull = 1,
-        // The game you tried to join already started.
-        // Check with the host to see if you can join next round.
-        GameStarted = 2,
-        // Could not find the game you're looking for.
-        GameMissing = 3,
-        IncorrectGame = 18,
-        // For these a message can be given, specifying an empty message shows
-        // "An unknown error disconnected you from the server."
-        CustomMessage1 = 4,
-        Custom = 8,
-        // CustomMessage3 = 11,
-        // CustomMessage4 = 12,
-        // CustomMessage5 = 13,
-        // CustomMessage6 = 14,
-        // CustomMessage7 = 15,
-        // You are running an older version of the game.
-        // Please update to play with others.
-        IncorrectVersion = 5,
-        // You cannot rejoin that room.
-        // You were banned
-        Banned = 6,
-        // You can rejoin if the room hasn't started
-        // You were kicked
-        Kicked = 7,
-        // You were banned for hacking.
-        // Please stop.
-        Hacking = 10,
-        Destroy = 16,
-        // You disconnected from the host.
-        // If this happens often, check your WiFi strength.
-        //
-        // You disconnected from the server.
-        // If this happens often, check your network strength.
-        // This may also be a server issue.
-        Error = 17,
-        // The server stopped this game. Possibly due to inactivity.
-        ServerRequest = 19,
-        // The Among Us servers are overloaded.
-        // Sorry! Please try again later!
-        ServerFull = 20,
-        FocusLostBackground = 207,
-        IntentionalLeaving = 208,
-        FocusLost = 209,
-        NewConnection = 210
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/Data/GameKeywords.cs b/src/Impostor.Shared/Innersloth/Data/GameKeywords.cs
deleted file mode 100644 (file)
index daefefe..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-
-namespace Impostor.Shared.Innersloth.Data
-{
-    [Flags]
-    public enum GameKeywords : uint
-    {
-        All = 0,
-        Other = 1,
-        Spanish = 2,
-        Korean = 4,
-        Russian = 8,
-        Portuguese = 16,
-        Arabic = 32,
-        Filipone = 64,
-        Polish = 128,
-        English = 256
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/Data/GameStates.cs b/src/Impostor.Shared/Innersloth/Data/GameStates.cs
deleted file mode 100644 (file)
index 7f165e9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Impostor.Shared.Innersloth.Data
-{
-    public enum GameStates : byte
-    {
-        NotStarted = 0,
-        Started = 1,
-        Ended = 2,
-        Destroyed = 3
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/Data/MapFlags.cs b/src/Impostor.Shared/Innersloth/Data/MapFlags.cs
deleted file mode 100644 (file)
index 49d730c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace Impostor.Shared.Innersloth.Data
-{
-    [Flags]
-    public enum MapFlags
-    {
-        Skeld = 1,
-        MiraHQ = 2,
-        Polus = 4
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/FloatRange.cs b/src/Impostor.Shared/Innersloth/FloatRange.cs
deleted file mode 100644 (file)
index fc68e2d..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-using Impostor.Shared.Unity;
-
-namespace Impostor.Shared.Innersloth
-{
-    public class FloatRange
-    {
-        private readonly float _min;
-        private readonly float _max;
-
-        public FloatRange(float min, float max)
-        {
-            _min = min;
-            _max = max;
-        }
-
-        public float Width => _max - _min;
-
-        public float Lerp(float v) => Mathf.Lerp(_min, _max, v);
-
-        public float ReverseLerp(float t) => Mathf.Clamp((t - _min) / Width, 0.0f, 1f);
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/GameCodeParser.cs b/src/Impostor.Shared/Innersloth/GameCodeParser.cs
deleted file mode 100644 (file)
index 86af88e..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-using System;
-using System.Buffers.Binary;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace Impostor.Shared.Innersloth
-{
-    public static class GameCodeParser
-    {
-        private const string V2 = "QWXRTYLPESDFGHUJKZOCVBINMA";
-        private static readonly int[] V2Map = {
-            25,
-            21,
-            19,
-            10,
-            8,
-            11,
-            12,
-            13,
-            22,
-            15,
-            16,
-            6,
-            24,
-            23,
-            18,
-            7,
-            0,
-            3,
-            9,
-            4,
-            14,
-            20,
-            1,
-            2,
-            5,
-            17
-        };
-        private static readonly RNGCryptoServiceProvider Random = new RNGCryptoServiceProvider();
-        
-        public static string IntToGameName(int input)
-        {
-            // V2.
-            if (input < -1)
-            {
-                return IntToGameNameV2(input);
-            }
-
-            // V1.
-            Span<byte> code = stackalloc byte[4];
-            BinaryPrimitives.WriteInt32LittleEndian(code, input);
-#if NETSTANDARD2_0
-            return Encoding.UTF8.GetString(code.Slice(0, 4).ToArray());
-#else
-            return Encoding.UTF8.GetString(code.Slice(0, 4));
-#endif
-        }
-
-        private static string IntToGameNameV2(int input)
-        {
-            var a = input & 0x3FF;
-            var b = (input >> 10) & 0xFFFFF;
-
-            return new string(new []
-            {
-                V2[a % 26],
-                V2[a / 26],
-                V2[b % 26],
-                V2[b / 26 % 26],
-                V2[b / (26 * 26) % 26],
-                V2[b / (26 * 26 * 26) % 26]
-            });
-        }
-
-        public static int GameNameToInt(string code)
-        {
-            var upper = code.ToUpperInvariant();
-            if (upper.Any(x => !char.IsLetter(x)))
-            {
-                return -1;
-            }
-            
-            var len = code.Length;
-            if (len == 6)
-            {
-                return GameNameToIntV2(upper);
-            }
-
-            if (len == 4)
-            {
-                return code[0] | ((code[1] | ((code[2] | (code[3] << 8)) << 8)) << 8);
-            }
-            
-            return -1;
-        }
-        
-        private static int GameNameToIntV2(string code)
-        {
-            var a = V2Map[code[0] - 65];
-            var b = V2Map[code[1] - 65];
-            var c = V2Map[code[2] - 65];
-            var d = V2Map[code[3] - 65];
-            var e = V2Map[code[4] - 65];
-            var f = V2Map[code[5] - 65];
-
-            var one = (a + 26 * b) & 0x3FF;
-            var two = (c + 26 * (d + 26 * (e + 26 * f)));
-
-            return (int) (one | ((two << 10) & 0x3FFFFC00) | 0x80000000);
-        }
-
-        public static int GenerateCode(int len)
-        {
-            if (len != 4 && len != 6)
-            {
-                throw new ArgumentException("should be 4 or 6", nameof(len));
-            }
-            
-            // Generate random bytes.
-#if NETSTANDARD2_0
-            var data = new byte[len];
-#else
-            Span<byte> data = stackalloc byte[len];
-#endif
-            Random.GetBytes(data);
-            
-            // Convert to their char representation.
-            Span<char> dataChar = stackalloc char[len];
-            for (var i = 0; i < len; i++)
-            {
-                dataChar[i] = V2[V2Map[data[i] % 26]];
-            }
-
-#if NETSTANDARD2_0
-            return GameNameToInt(new string(dataChar.ToArray()));
-#else
-            return GameNameToInt(new string(dataChar));
-#endif
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/GameData/GameDataTag.cs b/src/Impostor.Shared/Innersloth/GameData/GameDataTag.cs
deleted file mode 100644 (file)
index 757ab5e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Impostor.Shared.Innersloth.GameData
-{
-    public static class GameDataTag
-    {
-        public const byte DataFlag = 1;
-        public const byte RpcFlag = 2;
-        public const byte SpawnFlag = 4;
-        public const byte DespawnFlag = 5;
-        public const byte SceneChangeFlag = 6;
-        public const byte ReadyFlag = 7;
-        public const byte ChangeSettingsFlag = 8;
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/GameOptionsData.cs b/src/Impostor.Shared/Innersloth/GameOptionsData.cs
deleted file mode 100644 (file)
index 375b6ee..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-using System;
-using System.IO;
-using Impostor.Shared.Innersloth.Data;
-
-namespace Impostor.Shared.Innersloth
-{
-    public class GameOptionsData
-    {
-        public byte Version { get; set; }
-        public byte MaxPlayers { get; set; }
-        public GameKeywords Keywords { get; set; }
-        public byte MapId { get; set; }
-        public float PlayerSpeedMod { get; set; }
-        public float CrewLightMod { get; set; }
-        public float ImpostorLightMod { get; set; }
-        public float KillCooldown { get; set; }
-        public int NumCommonTasks { get; set; }
-        public int NumLongTasks { get; set; }
-        public int NumShortTasks { get; set; }
-        public int NumEmergencyMeetings { get; set; }
-        public int EmergencyCooldown { get; set; }
-        public int NumImpostors { get; set; }
-        public bool GhostsDoTasks { get; set; }
-        public int KillDistance { get; set; }
-        public int DiscussionTime { get; set; }
-        public int VotingTime { get; set; }
-        public bool ConfirmImpostor { get; set; }
-        public bool VisualTasks { get; set; }
-        public bool IsDefaults { get; set; }
-        
-        public void Serialize(BinaryWriter writer, byte version)
-        {
-            writer.Write((byte) version);
-            writer.Write((byte) MaxPlayers);
-            writer.Write((uint) Keywords);
-            writer.Write((byte) MapId);
-            writer.Write((float) PlayerSpeedMod);
-            writer.Write((float) CrewLightMod);
-            writer.Write((float) ImpostorLightMod);
-            writer.Write((float) KillCooldown);
-            writer.Write((byte) NumCommonTasks);
-            writer.Write((byte) NumLongTasks);
-            writer.Write((byte) NumShortTasks);
-            writer.Write((int) NumEmergencyMeetings);
-            writer.Write((byte) NumImpostors);
-            writer.Write((byte) KillDistance);
-            writer.Write((uint) DiscussionTime);
-            writer.Write((uint) VotingTime);
-            writer.Write((bool) IsDefaults);
-            if (version > 1)
-            {
-                writer.Write((byte) EmergencyCooldown);
-            }
-
-            if (version > 2)
-            {
-                writer.Write((bool) ConfirmImpostor);
-                writer.Write((bool) VisualTasks);
-            }
-        }
-
-        public static GameOptionsData Deserialize(ReadOnlyMemory<byte> bytes)
-        {
-            // TODO: Remove memory allocation.
-
-            using (var stream = new MemoryStream(bytes.ToArray()))
-            using (var reader = new BinaryReader(stream))
-            {
-                var result = new GameOptionsData();
-
-                result.Version = reader.ReadByte();
-                result.MaxPlayers = reader.ReadByte();
-                result.Keywords = (GameKeywords) reader.ReadUInt32();
-                result.MapId = reader.ReadByte();
-                result.PlayerSpeedMod = reader.ReadSingle();
-                result.CrewLightMod = reader.ReadSingle();
-                result.ImpostorLightMod = reader.ReadSingle();
-                result.KillCooldown = reader.ReadSingle();
-                result.NumCommonTasks = reader.ReadByte();
-                result.NumLongTasks = reader.ReadByte();
-                result.NumShortTasks = reader.ReadByte();
-                result.NumEmergencyMeetings = reader.ReadInt32();
-                result.NumImpostors = reader.ReadByte();
-                result.KillDistance = reader.ReadByte();
-                result.DiscussionTime = reader.ReadInt32();
-                result.VotingTime = reader.ReadInt32();
-                result.IsDefaults = reader.ReadBoolean();
-
-                if (result.Version > 1)
-                {
-                    result.EmergencyCooldown = reader.ReadByte();
-                }
-
-                if (result.Version > 2)
-                {
-                    result.ConfirmImpostor = reader.ReadBoolean();
-                    result.VisualTasks = reader.ReadBoolean();
-                }
-                
-                return result;
-            }
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/GameVersion.cs b/src/Impostor.Shared/Innersloth/GameVersion.cs
deleted file mode 100644 (file)
index 7377b79..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Impostor.Shared.Innersloth
-{
-    public class GameVersion
-    {
-        public static int GetVersion(int year, int month, int day, int rev = 0)
-        {
-            return (year * 25000) + (month * 1800) + (day * 50) + rev;
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/RegionInfo.cs b/src/Impostor.Shared/Innersloth/RegionInfo.cs
deleted file mode 100644 (file)
index 90c6da1..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-
-namespace Impostor.Shared.Innersloth
-{
-    public class RegionInfo
-    {
-        public RegionInfo(string name, string ping, IReadOnlyList<ServerInfo> servers)
-        {
-            Name = name;
-            Ping = ping;
-            Servers = servers;
-        }
-
-        public string Name { get; }
-        public string Ping { get; }
-        public IReadOnlyList<ServerInfo> Servers { get; }
-
-        public void Serialize(BinaryWriter writer)
-        {
-            writer.Write(0);
-            writer.Write(Name);
-            writer.Write(Ping);
-            writer.Write(Servers.Count);
-
-            foreach (var server in Servers)
-            {
-                server.Serialize(writer);
-            }
-        }
-
-        public static RegionInfo Deserialize(BinaryReader reader)
-        {
-            var unknown = reader.ReadInt32();
-            var name = reader.ReadString();
-            var ping = reader.ReadString();
-            var servers = new List<ServerInfo>();
-            var serverCount = reader.ReadInt32();
-
-            for (var i = 0; i < serverCount; i++)
-            {
-                servers.Add(ServerInfo.Deserialize(reader));
-            }
-
-            return new RegionInfo(name, ping, servers);
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Innersloth/ServerInfo.cs b/src/Impostor.Shared/Innersloth/ServerInfo.cs
deleted file mode 100644 (file)
index c76a7e4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-using System.IO;
-using System.Net;
-
-namespace Impostor.Shared.Innersloth
-{
-    public class ServerInfo
-    {
-        public string Name { get; }
-        public string Ip { get; }
-        public ushort Port { get; }
-
-        public ServerInfo(string name, string ip, ushort port)
-        {
-            Name = name;
-            Ip = ip;
-            Port = port;
-        }
-        
-        public void Serialize(BinaryWriter writer)
-        {
-            writer.Write(Name);
-            writer.Write(IPAddress.Parse(Ip).GetAddressBytes());
-            writer.Write(Port);
-            writer.Write(0);
-        }
-
-        public static ServerInfo Deserialize(BinaryReader reader)
-        {
-            var name = reader.ReadString();
-            var ip = new IPAddress(reader.ReadBytes(4)).ToString();
-            var port = reader.ReadUInt16();
-            var unknown = reader.ReadInt32();
-            
-            return new ServerInfo(name, ip, port);
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Unity/Mathf.cs b/src/Impostor.Shared/Unity/Mathf.cs
deleted file mode 100644 (file)
index e608bbb..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-namespace Impostor.Shared.Unity
-{
-    public static class Mathf
-    {
-        /// <summary>
-        ///   <para>Clamps the given value between the given minimum float and maximum float values.  Returns the given value if it is within the min and max range.</para>
-        /// </summary>
-        /// <param name="value">The floating point value to restrict inside the range defined by the min and max values.</param>
-        /// <param name="min">The minimum floating point value to compare against.</param>
-        /// <param name="max">The maximum floating point value to compare against.</param>
-        /// <returns>
-        ///   <para>The float result between the min and max values.</para>
-        /// </returns>
-        public static float Clamp(float value, float min, float max)
-        {
-            if ((double) value < (double) min)
-                value = min;
-            else if ((double) value > (double) max)
-                value = max;
-            return value;
-        }
-
-        /// <summary>
-        ///   <para>Clamps value between 0 and 1 and returns value.</para>
-        /// </summary>
-        /// <param name="value"></param>
-        public static float Clamp01(float value)
-        {
-            if ((double) value < 0.0)
-                return 0.0f;
-            return (double) value > 1.0 ? 1f : value;
-        }
-
-        /// <summary>
-        ///   <para>Linearly interpolates between a and b by t.</para>
-        /// </summary>
-        /// <param name="a">The start value.</param>
-        /// <param name="b">The end value.</param>
-        /// <param name="t">The interpolation value between the two floats.</param>
-        /// <returns>
-        ///   <para>The interpolated float result between the two float values.</para>
-        /// </returns>
-        public static float Lerp(float a, float b, float t) => a + (b - a) * Mathf.Clamp01(t);
-    }
-}
\ No newline at end of file
diff --git a/src/Impostor.Shared/Utils/HexUtils.cs b/src/Impostor.Shared/Utils/HexUtils.cs
deleted file mode 100644 (file)
index 04e497b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-using System;
-using System.Text;
-
-namespace Impostor.Shared.Utils
-{
-    public static class HexUtils
-    {
-        public static string HexDump(byte[] bytes, int bytesPerLine = 16)
-        {
-            if (bytes == null) return "<null>";
-            int bytesLength = bytes.Length;
-
-            char[] HexChars = "0123456789ABCDEF".ToCharArray();
-
-            int firstHexColumn =
-                  8                   // 8 characters for the address
-                + 3;                  // 3 spaces
-
-            int firstCharColumn = firstHexColumn
-                + bytesPerLine * 3       // - 2 digit for the hexadecimal value and 1 space
-                + (bytesPerLine - 1) / 8 // - 1 extra space every 8 characters from the 9th
-                + 2;                  // 2 spaces 
-
-            int lineLength = firstCharColumn
-                + bytesPerLine           // - characters to show the ascii value
-                + Environment.NewLine.Length; // Carriage return and line feed (should normally be 2)
-
-            char[] line = (new String(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray();
-            int expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine;
-            StringBuilder result = new StringBuilder(expectedLines * lineLength);
-
-            for (int i = 0; i < bytesLength; i += bytesPerLine)
-            {
-                line[0] = HexChars[(i >> 28) & 0xF];
-                line[1] = HexChars[(i >> 24) & 0xF];
-                line[2] = HexChars[(i >> 20) & 0xF];
-                line[3] = HexChars[(i >> 16) & 0xF];
-                line[4] = HexChars[(i >> 12) & 0xF];
-                line[5] = HexChars[(i >> 8) & 0xF];
-                line[6] = HexChars[(i >> 4) & 0xF];
-                line[7] = HexChars[(i >> 0) & 0xF];
-
-                int hexColumn = firstHexColumn;
-                int charColumn = firstCharColumn;
-
-                for (int j = 0; j < bytesPerLine; j++)
-                {
-                    if (j > 0 && (j & 7) == 0) hexColumn++;
-                    if (i + j >= bytesLength)
-                    {
-                        line[hexColumn] = ' ';
-                        line[hexColumn + 1] = ' ';
-                        line[charColumn] = ' ';
-                    }
-                    else
-                    {
-                        byte b = bytes[i + j];
-                        line[hexColumn] = HexChars[(b >> 4) & 0xF];
-                        line[hexColumn + 1] = HexChars[b & 0xF];
-                        line[charColumn] = (b < 32 ? '·' : (char)b);
-                    }
-                    hexColumn += 3;
-                    charColumn++;
-                }
-                result.Append(line);
-            }
-            return result.ToString();
-        }
-    }
-}
\ No newline at end of file
index 90ac515d280b3514b79ff052a5f3726e54b00390..93321e21b911a95b7a952d01150cd982b6f3b4f7 100644 (file)
@@ -1,4 +1,4 @@
-using Impostor.Shared.Innersloth;
+using Impostor.Api.Innersloth;
 using Xunit;
 
 namespace Impostor.Tests
index 84cece6f2518b3912ae17e90db1f21783c495387..840fde333b1cfd32c9a92b9c1976f373d22e0620 100644 (file)
@@ -1,4 +1,5 @@
 using Hazel;
+using Impostor.Api.Net.Messages;
 using Impostor.Server.Net.Hazel.Messages;
 using Impostor.Server.Net.Messages;
 using Xunit;
index dba3d7f8a73a1ee1a0775ce6626f8214ded792bc..e62127176974dade3f312f5c937dd00ef798de45 100644 (file)
@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio Version 16
 VisualStudioVersion = 16.0.30503.244
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Shared", "Impostor.Shared\Impostor.Shared.csproj", "{1D109A96-FADF-41B9-A845-457A7A5C0C5A}"
-EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Impostor.Tests", "Impostor.Tests\Impostor.Tests.csproj", "{C1385C67-A7DD-46D2-80F6-FA428B85FB22}"
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{56DD9707-D811-4056-9E2C-8A9CC2479B07}"
@@ -45,14 +43,6 @@ Global
                {1B0390AF-A4F3-4FE4-B093-708B0135C0B3}.Release|Any CPU.Build.0 = Release|Any CPU
                {1B0390AF-A4F3-4FE4-B093-708B0135C0B3}.Release|x86.ActiveCfg = Release|Any CPU
                {1B0390AF-A4F3-4FE4-B093-708B0135C0B3}.Release|x86.Build.0 = Release|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Debug|x86.ActiveCfg = Debug|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Debug|x86.Build.0 = Debug|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Release|Any CPU.Build.0 = Release|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Release|x86.ActiveCfg = Release|Any CPU
-               {1D109A96-FADF-41B9-A845-457A7A5C0C5A}.Release|x86.Build.0 = Release|Any CPU
                {C1385C67-A7DD-46D2-80F6-FA428B85FB22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
                {C1385C67-A7DD-46D2-80F6-FA428B85FB22}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {C1385C67-A7DD-46D2-80F6-FA428B85FB22}.Debug|x86.ActiveCfg = Debug|Any CPU