From: js6pak Date: Wed, 24 Mar 2021 15:57:11 +0000 (+0100) Subject: Code cleanup X-Git-Tag: v1.3.0~3^2~6 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=e90ba734ab05f993ea791ef700eb852bdf0a179f;p=rhonda%2Fimpostor.git Code cleanup --- diff --git a/src/Impostor.Api/Events/Announcements/IAnnouncementRequestEvent.cs b/src/Impostor.Api/Events/Announcements/IAnnouncementRequestEvent.cs index b4eaa01..a0e5445 100644 --- a/src/Impostor.Api/Events/Announcements/IAnnouncementRequestEvent.cs +++ b/src/Impostor.Api/Events/Announcements/IAnnouncementRequestEvent.cs @@ -3,40 +3,40 @@ using Impostor.Api.Innersloth; namespace Impostor.Api.Events.Announcements { /// - /// Event fired after client requests a announcement. + /// Event fired after client requests a announcement. /// public interface IAnnouncementRequestEvent : IEvent { public interface IResponse { /// - /// Gets or sets FreeWeekendState, currently unused by the client. + /// Gets or sets FreeWeekendState, currently unused by the client. /// public FreeWeekendState FreeWeekendState { get; set; } /// - /// Gets or sets a value indicating whether announcement should be loaded from client's cache, can save some bytes. + /// Gets or sets a value indicating whether announcement should be loaded from client's cache, can save some bytes. /// public bool UseCached { get; set; } /// - /// Gets or sets announcement, should be null when is set to true. + /// Gets or sets announcement, should be null when is set to true. /// public Announcement? Announcement { get; set; } } /// - /// Gets client's last announcement id. + /// Gets client's last announcement id. /// public int Id { get; } /// - /// Gets client's language. + /// Gets client's language. /// public Language Language { get; } /// - /// Gets or sets plugin made response. + /// Gets or sets plugin made response. /// public IResponse Response { get; set; } } diff --git a/src/Impostor.Api/Events/Attributes/EventListenerAttribute.cs b/src/Impostor.Api/Events/Attributes/EventListenerAttribute.cs index b31d2d1..9289fa5 100644 --- a/src/Impostor.Api/Events/Attributes/EventListenerAttribute.cs +++ b/src/Impostor.Api/Events/Attributes/EventListenerAttribute.cs @@ -27,8 +27,8 @@ namespace Impostor.Api.Events public Type? Event { get; set; } /// - /// If set to true, the listener will be called regardless of the . + /// If set to true, the listener will be called regardless of the . /// public bool IgnoreCancelled { get; set; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Events/Game/IGameCreatedEvent.cs b/src/Impostor.Api/Events/Game/IGameCreatedEvent.cs index ef45f1d..48c8d7c 100644 --- a/src/Impostor.Api/Events/Game/IGameCreatedEvent.cs +++ b/src/Impostor.Api/Events/Game/IGameCreatedEvent.cs @@ -3,7 +3,7 @@ namespace Impostor.Api.Events { /// - /// Called whenever a new is created. + /// Called whenever a new is created. /// public interface IGameCreatedEvent : IGameEvent { diff --git a/src/Impostor.Api/Events/Game/IGameDestroyedEvent.cs b/src/Impostor.Api/Events/Game/IGameDestroyedEvent.cs index 7ff7b46..e598aae 100644 --- a/src/Impostor.Api/Events/Game/IGameDestroyedEvent.cs +++ b/src/Impostor.Api/Events/Game/IGameDestroyedEvent.cs @@ -3,7 +3,7 @@ namespace Impostor.Api.Events { /// - /// Called whenever a new is destroyed. + /// Called whenever a new is destroyed. /// public interface IGameDestroyedEvent : IGameEvent { diff --git a/src/Impostor.Api/Events/Game/IGameEvent.cs b/src/Impostor.Api/Events/Game/IGameEvent.cs index c9ae579..c188af3 100644 --- a/src/Impostor.Api/Events/Game/IGameEvent.cs +++ b/src/Impostor.Api/Events/Game/IGameEvent.cs @@ -5,7 +5,7 @@ namespace Impostor.Api.Events public interface IGameEvent : IEvent { /// - /// Gets the this event belongs to. + /// Gets the this event belongs to. /// IGame Game { get; } } diff --git a/src/Impostor.Api/Events/Game/IGameStartingEvent.cs b/src/Impostor.Api/Events/Game/IGameStartingEvent.cs index 5998bf2..3ba450e 100644 --- a/src/Impostor.Api/Events/Game/IGameStartingEvent.cs +++ b/src/Impostor.Api/Events/Game/IGameStartingEvent.cs @@ -3,7 +3,7 @@ /// /// Called when the game is going to start. /// When this is called, not all players are initialized properly yet. - /// If you want to get correct player states, use . + /// If you want to get correct player states, use . /// public interface IGameStartingEvent : IGameEvent { diff --git a/src/Impostor.Api/Events/Game/Player/IPlayerCompletedTaskEvent.cs b/src/Impostor.Api/Events/Game/Player/IPlayerCompletedTaskEvent.cs index 78ccd2d..a5e3228 100644 --- a/src/Impostor.Api/Events/Game/Player/IPlayerCompletedTaskEvent.cs +++ b/src/Impostor.Api/Events/Game/Player/IPlayerCompletedTaskEvent.cs @@ -1,5 +1,4 @@ -using Impostor.Api.Innersloth; -using Impostor.Api.Net.Inner.Objects; +using Impostor.Api.Net.Inner.Objects; namespace Impostor.Api.Events.Player { diff --git a/src/Impostor.Api/Events/Game/Player/IPlayerEvent.cs b/src/Impostor.Api/Events/Game/Player/IPlayerEvent.cs index 247fe64..d8269ff 100644 --- a/src/Impostor.Api/Events/Game/Player/IPlayerEvent.cs +++ b/src/Impostor.Api/Events/Game/Player/IPlayerEvent.cs @@ -6,14 +6,14 @@ namespace Impostor.Api.Events.Player public interface IPlayerEvent : IGameEvent { /// - /// Gets the that triggered this . + /// Gets the that triggered this . /// IClientPlayer ClientPlayer { get; } /// - /// Gets the networked that triggered this . - /// This belongs to the . + /// Gets the networked that triggered this . + /// This belongs to the . /// IInnerPlayerControl PlayerControl { get; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Events/IEvent.cs b/src/Impostor.Api/Events/IEvent.cs index 796898e..3bdb3a6 100644 --- a/src/Impostor.Api/Events/IEvent.cs +++ b/src/Impostor.Api/Events/IEvent.cs @@ -3,4 +3,4 @@ public interface IEvent { } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Events/IEventCancelable.cs b/src/Impostor.Api/Events/IEventCancelable.cs index 319f02a..d6d1ca6 100644 --- a/src/Impostor.Api/Events/IEventCancelable.cs +++ b/src/Impostor.Api/Events/IEventCancelable.cs @@ -7,4 +7,4 @@ /// bool IsCancelled { get; set; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Events/IEventListener.cs b/src/Impostor.Api/Events/IEventListener.cs index 76392fc..f3e8e41 100644 --- a/src/Impostor.Api/Events/IEventListener.cs +++ b/src/Impostor.Api/Events/IEventListener.cs @@ -3,4 +3,4 @@ public interface IEventListener { } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Events/Managers/IEventManager.cs b/src/Impostor.Api/Events/Managers/IEventManager.cs index 07a7f7c..35fb9bb 100644 --- a/src/Impostor.Api/Events/Managers/IEventManager.cs +++ b/src/Impostor.Api/Events/Managers/IEventManager.cs @@ -16,20 +16,20 @@ namespace Impostor.Api.Events.Managers where TListener : IEventListener; /// - /// Returns true if an event with the type is registered. + /// Returns true if an event with the type is registered. /// - /// True if the is registered. + /// True if the is registered. /// Type of the event. bool IsRegistered() where TEvent : IEvent; /// - /// Call all the event listeners for the type . + /// Call all the event listeners for the type . /// /// The event argument. /// Type of the event. - /// A representing the asynchronous operation. + /// A representing the asynchronous operation. ValueTask CallAsync(TEvent @event) where TEvent : IEvent; } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Extensions/SpanReaderExtensions.cs b/src/Impostor.Api/Extensions/SpanReaderExtensions.cs index c103ee7..242f054 100644 --- a/src/Impostor.Api/Extensions/SpanReaderExtensions.cs +++ b/src/Impostor.Api/Extensions/SpanReaderExtensions.cs @@ -5,7 +5,7 @@ using System.Runtime.CompilerServices; namespace Impostor.Api { /// - /// Priovides a StreamReader-like api throught extensions + /// Priovides a StreamReader-like api throught extensions /// public static class SpanReaderExtensions { @@ -53,7 +53,7 @@ namespace Impostor.Api } /// - /// Advances the position of by the size of . + /// Advances the position of by the size of . /// /// Type that will be read. /// input "stream"/span. @@ -67,4 +67,4 @@ namespace Impostor.Api return original; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Extensions/SystemTypesExtensions.cs b/src/Impostor.Api/Extensions/SystemTypesExtensions.cs index 68f1efd..4238b4d 100644 --- a/src/Impostor.Api/Extensions/SystemTypesExtensions.cs +++ b/src/Impostor.Api/Extensions/SystemTypesExtensions.cs @@ -9,4 +9,4 @@ namespace Impostor.Api return SystemTypeHelpers.Names[(int)type]; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Games/Extensions/GameExtensions.cs b/src/Impostor.Api/Games/Extensions/GameExtensions.cs index a736978..e30050f 100644 --- a/src/Impostor.Api/Games/Extensions/GameExtensions.cs +++ b/src/Impostor.Api/Games/Extensions/GameExtensions.cs @@ -39,4 +39,4 @@ namespace Impostor.Api.Games return game.SendToAsync(writer, player.Client); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Games/Extensions/GameManagerExtensions.cs b/src/Impostor.Api/Games/Extensions/GameManagerExtensions.cs index 6a95b3d..de9a066 100644 --- a/src/Impostor.Api/Games/Extensions/GameManagerExtensions.cs +++ b/src/Impostor.Api/Games/Extensions/GameManagerExtensions.cs @@ -11,4 +11,4 @@ namespace Impostor.Api.Games return manager.Games.Count(game => map.HasFlag((MapFlags)(1 << (byte)game.Options.Map))); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Games/GameCode.cs b/src/Impostor.Api/Games/GameCode.cs index 2c30e7e..e24c28a 100644 --- a/src/Impostor.Api/Games/GameCode.cs +++ b/src/Impostor.Api/Games/GameCode.cs @@ -48,19 +48,19 @@ namespace Impostor.Api.Games public static GameCode From(string value) => new GameCode(value); - /// + /// public bool Equals(GameCode other) { return Code == other.Code && Value == other.Value; } - /// + /// public override bool Equals(object? obj) { return obj is GameCode other && Equals(other); } - /// + /// public override int GetHashCode() { return HashCode.Combine(Code, Value); @@ -71,4 +71,4 @@ namespace Impostor.Api.Games return Code; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Games/GameJoinError.cs b/src/Impostor.Api/Games/GameJoinError.cs index 4889ea9..7fcb0f9 100644 --- a/src/Impostor.Api/Games/GameJoinError.cs +++ b/src/Impostor.Api/Games/GameJoinError.cs @@ -41,8 +41,8 @@ /// Custom error by a plugin. /// /// - /// A custom message can be set in . + /// A custom message can be set in . /// Custom, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Games/GameJoinResult.cs b/src/Impostor.Api/Games/GameJoinResult.cs index b33a2b6..4b25c8f 100644 --- a/src/Impostor.Api/Games/GameJoinResult.cs +++ b/src/Impostor.Api/Games/GameJoinResult.cs @@ -45,4 +45,4 @@ namespace Impostor.Api.Games return new GameJoinResult(error); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Games/IGame.cs b/src/Impostor.Api/Games/IGame.cs index 58e9208..ecc11f8 100644 --- a/src/Impostor.Api/Games/IGame.cs +++ b/src/Impostor.Api/Games/IGame.cs @@ -29,7 +29,7 @@ namespace Impostor.Api.Games bool IsPublic { get; } /// - /// Gets or sets display name on game list. + /// Gets or sets display name on game list. /// string? DisplayName { get; set; } @@ -43,28 +43,27 @@ namespace Impostor.Api.Games where T : IInnerNetObject; /// - /// Adds an to the ban list of this game. - /// Prevents all future joins from this . - /// - /// This does not kick the player with that from the lobby. + /// Adds an to the ban list of this game. + /// Prevents all future joins from this . + /// This does not kick the player with that from the lobby. /// /// - /// The to ban. + /// The to ban. /// void BanIp(IPAddress ipAddress); /// - /// Syncs the internal to all players. + /// Syncs the internal to all players. /// Necessary to do if you modified it, otherwise it won't be used. /// - /// A representing the asynchronous operation. + /// A representing the asynchronous operation. ValueTask SyncSettingsAsync(); /// /// Sets game's privacy. /// /// Privacy to set. - /// A representing the asynchronous operation. + /// A representing the asynchronous operation. ValueTask SetPrivacyAsync(bool isPublic); /// @@ -72,7 +71,7 @@ namespace Impostor.Api.Games /// /// Message to send. /// Required limbo state of the player. - /// A representing the asynchronous operation. + /// A representing the asynchronous operation. ValueTask SendToAllAsync(IMessageWriter writer, LimboStates states = LimboStates.NotLimbo); /// @@ -81,7 +80,7 @@ namespace Impostor.Api.Games /// Message to send. /// The player to exclude from sending the message. /// Required limbo state of the player. - /// A representing the asynchronous operation. + /// A representing the asynchronous operation. ValueTask SendToAllExceptAsync(IMessageWriter writer, int senderId, LimboStates states = LimboStates.NotLimbo); /// @@ -89,7 +88,7 @@ namespace Impostor.Api.Games /// /// Message to send. /// ID of the client. - /// A representing the asynchronous operation. + /// A representing the asynchronous operation. ValueTask SendToAsync(IMessageWriter writer, int id); } } diff --git a/src/Impostor.Api/Games/IGameCodeFactory.cs b/src/Impostor.Api/Games/IGameCodeFactory.cs index f264fe0..38f047f 100644 --- a/src/Impostor.Api/Games/IGameCodeFactory.cs +++ b/src/Impostor.Api/Games/IGameCodeFactory.cs @@ -4,4 +4,4 @@ { GameCode Create(); } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Games/Managers/IGameManager.cs b/src/Impostor.Api/Games/Managers/IGameManager.cs index 7ee403f..cdf8558 100644 --- a/src/Impostor.Api/Games/Managers/IGameManager.cs +++ b/src/Impostor.Api/Games/Managers/IGameManager.cs @@ -12,4 +12,4 @@ namespace Impostor.Api.Games.Managers ValueTask CreateAsync(GameOptionsData options); } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/AlterGameTags.cs b/src/Impostor.Api/Innersloth/AlterGameTags.cs index 46d1b2e..a1d9c42 100644 --- a/src/Impostor.Api/Innersloth/AlterGameTags.cs +++ b/src/Impostor.Api/Innersloth/AlterGameTags.cs @@ -4,4 +4,4 @@ { ChangePrivacy = 1, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/ChatNoteType.cs b/src/Impostor.Api/Innersloth/ChatNoteType.cs index c163601..697b031 100644 --- a/src/Impostor.Api/Innersloth/ChatNoteType.cs +++ b/src/Impostor.Api/Innersloth/ChatNoteType.cs @@ -4,4 +4,4 @@ { DidVote = 0, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/DeathReason.cs b/src/Impostor.Api/Innersloth/DeathReason.cs index a07ac05..8b8a430 100644 --- a/src/Impostor.Api/Innersloth/DeathReason.cs +++ b/src/Impostor.Api/Innersloth/DeathReason.cs @@ -6,4 +6,4 @@ Kill = 1, Disconnect = 2, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/GameKeywords.cs b/src/Impostor.Api/Innersloth/GameKeywords.cs index bbb463f..4b3c670 100644 --- a/src/Impostor.Api/Innersloth/GameKeywords.cs +++ b/src/Impostor.Api/Innersloth/GameKeywords.cs @@ -16,4 +16,4 @@ namespace Impostor.Api.Innersloth Polish = 128, English = 256, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/GameOptionsData.cs b/src/Impostor.Api/Innersloth/GameOptionsData.cs index 3d64844..5530c88 100644 --- a/src/Impostor.Api/Innersloth/GameOptionsData.cs +++ b/src/Impostor.Api/Innersloth/GameOptionsData.cs @@ -7,130 +7,130 @@ namespace Impostor.Api.Innersloth public class GameOptionsData { /// - /// The latest major version of the game client. + /// The latest major version of the game client. /// public const int LatestVersion = 4; /// - /// Gets or sets host's version of the game. + /// Gets or sets host's version of the game. /// public byte Version { get; set; } = LatestVersion; /// - /// Gets or sets the maximum amount of players for this lobby. + /// Gets or sets the maximum amount of players for this lobby. /// public byte MaxPlayers { get; set; } = 10; /// - /// Gets or sets the language of the lobby as per enum. + /// Gets or sets the language of the lobby as per enum. /// public GameKeywords Keywords { get; set; } = GameKeywords.English; /// - /// Gets or sets the Map selected for this lobby. + /// Gets or sets the Map selected for this lobby. /// public MapTypes Map { get; set; } = MapTypes.Skeld; /// - /// Gets or sets the Player speed modifier. + /// Gets or sets the Player speed modifier. /// public float PlayerSpeedMod { get; set; } = 1f; /// - /// Gets or sets the Light modifier for the players that are members of the crew as a multiplier value. + /// Gets or sets the Light modifier for the players that are members of the crew as a multiplier value. /// public float CrewLightMod { get; set; } = 1f; /// - /// Gets or sets the Light modifier for the players that are Impostors as a multiplier value. + /// Gets or sets the Light modifier for the players that are Impostors as a multiplier value. /// public float ImpostorLightMod { get; set; } = 1f; /// - /// Gets or sets the Impostor cooldown to kill in seconds. + /// Gets or sets the Impostor cooldown to kill in seconds. /// public float KillCooldown { get; set; } = 15f; /// - /// Gets or sets the number of common tasks. + /// Gets or sets the number of common tasks. /// public int NumCommonTasks { get; set; } = 1; /// - /// Gets or sets the number of long tasks. + /// Gets or sets the number of long tasks. /// public int NumLongTasks { get; set; } = 1; /// - /// Gets or sets the number of short tasks. + /// Gets or sets the number of short tasks. /// public int NumShortTasks { get; set; } = 2; /// - /// Gets or sets the maximum amount of emergency meetings each player can call during the game in seconds. + /// Gets or sets the maximum amount of emergency meetings each player can call during the game in seconds. /// public int NumEmergencyMeetings { get; set; } = 1; /// - /// Gets or sets the cooldown between each time any player can call an emergency meeting in seconds. + /// Gets or sets the cooldown between each time any player can call an emergency meeting in seconds. /// public int EmergencyCooldown { get; set; } = 15; /// - /// Gets or sets the number of impostors for this lobby. + /// Gets or sets the number of impostors for this lobby. /// public int NumImpostors { get; set; } = 1; /// - /// Gets or sets a value indicating whether ghosts (dead crew members) can do tasks. + /// Gets or sets a value indicating whether ghosts (dead crew members) can do tasks. /// public bool GhostsDoTasks { get; set; } = true; /// - /// Gets or sets the Kill as per values in . + /// Gets or sets the Kill as per values in . /// public KillDistances KillDistance { get; set; } = KillDistances.Normal; /// - /// Gets or sets the time for discussion before voting time in seconds. + /// Gets or sets the time for discussion before voting time in seconds. /// public int DiscussionTime { get; set; } = 15; /// - /// Gets or sets the time for voting in seconds. + /// Gets or sets the time for voting in seconds. /// public int VotingTime { get; set; } = 120; /// - /// Gets or sets a value indicating whether an ejected player is an impostor or not. + /// Gets or sets a value indicating whether an ejected player is an impostor or not. /// public bool ConfirmImpostor { get; set; } = true; /// - /// Gets or sets a value indicating whether players are able to see tasks being performed by other players. + /// Gets or sets a value indicating whether players are able to see tasks being performed by other players. /// /// - /// By being set to true, tasks such as Empty Garbage, Submit Scan, Clear asteroids, Prime shields execution will be visible to other players. + /// By being set to true, tasks such as Empty Garbage, Submit Scan, Clear asteroids, Prime shields execution will be visible to other players. /// public bool VisualTasks { get; set; } = true; /// - /// Gets or sets a value indicating whether the vote is anonymous. + /// Gets or sets a value indicating whether the vote is anonymous. /// public bool AnonymousVotes { get; set; } /// - /// Gets or sets the task bar update mode as per values in . + /// Gets or sets the task bar update mode as per values in . /// public TaskBarUpdate TaskBarUpdate { get; set; } = TaskBarUpdate.Always; /// - /// Gets or sets a value indicating whether the GameOptions are the default ones. + /// Gets or sets a value indicating whether the GameOptions are the default ones. /// public bool IsDefaults { get; set; } = true; /// - /// Deserialize a packet/message to a new GameOptionsData object. + /// Deserialize a packet/message to a new GameOptionsData object. /// /// Message reader object containing the raw message. /// GameOptionsData object. @@ -142,7 +142,7 @@ namespace Impostor.Api.Innersloth } /// - /// Serializes this instance of GameOptionsData object to a specified BinaryWriter. + /// Serializes this instance of GameOptionsData object to a specified BinaryWriter. /// /// The stream to write the message to. /// The version of the game. @@ -198,7 +198,7 @@ namespace Impostor.Api.Innersloth } /// - /// Deserialize a ReadOnlyMemory object to this instance of the GameOptionsData object. + /// Deserialize a ReadOnlyMemory object to this instance of the GameOptionsData object. /// /// Memory containing the message/packet. public void Deserialize(ReadOnlyMemory memory) diff --git a/src/Impostor.Api/Innersloth/GameStates.cs b/src/Impostor.Api/Innersloth/GameStates.cs index f5aaa9c..8e791de 100644 --- a/src/Impostor.Api/Innersloth/GameStates.cs +++ b/src/Impostor.Api/Innersloth/GameStates.cs @@ -8,4 +8,4 @@ Ended = 3, Destroyed = 4, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/GameVersion.cs b/src/Impostor.Api/Innersloth/GameVersion.cs index c11933e..5015589 100644 --- a/src/Impostor.Api/Innersloth/GameVersion.cs +++ b/src/Impostor.Api/Innersloth/GameVersion.cs @@ -7,4 +7,4 @@ namespace Impostor.Api.Innersloth return (year * 25000) + (month * 1800) + (day * 50) + rev; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/MapFlags.cs b/src/Impostor.Api/Innersloth/MapFlags.cs index ad462a2..9b0d8f0 100644 --- a/src/Impostor.Api/Innersloth/MapFlags.cs +++ b/src/Impostor.Api/Innersloth/MapFlags.cs @@ -9,4 +9,4 @@ namespace Impostor.Api.Innersloth MiraHQ = 2, Polus = 4, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/MapTypes.cs b/src/Impostor.Api/Innersloth/MapTypes.cs index 2b5ede9..2706933 100644 --- a/src/Impostor.Api/Innersloth/MapTypes.cs +++ b/src/Impostor.Api/Innersloth/MapTypes.cs @@ -6,4 +6,4 @@ MiraHQ = 1, Polus = 2, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/SystemTypeHelpers.cs b/src/Impostor.Api/Innersloth/SystemTypeHelpers.cs index ad88c28..e9ba29b 100644 --- a/src/Impostor.Api/Innersloth/SystemTypeHelpers.cs +++ b/src/Impostor.Api/Innersloth/SystemTypeHelpers.cs @@ -20,9 +20,9 @@ namespace Impostor.Api.Innersloth SystemTypes.LifeSupp => "O2", SystemTypes.LowerEngine => "Lower Engine", SystemTypes.LockerRoom => "Locker Room", - _ => x.ToString() + _ => x.ToString(), }; }).ToArray(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/SystemTypes.cs b/src/Impostor.Api/Innersloth/SystemTypes.cs index 5de8bc9..6a072e7 100644 --- a/src/Impostor.Api/Innersloth/SystemTypes.cs +++ b/src/Impostor.Api/Innersloth/SystemTypes.cs @@ -39,7 +39,7 @@ Sabotage = 17, /// - /// Decontam on Mira and bottom decontam on Polus + /// Decontam on Mira and bottom decontam on Polus /// Decontamination = 18, @@ -58,7 +58,7 @@ Dropship = 25, /// - /// Top decontam on Polus + /// Top decontam on Polus /// Decontamination2 = 26, diff --git a/src/Impostor.Api/Innersloth/TaskTypes.cs b/src/Impostor.Api/Innersloth/TaskTypes.cs index 8b15354..d479479 100644 --- a/src/Impostor.Api/Innersloth/TaskTypes.cs +++ b/src/Impostor.Api/Innersloth/TaskTypes.cs @@ -46,4 +46,4 @@ RecordTemperature = 41, RebootWifi = 42, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Innersloth/TextBox.cs b/src/Impostor.Api/Innersloth/TextBox.cs index 9533d83..1928ce2 100644 --- a/src/Impostor.Api/Innersloth/TextBox.cs +++ b/src/Impostor.Api/Innersloth/TextBox.cs @@ -7,4 +7,4 @@ return i == ' ' || (i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || (i >= '0' && i <= '9') || (i >= 'À' && i <= 'ÿ') || (i >= 'Ѐ' && i <= 'џ') || (i >= 'ㄱ' && i <= 'ㆎ') || (i >= '가' && i <= '힣'); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/IClient.cs b/src/Impostor.Api/Net/IClient.cs index 1ba5944..790b1c0 100644 --- a/src/Impostor.Api/Net/IClient.cs +++ b/src/Impostor.Api/Net/IClient.cs @@ -29,7 +29,7 @@ namespace Impostor.Api.Net string Name { get; } /// - /// Gets mods sent by client in modded handshake. + /// Gets mods sent by client in modded handshake. /// ISet Mods { get; } @@ -57,7 +57,7 @@ namespace Impostor.Api.Net IDictionary Items { get; } /// - /// Gets or sets the current game data of the . + /// Gets or sets the current game data of the . /// IClientPlayer? Player { get; } @@ -68,16 +68,16 @@ namespace Impostor.Api.Net ValueTask HandleDisconnectAsync(string reason); /// - /// Disconnect the client with a . + /// Disconnect the client with a . /// /// /// The message to show to the player. /// /// - /// Only used when is set to . + /// Only used when is set to . /// /// - /// A representing the asynchronous operation. + /// A representing the asynchronous operation. /// ValueTask DisconnectAsync(DisconnectReason reason, string? message = null); } diff --git a/src/Impostor.Api/Net/IClientPlayer.cs b/src/Impostor.Api/Net/IClientPlayer.cs index 6070210..f11c873 100644 --- a/src/Impostor.Api/Net/IClientPlayer.cs +++ b/src/Impostor.Api/Net/IClientPlayer.cs @@ -6,7 +6,7 @@ using Impostor.Api.Net.Inner.Objects; namespace Impostor.Api.Net { /// - /// Represents a player in . + /// Represents a player in . /// public interface IClientPlayer { @@ -16,7 +16,7 @@ namespace Impostor.Api.Net IClient Client { get; } /// - /// Gets the game where the belongs to. + /// Gets the game where the belongs to. /// IGame Game { get; } @@ -30,10 +30,10 @@ namespace Impostor.Api.Net public bool IsHost { get; } /// - /// Checks if the specified is owned by . + /// Checks if the specified is owned by . /// - /// The . - /// Returns true if owned by . + /// The . + /// Returns true if owned by . bool IsOwner(IInnerNetObject netObject); ValueTask KickAsync(); diff --git a/src/Impostor.Api/Net/IHazelConnection.cs b/src/Impostor.Api/Net/IHazelConnection.cs index 4e6c4b3..c012bd1 100644 --- a/src/Impostor.Api/Net/IHazelConnection.cs +++ b/src/Impostor.Api/Net/IHazelConnection.cs @@ -38,4 +38,4 @@ namespace Impostor.Api.Net /// ValueTask DisconnectAsync(string? reason); } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Inner/IInnerNetObject.cs b/src/Impostor.Api/Net/Inner/IInnerNetObject.cs index c171377..8cfadb8 100644 --- a/src/Impostor.Api/Net/Inner/IInnerNetObject.cs +++ b/src/Impostor.Api/Net/Inner/IInnerNetObject.cs @@ -6,4 +6,4 @@ public int OwnerId { get; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Inner/Objects/Components/IInnerCustomNetworkTransform.cs b/src/Impostor.Api/Net/Inner/Objects/Components/IInnerCustomNetworkTransform.cs index 2dd4709..5ad4763 100644 --- a/src/Impostor.Api/Net/Inner/Objects/Components/IInnerCustomNetworkTransform.cs +++ b/src/Impostor.Api/Net/Inner/Objects/Components/IInnerCustomNetworkTransform.cs @@ -16,7 +16,7 @@ namespace Impostor.Api.Net.Inner.Objects.Components Vector2 Velocity { get; } /// - /// Snaps the current to the given position . + /// Snaps the current to the given position . /// /// The target position. /// Task that must be awaited. diff --git a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs index 0ee065a..711f878 100644 --- a/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs +++ b/src/Impostor.Api/Net/Inner/Objects/IInnerPlayerControl.cs @@ -7,30 +7,30 @@ namespace Impostor.Api.Net.Inner.Objects public interface IInnerPlayerControl : IInnerNetObject { /// - /// Gets the assigned by the client of the host of the game. + /// Gets the assigned by the client of the host of the game. /// byte PlayerId { get; } /// - /// Gets the of the . + /// Gets the of the . /// Contains vent logic. /// IInnerPlayerPhysics Physics { get; } /// - /// Gets the of the . + /// Gets the of the . /// Contains position data about the player. /// IInnerCustomNetworkTransform NetworkTransform { get; } /// - /// Gets the of the . + /// Gets the of the . /// Contains metadata about the player. /// IInnerPlayerInfo PlayerInfo { get; } /// - /// Sets the name of the current . + /// Sets the name of the current . /// Visible to all players. /// /// A name for the player. @@ -38,7 +38,7 @@ namespace Impostor.Api.Net.Inner.Objects ValueTask SetNameAsync(string name); /// - /// Sets the color of the current . + /// Sets the color of the current . /// Visible to all players. /// /// A color for the player. @@ -46,7 +46,7 @@ namespace Impostor.Api.Net.Inner.Objects ValueTask SetColorAsync(ColorType colorType); /// - /// Sets the hat of the current . + /// Sets the hat of the current . /// Visible to all players. /// /// An hat for the player. @@ -54,7 +54,7 @@ namespace Impostor.Api.Net.Inner.Objects ValueTask SetHatAsync(HatType hatType); /// - /// Sets the pet of the current . + /// Sets the pet of the current . /// Visible to all players. /// /// A pet for the player. @@ -62,7 +62,7 @@ namespace Impostor.Api.Net.Inner.Objects ValueTask SetPetAsync(PetType petType); /// - /// Sets the skin of the current . + /// Sets the skin of the current . /// Visible to all players. /// /// A skin for the player. @@ -70,7 +70,7 @@ namespace Impostor.Api.Net.Inner.Objects ValueTask SetSkinAsync(SkinType skinType); /// - /// Send a chat message as the current . + /// Send a chat message as the current . /// Visible to all players. /// /// The message to send. @@ -78,7 +78,7 @@ namespace Impostor.Api.Net.Inner.Objects ValueTask SendChatAsync(string text); /// - /// Send a chat message as the current . + /// Send a chat message as the current . /// Visible to only the current. /// /// The message to send. @@ -90,7 +90,7 @@ namespace Impostor.Api.Net.Inner.Objects ValueTask SendChatToPlayerAsync(string text, IInnerPlayerControl? player = null); /// - /// Murder player. + /// Murder player. /// /// Target player to murder. /// Thrown when player is not the impostor. diff --git a/src/Impostor.Api/Net/Inner/Objects/ITaskInfo.cs b/src/Impostor.Api/Net/Inner/Objects/ITaskInfo.cs index 2b6dd86..f4e54b1 100644 --- a/src/Impostor.Api/Net/Inner/Objects/ITaskInfo.cs +++ b/src/Impostor.Api/Net/Inner/Objects/ITaskInfo.cs @@ -1,5 +1,4 @@ using Impostor.Api.Innersloth; -using Impostor.Api.Net.Messages; namespace Impostor.Api.Net.Inner.Objects { diff --git a/src/Impostor.Api/Net/LimboStates.cs b/src/Impostor.Api/Net/LimboStates.cs index 44c493e..5d1242d 100644 --- a/src/Impostor.Api/Net/LimboStates.cs +++ b/src/Impostor.Api/Net/LimboStates.cs @@ -10,4 +10,4 @@ namespace Impostor.Api.Net WaitingForHost = 4, All = PreSpawn | NotLimbo | WaitingForHost, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Manager/IClientManager.cs b/src/Impostor.Api/Net/Manager/IClientManager.cs index 92bf89f..737e42f 100644 --- a/src/Impostor.Api/Net/Manager/IClientManager.cs +++ b/src/Impostor.Api/Net/Manager/IClientManager.cs @@ -6,4 +6,4 @@ namespace Impostor.Api.Net.Manager { IEnumerable Clients { get; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/C2S/Message00HostGameC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message00HostGameC2S.cs index 7d7ee55..e81e861 100644 --- a/src/Impostor.Api/Net/Messages/C2S/Message00HostGameC2S.cs +++ b/src/Impostor.Api/Net/Messages/C2S/Message00HostGameC2S.cs @@ -14,9 +14,9 @@ namespace Impostor.Api.Net.Messages.C2S /// /// Deserialize a packet. /// - /// with 0. + /// with 0. /// The chat type selected in the client of the player. - /// Deserialized . + /// Deserialized . public static GameOptionsData Deserialize(IMessageReader reader, out ChatType chatType) { var gameOptionsData = GameOptionsData.DeserializeCreate(reader); diff --git a/src/Impostor.Api/Net/Messages/C2S/Message01JoinGameC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message01JoinGameC2S.cs index 58a8512..e7771e7 100644 --- a/src/Impostor.Api/Net/Messages/C2S/Message01JoinGameC2S.cs +++ b/src/Impostor.Api/Net/Messages/C2S/Message01JoinGameC2S.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Games; +using System; +using Impostor.Api.Games; namespace Impostor.Api.Net.Messages.C2S { @@ -6,7 +7,7 @@ namespace Impostor.Api.Net.Messages.C2S { public static void Serialize(IMessageWriter writer) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public static void Deserialize(IMessageReader reader, out GameCode gameCode) diff --git a/src/Impostor.Api/Net/Messages/C2S/Message04RemovePlayerC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message04RemovePlayerC2S.cs index 99cdcfa..a3bcedf 100644 --- a/src/Impostor.Api/Net/Messages/C2S/Message04RemovePlayerC2S.cs +++ b/src/Impostor.Api/Net/Messages/C2S/Message04RemovePlayerC2S.cs @@ -1,10 +1,12 @@ -namespace Impostor.Api.Net.Messages.C2S +using System; + +namespace Impostor.Api.Net.Messages.C2S { public class Message04RemovePlayerC2S { public static void Serialize(IMessageWriter writer) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public static void Deserialize(IMessageReader reader, out int playerId, out byte reason) @@ -13,4 +15,4 @@ reason = reader.ReadByte(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/C2S/Message08EndGameC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message08EndGameC2S.cs index 7ca5e3a..d264294 100644 --- a/src/Impostor.Api/Net/Messages/C2S/Message08EndGameC2S.cs +++ b/src/Impostor.Api/Net/Messages/C2S/Message08EndGameC2S.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Innersloth; +using System; +using Impostor.Api.Innersloth; namespace Impostor.Api.Net.Messages.C2S { @@ -6,7 +7,7 @@ namespace Impostor.Api.Net.Messages.C2S { public static void Serialize(IMessageWriter writer) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public static void Deserialize(IMessageReader reader, out GameOverReason gameOverReason) @@ -15,4 +16,4 @@ namespace Impostor.Api.Net.Messages.C2S reader.ReadBoolean(); // showAd } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/C2S/Message10AlterGameC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message10AlterGameC2S.cs index 330f3b5..57db669 100644 --- a/src/Impostor.Api/Net/Messages/C2S/Message10AlterGameC2S.cs +++ b/src/Impostor.Api/Net/Messages/C2S/Message10AlterGameC2S.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Innersloth; +using System; +using Impostor.Api.Innersloth; namespace Impostor.Api.Net.Messages.C2S { @@ -6,7 +7,7 @@ namespace Impostor.Api.Net.Messages.C2S { public static void Serialize(IMessageWriter writer) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public static void Deserialize(IMessageReader reader, out AlterGameTags gameTag, out bool isPublic) @@ -17,4 +18,4 @@ namespace Impostor.Api.Net.Messages.C2S isPublic = slice.ReadBoolean(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/C2S/Message11KickPlayerC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message11KickPlayerC2S.cs index 7c5b8b9..acafcee 100644 --- a/src/Impostor.Api/Net/Messages/C2S/Message11KickPlayerC2S.cs +++ b/src/Impostor.Api/Net/Messages/C2S/Message11KickPlayerC2S.cs @@ -1,10 +1,12 @@ -namespace Impostor.Api.Net.Messages.C2S +using System; + +namespace Impostor.Api.Net.Messages.C2S { public class Message11KickPlayerC2S { public static void Serialize(IMessageWriter writer) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public static void Deserialize(IMessageReader reader, out int playerId, out bool isBan) @@ -13,4 +15,4 @@ isBan = reader.ReadBoolean(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/C2S/Message16GetGameListC2S.cs b/src/Impostor.Api/Net/Messages/C2S/Message16GetGameListC2S.cs index bc32d5e..72be48d 100644 --- a/src/Impostor.Api/Net/Messages/C2S/Message16GetGameListC2S.cs +++ b/src/Impostor.Api/Net/Messages/C2S/Message16GetGameListC2S.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Innersloth; +using System; +using Impostor.Api.Innersloth; namespace Impostor.Api.Net.Messages.C2S { @@ -6,7 +7,7 @@ namespace Impostor.Api.Net.Messages.C2S { public static void Serialize(IMessageWriter writer) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public static void Deserialize(IMessageReader reader, out GameOptionsData options, out ChatType chatType) diff --git a/src/Impostor.Api/Net/Messages/IMessageReader.cs b/src/Impostor.Api/Net/Messages/IMessageReader.cs index 1eb82d1..397ad5a 100644 --- a/src/Impostor.Api/Net/Messages/IMessageReader.cs +++ b/src/Impostor.Api/Net/Messages/IMessageReader.cs @@ -18,7 +18,7 @@ namespace Impostor.Api.Net.Messages byte[] Buffer { get; } /// - /// Gets the offset of our current in the entire . + /// Gets the offset of our current in the entire . /// int Offset { get; } diff --git a/src/Impostor.Api/Net/Messages/IMessageWriter.cs b/src/Impostor.Api/Net/Messages/IMessageWriter.cs index 0f4b7fa..fd500ad 100644 --- a/src/Impostor.Api/Net/Messages/IMessageWriter.cs +++ b/src/Impostor.Api/Net/Messages/IMessageWriter.cs @@ -74,7 +74,7 @@ namespace Impostor.Api.Net.Messages void Write(string value); /// - /// Writes a to the message. + /// Writes a to the message. /// /// Value to write. void Write(IPAddress value); diff --git a/src/Impostor.Api/Net/Messages/IMessageWriterProvider.cs b/src/Impostor.Api/Net/Messages/IMessageWriterProvider.cs index f398939..cf92004 100644 --- a/src/Impostor.Api/Net/Messages/IMessageWriterProvider.cs +++ b/src/Impostor.Api/Net/Messages/IMessageWriterProvider.cs @@ -3,14 +3,14 @@ public interface IMessageWriterProvider { /// - /// Retrieves a from the internal pool. - /// Make sure to call when you are done! + /// Retrieves a from the internal pool. + /// Make sure to call when you are done! /// /// - /// Whether to send the message as or . + /// Whether to send the message as or . /// Reliable packets will ensure delivery while unreliable packets may be lost. /// - /// A from the pool. + /// A from the pool. IMessageWriter Get(MessageType sendOption = MessageType.Unreliable); } } diff --git a/src/Impostor.Api/Net/Messages/MessageFlags.cs b/src/Impostor.Api/Net/Messages/MessageFlags.cs index aea0c60..2ebf475 100644 --- a/src/Impostor.Api/Net/Messages/MessageFlags.cs +++ b/src/Impostor.Api/Net/Messages/MessageFlags.cs @@ -19,4 +19,4 @@ public const byte GetGameList = 9; public const byte GetGameListV2 = 16; } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/MessageType.cs b/src/Impostor.Api/Net/Messages/MessageType.cs index 1604358..50acb52 100644 --- a/src/Impostor.Api/Net/Messages/MessageType.cs +++ b/src/Impostor.Api/Net/Messages/MessageType.cs @@ -29,4 +29,4 @@ namespace Impostor.Api.Net.Messages /// Reliable, } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message00HostGameS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message00HostGameS2C.cs index 8402d10..8fef225 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message00HostGameS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message00HostGameS2C.cs @@ -17,4 +17,4 @@ namespace Impostor.Api.Net.Messages.S2C throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message01JoinGameS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message01JoinGameS2C.cs index c455201..74fdc40 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message01JoinGameS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message01JoinGameS2C.cs @@ -44,7 +44,7 @@ namespace Impostor.Api.Net.Messages.S2C public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message04RemovePlayerS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message04RemovePlayerS2C.cs index 77b447d..bcdca04 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message04RemovePlayerS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message04RemovePlayerS2C.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Innersloth; +using System; +using Impostor.Api.Innersloth; namespace Impostor.Api.Net.Messages.S2C { @@ -23,7 +24,7 @@ namespace Impostor.Api.Net.Messages.S2C public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message07JoinedGameS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message07JoinedGameS2C.cs index da6eb40..857fea1 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message07JoinedGameS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message07JoinedGameS2C.cs @@ -1,4 +1,6 @@ -namespace Impostor.Api.Net.Messages.S2C +using System; + +namespace Impostor.Api.Net.Messages.S2C { public static class Message07JoinedGameS2C { @@ -25,7 +27,7 @@ public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message10AlterGameS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message10AlterGameS2C.cs index fa155df..40c949d 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message10AlterGameS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message10AlterGameS2C.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Innersloth; +using System; +using Impostor.Api.Innersloth; namespace Impostor.Api.Net.Messages.S2C { @@ -20,7 +21,7 @@ namespace Impostor.Api.Net.Messages.S2C public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message11KickPlayerS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message11KickPlayerS2C.cs index 1e2b6ef..7ffdb7b 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message11KickPlayerS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message11KickPlayerS2C.cs @@ -1,4 +1,6 @@ -namespace Impostor.Api.Net.Messages.S2C +using System; + +namespace Impostor.Api.Net.Messages.S2C { public class Message11KickPlayerS2C { @@ -18,7 +20,7 @@ public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message12WaitForHostS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message12WaitForHostS2C.cs index 5964b1c..8cf9046 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message12WaitForHostS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message12WaitForHostS2C.cs @@ -1,4 +1,6 @@ -namespace Impostor.Api.Net.Messages.S2C +using System; + +namespace Impostor.Api.Net.Messages.S2C { public class Message12WaitForHostS2C { @@ -17,7 +19,7 @@ public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message13RedirectS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message13RedirectS2C.cs index 4b93b0e..0576c71 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message13RedirectS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message13RedirectS2C.cs @@ -1,4 +1,5 @@ -using System.Net; +using System; +using System.Net; namespace Impostor.Api.Net.Messages.S2C { @@ -19,7 +20,7 @@ namespace Impostor.Api.Net.Messages.S2C public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Net/Messages/S2C/Message16GetGameListS2C.cs b/src/Impostor.Api/Net/Messages/S2C/Message16GetGameListS2C.cs index 7b64192..a09259b 100644 --- a/src/Impostor.Api/Net/Messages/S2C/Message16GetGameListS2C.cs +++ b/src/Impostor.Api/Net/Messages/S2C/Message16GetGameListS2C.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Impostor.Api.Games; namespace Impostor.Api.Net.Messages.S2C @@ -33,7 +34,7 @@ namespace Impostor.Api.Net.Messages.S2C public static void Deserialize(IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } } diff --git a/src/Impostor.Api/Plugins/IPlugin.cs b/src/Impostor.Api/Plugins/IPlugin.cs index fd0f38f..9f1efcf 100644 --- a/src/Impostor.Api/Plugins/IPlugin.cs +++ b/src/Impostor.Api/Plugins/IPlugin.cs @@ -11,4 +11,4 @@ namespace Impostor.Api.Plugins ValueTask ReloadAsync(); } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Plugins/IPluginStartup.cs b/src/Impostor.Api/Plugins/IPluginStartup.cs index aa6a35f..e9d8585 100644 --- a/src/Impostor.Api/Plugins/IPluginStartup.cs +++ b/src/Impostor.Api/Plugins/IPluginStartup.cs @@ -9,4 +9,4 @@ namespace Impostor.Api.Plugins void ConfigureServices(IServiceCollection services); } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Plugins/ImpostorPluginAttribute.cs b/src/Impostor.Api/Plugins/ImpostorPluginAttribute.cs index b31bd47..e2d6b02 100644 --- a/src/Impostor.Api/Plugins/ImpostorPluginAttribute.cs +++ b/src/Impostor.Api/Plugins/ImpostorPluginAttribute.cs @@ -21,4 +21,4 @@ namespace Impostor.Api.Plugins public string Version { get; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Plugins/PluginBase.cs b/src/Impostor.Api/Plugins/PluginBase.cs index 0384363..9d6f2b4 100644 --- a/src/Impostor.Api/Plugins/PluginBase.cs +++ b/src/Impostor.Api/Plugins/PluginBase.cs @@ -19,4 +19,4 @@ namespace Impostor.Api.Plugins return default; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Api/Properties/AssemblyInfo.cs b/src/Impostor.Api/Properties/AssemblyInfo.cs index c02e44a..30143b8 100644 --- a/src/Impostor.Api/Properties/AssemblyInfo.cs +++ b/src/Impostor.Api/Properties/AssemblyInfo.cs @@ -1,3 +1,3 @@ using System.Runtime.CompilerServices; -[assembly:InternalsVisibleTo("Impostor.Server")] \ No newline at end of file +[assembly: InternalsVisibleTo("Impostor.Server")] diff --git a/src/Impostor.Api/Reactor/PluginSide.cs b/src/Impostor.Api/Reactor/PluginSide.cs index 30c588c..2118299 100644 --- a/src/Impostor.Api/Reactor/PluginSide.cs +++ b/src/Impostor.Api/Reactor/PluginSide.cs @@ -1,22 +1,22 @@ namespace Impostor.Api.Reactor { /// - /// Plugin side used in modded handshake + /// Plugin side used in modded handshake /// public enum PluginSide : byte { /// - /// Required by both sides, reject connection if missing on the other side + /// Required by both sides, reject connection if missing on the other side /// Both, /// - /// Required only by client + /// Required only by client /// ClientOnly, /// - /// Required only by server + /// Required only by server /// ServerOnly, } diff --git a/src/Impostor.Api/Unity/Mathf.cs b/src/Impostor.Api/Unity/Mathf.cs index c907f81..5ab93c7 100644 --- a/src/Impostor.Api/Unity/Mathf.cs +++ b/src/Impostor.Api/Unity/Mathf.cs @@ -3,13 +3,13 @@ public static class Mathf { /// - /// 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. + /// 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. /// /// The floating point value to restrict inside the range defined by the min and max values. /// The minimum floating point value to compare against. /// The maximum floating point value to compare against. /// - /// The float result between the min and max values. + /// The float result between the min and max values. /// public static float Clamp(float value, float min, float max) { @@ -26,7 +26,7 @@ } /// - /// Clamps value between 0 and 1 and returns value. + /// Clamps value between 0 and 1 and returns value. /// /// Value. /// Clamped value. @@ -41,13 +41,13 @@ } /// - /// Linearly interpolates between a and b by t. + /// Linearly interpolates between a and b by t. /// /// The start value. /// The end value. /// The interpolation value between the two floats. /// - /// The interpolated float result between the two float values. + /// The interpolated float result between the two float values. /// public static float Lerp(float a, float b, float t) => a + ((b - a) * Clamp01(t)); diff --git a/src/Impostor.Benchmarks/Data/MessageReader_Bytes.cs b/src/Impostor.Benchmarks/Data/MessageReader_Bytes.cs index 2aba724..7788f0e 100644 --- a/src/Impostor.Benchmarks/Data/MessageReader_Bytes.cs +++ b/src/Impostor.Benchmarks/Data/MessageReader_Bytes.cs @@ -41,7 +41,7 @@ namespace Impostor.Benchmarks.Data public bool ReadBoolean() { - byte val = FastByte(); + var val = FastByte(); return val != 0; } @@ -88,7 +88,7 @@ namespace Impostor.Benchmarks.Data float output = 0; fixed (byte* bufPtr = &this.Buffer[Position]) { - byte* outPtr = (byte*)&output; + var outPtr = (byte*)&output; *outPtr = *bufPtr; *(outPtr + 1) = *(bufPtr + 1); @@ -134,13 +134,13 @@ namespace Impostor.Benchmarks.Data public uint ReadPackedUInt32() { - bool readMore = true; - int shift = 0; + var readMore = true; + var shift = 0; uint output = 0; while (readMore) { - byte b = FastByte(); + var b = FastByte(); if (b >= 0x80) { readMore = true; diff --git a/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled.cs b/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled.cs index 1103336..3c88ffb 100644 --- a/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled.cs +++ b/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled.cs @@ -65,7 +65,7 @@ namespace Impostor.Benchmarks.Data public bool ReadBoolean() { - byte val = FastByte(); + var val = FastByte(); return val != 0; } @@ -112,7 +112,7 @@ namespace Impostor.Benchmarks.Data float output = 0; fixed (byte* bufPtr = &this.Buffer[Position]) { - byte* outPtr = (byte*)&output; + var outPtr = (byte*)&output; *outPtr = *bufPtr; *(outPtr + 1) = *(bufPtr + 1); @@ -158,13 +158,13 @@ namespace Impostor.Benchmarks.Data public uint ReadPackedUInt32() { - bool readMore = true; - int shift = 0; + var readMore = true; + var shift = 0; uint output = 0; while (readMore) { - byte b = FastByte(); + var b = FastByte(); if (b >= 0x80) { readMore = true; diff --git a/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled_Improved.cs b/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled_Improved.cs index 0066847..cb5d18d 100644 --- a/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled_Improved.cs +++ b/src/Impostor.Benchmarks/Data/MessageReader_Bytes_Pooled_Improved.cs @@ -1,10 +1,6 @@ using System; using System.Buffers.Binary; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; using System.Runtime.CompilerServices; -using System.Text; using Microsoft.Extensions.ObjectPool; namespace Impostor.Benchmarks.Data diff --git a/src/Impostor.Benchmarks/Data/MessageWriter.cs b/src/Impostor.Benchmarks/Data/MessageWriter.cs index 42f452a..b55b797 100644 --- a/src/Impostor.Benchmarks/Data/MessageWriter.cs +++ b/src/Impostor.Benchmarks/Data/MessageWriter.cs @@ -32,7 +32,7 @@ namespace Impostor.Benchmarks.Data { if (includeHeader) { - byte[] output = new byte[this.Length]; + var output = new byte[this.Length]; System.Buffer.BlockCopy(this.Buffer, 0, output, 0, this.Length); return output; } @@ -41,17 +41,17 @@ namespace Impostor.Benchmarks.Data switch (this.SendOption) { case MessageType.Reliable: - { - byte[] output = new byte[this.Length - 3]; - System.Buffer.BlockCopy(this.Buffer, 3, output, 0, this.Length - 3); - return output; - } + { + var output = new byte[this.Length - 3]; + System.Buffer.BlockCopy(this.Buffer, 3, output, 0, this.Length - 3); + return output; + } case MessageType.Unreliable: - { - byte[] output = new byte[this.Length - 1]; - System.Buffer.BlockCopy(this.Buffer, 1, output, 0, this.Length - 1); - return output; - } + { + var output = new byte[this.Length - 1]; + System.Buffer.BlockCopy(this.Buffer, 1, output, 0, this.Length - 1); + return output; + } default: throw new ArgumentOutOfRangeException(); } @@ -87,7 +87,7 @@ namespace Impostor.Benchmarks.Data public void EndMessage() { var lastMessageStart = messageStarts.Pop(); - ushort length = (ushort)(this.Position - lastMessageStart - 3); // Minus length and type byte + var length = (ushort)(this.Position - lastMessageStart - 3); // Minus length and type byte this.Buffer[lastMessageStart] = (byte)length; this.Buffer[lastMessageStart + 1] = (byte)(length >> 8); } @@ -173,7 +173,7 @@ namespace Impostor.Benchmarks.Data { fixed (byte* ptr = &this.Buffer[this.Position]) { - byte* valuePtr = (byte*)&value; + var valuePtr = (byte*)&value; *ptr = *valuePtr; *(ptr + 1) = *(valuePtr + 1); @@ -260,7 +260,7 @@ namespace Impostor.Benchmarks.Data { do { - byte b = (byte)(value & 0xFF); + var b = (byte)(value & 0xFF); if (value >= 0x80) { b |= 0x80; @@ -275,7 +275,7 @@ namespace Impostor.Benchmarks.Data public void Write(MessageWriter msg, bool includeHeader) { - int offset = 0; + var offset = 0; if (!includeHeader) { switch (msg.SendOption) @@ -298,8 +298,8 @@ namespace Impostor.Benchmarks.Data byte b; unsafe { - int i = 1; - byte* bp = (byte*)&i; + var i = 1; + var bp = (byte*)&i; b = *bp; } diff --git a/src/Impostor.Benchmarks/Data/Span/MessageReader_Span.cs b/src/Impostor.Benchmarks/Data/Span/MessageReader_Span.cs index 5636dbe..3a7edec 100644 --- a/src/Impostor.Benchmarks/Data/Span/MessageReader_Span.cs +++ b/src/Impostor.Benchmarks/Data/Span/MessageReader_Span.cs @@ -1,6 +1,5 @@ using System; using System.Buffers.Binary; -using Impostor.Hazel; namespace Impostor.Benchmarks.Data.Span { diff --git a/src/Impostor.Benchmarks/Tests/MessageReaderBenchmark.cs b/src/Impostor.Benchmarks/Tests/MessageReaderBenchmark.cs index abf1642..dbaf227 100644 --- a/src/Impostor.Benchmarks/Tests/MessageReaderBenchmark.cs +++ b/src/Impostor.Benchmarks/Tests/MessageReaderBenchmark.cs @@ -4,10 +4,8 @@ using BenchmarkDotNet.Attributes; using Impostor.Benchmarks.Data; using Impostor.Benchmarks.Data.Pool; using Impostor.Benchmarks.Extensions; -using Impostor.Hazel; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.ObjectPool; -using MessageWriter = Impostor.Benchmarks.Data.MessageWriter; namespace Impostor.Benchmarks.Tests { @@ -24,7 +22,7 @@ namespace Impostor.Benchmarks.Tests message.StartMessage(1); message.Write((ushort)3100); message.Write((byte)100); - message.Write((int) int.MaxValue); + message.Write((int)int.MaxValue); message.WritePacked(int.MaxValue); message.EndMessage(); diff --git a/src/Impostor.Client.App/Program.cs b/src/Impostor.Client.App/Program.cs index aa8866a..ba039a5 100644 --- a/src/Impostor.Client.App/Program.cs +++ b/src/Impostor.Client.App/Program.cs @@ -1,5 +1,4 @@ -using System; -using System.Net; +using System.Net; using System.Threading; using System.Threading.Tasks; using Impostor.Api.Innersloth; @@ -31,7 +30,7 @@ namespace Impostor.Client.App Message00HostGameC2S.Serialize(writeGameCreate, new GameOptionsData { MaxPlayers = 4, - NumImpostors = 2 + NumImpostors = 2, }); // TODO: ObjectPool for MessageReaders diff --git a/src/Impostor.Hazel/Connection.cs b/src/Impostor.Hazel/Connection.cs index dec8cfe..23d7f4b 100644 --- a/src/Impostor.Hazel/Connection.cs +++ b/src/Impostor.Hazel/Connection.cs @@ -11,7 +11,7 @@ namespace Impostor.Hazel /// /// /// - /// Connection is the base class for all connections that Hazel can make. It provides common functionality and a + /// Connection is the base class for all connections that Hazel can make. It provides common functionality and a /// standard interface to allow connections to be swapped easily. /// /// @@ -29,7 +29,7 @@ namespace Impostor.Hazel /// /// /// - /// + /// public abstract class Connection : IDisposable { private static readonly ILogger Logger = Log.ForContext(); @@ -39,34 +39,34 @@ namespace Impostor.Hazel /// /// /// - /// DataReceived is invoked everytime a message is received from the end point of this connection, the message - /// that was received can be found in the alongside other information from the + /// DataReceived is invoked everytime a message is received from the end point of this connection, the message + /// that was received can be found in the alongside other information from the /// event. /// /// /// /// - /// + /// /// public Func DataReceived; public int TestLagMs = -1; public int TestDropRate = 0; protected int testDropCount = 0; - + /// /// Called when the end point disconnects or an error occurs. /// /// /// - /// Disconnected is invoked when the connection is closed due to an exception occuring or because the remote - /// end point disconnected. If it was invoked due to an exception occuring then the exception is available - /// in the passed with the event. + /// Disconnected is invoked when the connection is closed due to an exception occuring or because the remote + /// end point disconnected. If it was invoked due to an exception occuring then the exception is available + /// in the passed with the event. /// /// /// /// - /// + /// /// public Func Disconnected; @@ -74,8 +74,8 @@ namespace Impostor.Hazel /// The remote end point of this Connection. /// /// - /// This is the end point that this connection is connected to (i.e. the other device). This returns an abstract - /// which can then be cast to an appropriate end point depending on the + /// This is the end point that this connection is connected to (i.e. the other device). This returns an abstract + /// which can then be cast to an appropriate end point depending on the /// connection type. /// public IPEndPoint EndPoint { get; protected set; } @@ -95,7 +95,7 @@ namespace Impostor.Hazel /// /// /// All implementers should be aware that when this is set to ConnectionState.Connected it will - /// release all threads that are blocked on . + /// release all threads that are blocked on . /// public ConnectionState State { @@ -103,7 +103,7 @@ namespace Impostor.Hazel { return this._state; } - + protected set { this._state = value; @@ -113,13 +113,13 @@ namespace Impostor.Hazel protected ConnectionState _state; protected virtual void SetState(ConnectionState state) { } - + /// /// Constructor that initializes the ConnecitonStatistics object. /// /// - /// This constructor initialises with empty statistics and sets to - /// . + /// This constructor initialises with empty statistics and sets to + /// . /// protected Connection() { @@ -128,21 +128,21 @@ namespace Impostor.Hazel } /// - /// Sends a number of bytes to the end point of the connection using the specified . + /// Sends a number of bytes to the end point of the connection using the specified . /// /// The message to send. /// /// /// /// The messageType parameter is only a request to use those options and the actual method used to send the - /// data is up to the implementation. There are circumstances where this parameter may be ignored but in + /// data is up to the implementation. There are circumstances where this parameter may be ignored but in /// general any implementer should aim to always follow the user's request. /// /// public abstract ValueTask SendAsync(IMessageWriter msg); /// - /// Sends a number of bytes to the end point of the connection using the specified . + /// Sends a number of bytes to the end point of the connection using the specified . /// /// The bytes of the message to send. /// The option specifying how the message should be sent. @@ -150,7 +150,7 @@ namespace Impostor.Hazel /// /// /// The messageType parameter is only a request to use those options and the actual method used to send the - /// data is up to the implementation. There are circumstances where this parameter may be ignored but in + /// data is up to the implementation. There are circumstances where this parameter may be ignored but in /// general any implementer should aim to always follow the user's request. /// /// @@ -167,9 +167,9 @@ namespace Impostor.Hazel /// Invokes the DataReceived event. /// /// The bytes received. - /// The the message was received with. + /// The the message was received with. /// - /// Invokes the event on this connection to alert subscribers a new message has been + /// Invokes the event on this connection to alert subscribers a new message has been /// received. The bytes and the send option that the message was sent with should be passed in to give to the /// subscribers. /// @@ -197,8 +197,8 @@ namespace Impostor.Hazel /// The exception, if any, that occurred to cause this. /// Extra disconnect data /// - /// Invokes the event to alert subscribres this connection has been disconnected either - /// by the end point or because an error occurred. If an error occurred the error should be passed in in order to + /// Invokes the event to alert subscribres this connection has been disconnected either + /// by the end point or because an error occurred. If an error occurred the error should be passed in in order to /// pass to the subscribers, otherwise null can be passed in. /// protected async ValueTask InvokeDisconnected(string e, IMessageReader reader) @@ -219,11 +219,11 @@ namespace Impostor.Hazel } /// - /// For times when you want to force the disconnect handler to fire as well as close it. - /// If you only want to close it, just use Dispose. + /// For times when you want to force the disconnect handler to fire as well as close it. + /// If you only want to close it, just use Dispose. /// public abstract ValueTask Disconnect(string reason, MessageWriter writer = null); - + /// /// Disposes of this NetworkConnection. /// diff --git a/src/Impostor.Hazel/ConnectionListener.cs b/src/Impostor.Hazel/ConnectionListener.cs index 116f657..6c2f942 100644 --- a/src/Impostor.Hazel/ConnectionListener.cs +++ b/src/Impostor.Hazel/ConnectionListener.cs @@ -10,16 +10,16 @@ namespace Impostor.Hazel /// /// /// - /// ConnectionListeners are server side objects that listen for clients and create matching server side connections + /// ConnectionListeners are server side objects that listen for clients and create matching server side connections /// for each client in a similar way to TCP does. These connections should be ready for communication immediately. /// /// - /// Each time a client connects the event will be invoked to alert all subscribers to - /// the new connection. A disconnected event is then present on the that is passed to the + /// Each time a client connects the event will be invoked to alert all subscribers to + /// the new connection. A disconnected event is then present on the that is passed to the /// subscribers. /// /// - /// + /// public abstract class ConnectionListener : IAsyncDisposable { private static readonly ILogger Logger = Log.ForContext(); @@ -29,18 +29,18 @@ namespace Impostor.Hazel /// /// /// - /// NewConnection is invoked each time a client connects to the listener. The - /// contains the new for communication with this + /// NewConnection is invoked each time a client connects to the listener. The + /// contains the new for communication with this /// client. /// /// - /// Hazel may or may not store connections so it is your responsibility to keep track and properly Dispose of - /// connections to your server. + /// Hazel may or may not store connections so it is your responsibility to keep track and properly Dispose of + /// connections to your server. /// /// /// /// - /// + /// /// public Func NewConnection; @@ -49,15 +49,15 @@ namespace Impostor.Hazel /// /// /// - /// This instructs the listener to begin listening for new clients connecting to the server. When a new client - /// connects the event will be invoked containing the connection to the new client. + /// This instructs the listener to begin listening for new clients connecting to the server. When a new client + /// connects the event will be invoked containing the connection to the new client. /// /// - /// To stop listening you should call . + /// To stop listening you should call . /// /// /// - /// + /// /// public abstract Task StartAsync(); @@ -67,7 +67,7 @@ namespace Impostor.Hazel /// The user sent bytes that were received as part of the handshake. /// The connection to pass in the arguments. /// - /// Implementers should call this to invoke the event before data is received so that + /// Implementers should call this to invoke the event before data is received so that /// subscribers do not miss any data that may have been sent immediately after connecting. /// internal async Task InvokeNewConnection(IMessageReader msg, Connection connection) diff --git a/src/Impostor.Hazel/ConnectionState.cs b/src/Impostor.Hazel/ConnectionState.cs index 5dd7c6a..c9fd4de 100644 --- a/src/Impostor.Hazel/ConnectionState.cs +++ b/src/Impostor.Hazel/ConnectionState.cs @@ -1,7 +1,7 @@ namespace Impostor.Hazel { /// - /// Represents the state a is currently in. + /// Represents the state a is currently in. /// public enum ConnectionState { @@ -9,7 +9,7 @@ /// The Connection has either not been established yet or has been disconnected. /// NotConnected, - + /// /// The Connection is currently connecting to an endpoint. /// diff --git a/src/Impostor.Hazel/ConnectionStatistics.cs b/src/Impostor.Hazel/ConnectionStatistics.cs index 4802620..cd7567c 100644 --- a/src/Impostor.Hazel/ConnectionStatistics.cs +++ b/src/Impostor.Hazel/ConnectionStatistics.cs @@ -2,12 +2,13 @@ using System.Threading; [assembly: InternalsVisibleTo("Hazel.Tests")] + namespace Impostor.Hazel { /// - /// Holds statistics about the traffic through a . + /// Holds statistics about the traffic through a . /// - /// + /// public class ConnectionStatistics { private const int ExpectedMTU = 1200; @@ -27,8 +28,8 @@ namespace Impostor.Hazel /// The number of messages sent larger than 576 bytes. This is smaller than most default MTUs. /// /// - /// This is the number of unreliable messages that were sent from the , incremented - /// each time that LogUnreliableSend is called by the Connection. Messages that caused an error are not + /// This is the number of unreliable messages that were sent from the , incremented + /// each time that LogUnreliableSend is called by the Connection. Messages that caused an error are not /// counted and messages are only counted once all other operations in the send are complete. /// public int FragmentableMessagesSent @@ -48,8 +49,8 @@ namespace Impostor.Hazel /// The number of unreliable messages sent. /// /// - /// This is the number of unreliable messages that were sent from the , incremented - /// each time that LogUnreliableSend is called by the Connection. Messages that caused an error are not + /// This is the number of unreliable messages that were sent from the , incremented + /// each time that LogUnreliableSend is called by the Connection. Messages that caused an error are not /// counted and messages are only counted once all other operations in the send are complete. /// public int UnreliableMessagesSent @@ -69,8 +70,8 @@ namespace Impostor.Hazel /// The number of reliable messages sent. /// /// - /// This is the number of reliable messages that were sent from the , incremented - /// each time that LogReliableSend is called by the Connection. Messages that caused an error are not + /// This is the number of reliable messages that were sent from the , incremented + /// each time that LogReliableSend is called by the Connection. Messages that caused an error are not /// counted and messages are only counted once all other operations in the send are complete. /// public int ReliableMessagesSent @@ -90,8 +91,8 @@ namespace Impostor.Hazel /// The number of fragmented messages sent. /// /// - /// This is the number of fragmented messages that were sent from the , incremented - /// each time that LogFragmentedSend is called by the Connection. Messages that caused an error are not + /// This is the number of fragmented messages that were sent from the , incremented + /// each time that LogFragmentedSend is called by the Connection. Messages that caused an error are not /// counted and messages are only counted once all other operations in the send are complete. /// public int FragmentedMessagesSent @@ -111,8 +112,8 @@ namespace Impostor.Hazel /// The number of acknowledgement messages sent. /// /// - /// This is the number of acknowledgements that were sent from the , incremented - /// each time that LogAcknowledgementSend is called by the Connection. Messages that caused an error are not + /// This is the number of acknowledgements that were sent from the , incremented + /// each time that LogAcknowledgementSend is called by the Connection. Messages that caused an error are not /// counted and messages are only counted once all other operations in the send are complete. /// public int AcknowledgementMessagesSent @@ -132,8 +133,8 @@ namespace Impostor.Hazel /// The number of hello messages sent. /// /// - /// This is the number of hello messages that were sent from the , incremented - /// each time that LogHelloSend is called by the Connection. Messages that caused an error are not + /// This is the number of hello messages that were sent from the , incremented + /// each time that LogHelloSend is called by the Connection. Messages that caused an error are not /// counted and messages are only counted once all other operations in the send are complete. /// public int HelloMessagesSent @@ -154,12 +155,12 @@ namespace Impostor.Hazel /// /// /// - /// This is the number of bytes of data (i.e. user bytes) that were sent from the , - /// accumulated each time that LogSend is called by the Connection. Messages that caused an error are not + /// This is the number of bytes of data (i.e. user bytes) that were sent from the , + /// accumulated each time that LogSend is called by the Connection. Messages that caused an error are not /// counted and messages are only counted once all other operations in the send are complete. /// /// - /// For the number of bytes including protocol bytes see . + /// For the number of bytes including protocol bytes see . /// /// public long DataBytesSent @@ -180,13 +181,13 @@ namespace Impostor.Hazel /// /// /// - /// This is the total number of bytes (the data bytes plus protocol bytes) that were sent from the - /// , accumulated each time that LogSend is called by the Connection. Messages that - /// caused an error are not counted and messages are only counted once all other operations in the send are + /// This is the total number of bytes (the data bytes plus protocol bytes) that were sent from the + /// , accumulated each time that LogSend is called by the Connection. Messages that + /// caused an error are not counted and messages are only counted once all other operations in the send are /// complete. /// /// - /// For the number of data bytes excluding protocol bytes see . + /// For the number of data bytes excluding protocol bytes see . /// /// public long TotalBytesSent @@ -212,12 +213,12 @@ namespace Impostor.Hazel return UnreliableMessagesReceived + ReliableMessagesReceived + FragmentedMessagesReceived + AcknowledgementMessagesReceived + helloMessagesReceived; } } - + /// /// The number of unreliable messages received. /// /// - /// This is the number of unreliable messages that were received by the , incremented + /// This is the number of unreliable messages that were received by the , incremented /// each time that LogUnreliableReceive is called by the Connection. Messages are counted before the receive event is invoked. /// public int UnreliableMessagesReceived @@ -237,7 +238,7 @@ namespace Impostor.Hazel /// The number of reliable messages received. /// /// - /// This is the number of reliable messages that were received by the , incremented + /// This is the number of reliable messages that were received by the , incremented /// each time that LogReliableReceive is called by the Connection. Messages are counted before the receive event is invoked. /// public int ReliableMessagesReceived @@ -257,7 +258,7 @@ namespace Impostor.Hazel /// The number of fragmented messages received. /// /// - /// This is the number of fragmented messages that were received by the , incremented + /// This is the number of fragmented messages that were received by the , incremented /// each time that LogFragmentedReceive is called by the Connection. Messages are counted before the receive event is invoked. /// public int FragmentedMessagesReceived @@ -277,7 +278,7 @@ namespace Impostor.Hazel /// The number of acknowledgement messages received. /// /// - /// This is the number of acknowledgement messages that were received by the , incremented + /// This is the number of acknowledgement messages that were received by the , incremented /// each time that LogAcknowledgemntReceive is called by the Connection. Messages are counted before the receive event is invoked. /// public int AcknowledgementMessagesReceived @@ -297,7 +298,7 @@ namespace Impostor.Hazel /// The number of ping messages received. /// /// - /// This is the number of hello messages that were received by the , incremented + /// This is the number of hello messages that were received by the , incremented /// each time that LogHelloReceive is called by the Connection. Messages are counted before the receive event is invoked. /// public int PingMessagesReceived @@ -317,7 +318,7 @@ namespace Impostor.Hazel /// The number of hello messages received. /// /// - /// This is the number of hello messages that were received by the , incremented + /// This is the number of hello messages that were received by the , incremented /// each time that LogHelloReceive is called by the Connection. Messages are counted before the receive event is invoked. /// public int HelloMessagesReceived @@ -338,12 +339,12 @@ namespace Impostor.Hazel /// /// /// - /// This is the number of bytes of data (i.e. user bytes) that were received by the , + /// This is the number of bytes of data (i.e. user bytes) that were received by the , /// accumulated each time that LogReceive is called by the Connection. Messages are counted before the receive /// event is invoked. /// /// - /// For the number of bytes including protocol bytes see . + /// For the number of bytes including protocol bytes see . /// /// public long DataBytesReceived @@ -364,12 +365,12 @@ namespace Impostor.Hazel /// /// /// - /// This is the total number of bytes (the data bytes plus protocol bytes) that were received by the - /// , accumulated each time that LogReceive is called by the Connection. Messages are + /// This is the total number of bytes (the data bytes plus protocol bytes) that were received by the + /// , accumulated each time that LogReceive is called by the Connection. Messages are /// counted before the receive event is invoked. /// /// - /// For the number of data bytes excluding protocol bytes see . + /// For the number of data bytes excluding protocol bytes see . /// /// public long TotalBytesReceived diff --git a/src/Impostor.Hazel/DataReceivedEventArgs.cs b/src/Impostor.Hazel/DataReceivedEventArgs.cs index 9176d8d..d2259e5 100644 --- a/src/Impostor.Hazel/DataReceivedEventArgs.cs +++ b/src/Impostor.Hazel/DataReceivedEventArgs.cs @@ -12,10 +12,10 @@ namespace Impostor.Hazel public readonly IMessageReader Message; /// - /// The the data was sent with. + /// The the data was sent with. /// public readonly MessageType Type; - + public DataReceivedEventArgs(Connection sender, IMessageReader msg, MessageType type) { this.Sender = sender; diff --git a/src/Impostor.Hazel/DisconnectedEventArgs.cs b/src/Impostor.Hazel/DisconnectedEventArgs.cs index d46df4b..4872aea 100644 --- a/src/Impostor.Hazel/DisconnectedEventArgs.cs +++ b/src/Impostor.Hazel/DisconnectedEventArgs.cs @@ -6,13 +6,13 @@ namespace Impostor.Hazel public class DisconnectedEventArgs : EventArgs { /// - /// Optional disconnect reason. May be null. + /// Optional disconnect reason. May be null. /// public readonly string Reason; /// - /// Optional data sent with a disconnect message. May be null. - /// You must not recycle this. If you need the message outside of a callback, you should copy it. + /// Optional data sent with a disconnect message. May be null. + /// You must not recycle this. If you need the message outside of a callback, you should copy it. /// public readonly IMessageReader Message; diff --git a/src/Impostor.Hazel/HazelException.cs b/src/Impostor.Hazel/HazelException.cs index 8c6fc3c..81c8017 100644 --- a/src/Impostor.Hazel/HazelException.cs +++ b/src/Impostor.Hazel/HazelException.cs @@ -8,14 +8,12 @@ namespace Impostor.Hazel [Serializable] public class HazelException : Exception { - internal HazelException(string msg) : base (msg) + internal HazelException(string msg) : base(msg) { - } - internal HazelException(string msg, Exception e) : base (msg, e) + internal HazelException(string msg, Exception e) : base(msg, e) { - } } } diff --git a/src/Impostor.Hazel/IPMode.cs b/src/Impostor.Hazel/IPMode.cs index 5eb6679..3f43958 100644 --- a/src/Impostor.Hazel/IPMode.cs +++ b/src/Impostor.Hazel/IPMode.cs @@ -4,8 +4,8 @@ /// Represents the IP version that a connection or listener will use. /// /// - /// If you wand a client to connect or be able to connect using IPv6 then you should use , - /// this sets the underlying sockets to use IPv6 but still allow IPv4 sockets to connect for backwards compatability + /// If you wand a client to connect or be able to connect using IPv6 then you should use , + /// this sets the underlying sockets to use IPv6 but still allow IPv4 sockets to connect for backwards compatability /// and hence it is the default IPMode in most cases. /// public enum IPMode @@ -16,9 +16,9 @@ IPv4, /// - /// Instruction to use IPv6 only, IPv4 connections will not be able to connect. IPv4 addresses can be connected + /// Instruction to use IPv6 only, IPv4 connections will not be able to connect. IPv4 addresses can be connected /// by converting to IPv6 addresses. /// - IPv6 + IPv6, } } diff --git a/src/Impostor.Hazel/IRecyclable.cs b/src/Impostor.Hazel/IRecyclable.cs index 69be122..0ddc04c 100644 --- a/src/Impostor.Hazel/IRecyclable.cs +++ b/src/Impostor.Hazel/IRecyclable.cs @@ -3,7 +3,7 @@ /// /// Interface for all items that can be returned to an object pool. /// - /// + /// public interface IRecyclable { /// diff --git a/src/Impostor.Hazel/MessageReader.cs b/src/Impostor.Hazel/MessageReader.cs index 317e45b..969e41b 100644 --- a/src/Impostor.Hazel/MessageReader.cs +++ b/src/Impostor.Hazel/MessageReader.cs @@ -78,7 +78,7 @@ namespace Impostor.Hazel public bool ReadBoolean() { - byte val = FastByte(); + var val = FastByte(); return val != 0; } @@ -159,13 +159,13 @@ namespace Impostor.Hazel public uint ReadPackedUInt32() { - bool readMore = true; - int shift = 0; + var readMore = true; + var shift = 0; uint output = 0; while (readMore) { - byte b = FastByte(); + var b = FastByte(); if (b >= 0x80) { readMore = true; @@ -185,8 +185,8 @@ namespace Impostor.Hazel public void CopyTo(IMessageWriter writer) { - writer.Write((ushort) Length); - writer.Write((byte) Tag); + writer.Write((ushort)Length); + writer.Write((byte)Tag); writer.Write(Buffer.AsMemory(Offset, Length)); } @@ -213,7 +213,7 @@ namespace Impostor.Hazel System.Buffer.BlockCopy(Buffer, offsetEnd, Buffer, offsetStart, lengthToCopy); - ((MessageReader) message).Parent.AdjustLength(message.Offset, message.Length + 3); + ((MessageReader)message).Parent.AdjustLength(message.Offset, message.Length + 3); } private void AdjustLength(int offset, int amount) @@ -255,9 +255,9 @@ namespace Impostor.Hazel public Vector2 ReadVector2() { const float range = 50f; - - var x = ReadUInt16() / (float) ushort.MaxValue; - var y = ReadUInt16() / (float) ushort.MaxValue; + + var x = ReadUInt16() / (float)ushort.MaxValue; + var y = ReadUInt16() / (float)ushort.MaxValue; return new Vector2(Mathf.Lerp(-range, range, x), Mathf.Lerp(-range, range, y)); } diff --git a/src/Impostor.Hazel/MessageWriter.cs b/src/Impostor.Hazel/MessageWriter.cs index a7b57e7..bb71a71 100644 --- a/src/Impostor.Hazel/MessageWriter.cs +++ b/src/Impostor.Hazel/MessageWriter.cs @@ -1,12 +1,11 @@ -using Impostor.Api.Games; -using Impostor.Api.Net.Messages; - -using System; +using System; using System.Collections.Generic; using System.Net; using System.Numerics; using System.Text; +using Impostor.Api.Games; using Impostor.Api.Net.Inner; +using Impostor.Api.Net.Messages; using Impostor.Api.Unity; namespace Impostor.Hazel @@ -39,7 +38,7 @@ namespace Impostor.Hazel { if (includeHeader) { - byte[] output = new byte[this.Length]; + var output = new byte[this.Length]; System.Buffer.BlockCopy(this.Buffer, 0, output, 0, this.Length); return output; } @@ -48,17 +47,17 @@ namespace Impostor.Hazel switch (this.SendOption) { case MessageType.Reliable: - { - byte[] output = new byte[this.Length - 3]; - System.Buffer.BlockCopy(this.Buffer, 3, output, 0, this.Length - 3); - return output; - } + { + var output = new byte[this.Length - 3]; + System.Buffer.BlockCopy(this.Buffer, 3, output, 0, this.Length - 3); + return output; + } case MessageType.Unreliable: - { - byte[] output = new byte[this.Length - 1]; - System.Buffer.BlockCopy(this.Buffer, 1, output, 0, this.Length - 1); - return output; - } + { + var output = new byte[this.Length - 1]; + System.Buffer.BlockCopy(this.Buffer, 1, output, 0, this.Length - 1); + return output; + } default: throw new ArgumentOutOfRangeException(); } @@ -67,7 +66,6 @@ namespace Impostor.Hazel throw new NotImplementedException(); } - /// /// The option specifying how the message should be sent. public static MessageWriter Get(MessageType sendOption = MessageType.Unreliable) { @@ -106,8 +104,8 @@ namespace Impostor.Hazel public void Write(Vector2 vector) { - Write((ushort)(Mathf.ReverseLerp(vector.X) * (double) ushort.MaxValue)); - Write((ushort)(Mathf.ReverseLerp(vector.Y) * (double) ushort.MaxValue)); + Write((ushort)(Mathf.ReverseLerp(vector.X) * (double)ushort.MaxValue)); + Write((ushort)(Mathf.ReverseLerp(vector.Y) * (double)ushort.MaxValue)); } /// @@ -122,7 +120,7 @@ namespace Impostor.Hazel public void EndMessage() { var lastMessageStart = messageStarts.Pop(); - ushort length = (ushort)(this.Position - lastMessageStart - 3); // Minus length and type byte + var length = (ushort)(this.Position - lastMessageStart - 3); // Minus length and type byte this.Buffer[lastMessageStart] = (byte)length; this.Buffer[lastMessageStart + 1] = (byte)(length >> 8); } @@ -215,7 +213,7 @@ namespace Impostor.Hazel { fixed (byte* ptr = &this.Buffer[this.Position]) { - byte* valuePtr = (byte*)&value; + var valuePtr = (byte*)&value; *ptr = *valuePtr; *(ptr + 1) = *(valuePtr + 1); @@ -302,7 +300,7 @@ namespace Impostor.Hazel { do { - byte b = (byte)(value & 0xFF); + var b = (byte)(value & 0xFF); if (value >= 0x80) { b |= 0x80; @@ -317,7 +315,7 @@ namespace Impostor.Hazel public void Write(MessageWriter msg, bool includeHeader) { - int offset = 0; + var offset = 0; if (!includeHeader) { switch (msg.SendOption) @@ -340,8 +338,8 @@ namespace Impostor.Hazel byte b; unsafe { - int i = 1; - byte* bp = (byte*)&i; + var i = 1; + var bp = (byte*)&i; b = *bp; } diff --git a/src/Impostor.Hazel/NetworkConnection.cs b/src/Impostor.Hazel/NetworkConnection.cs index 9e81c5c..b530f01 100644 --- a/src/Impostor.Hazel/NetworkConnection.cs +++ b/src/Impostor.Hazel/NetworkConnection.cs @@ -12,17 +12,17 @@ namespace Impostor.Hazel ReceivedZeroBytes, PingsWithoutResponse, ReliablePacketWithoutResponse, - ConnectionDisconnected + ConnectionDisconnected, } /// - /// Abstract base class for a to a remote end point via a network protocol like TCP or UDP. + /// Abstract base class for a to a remote end point via a network protocol like TCP or UDP. /// - /// + /// public abstract class NetworkConnection : Connection { /// - /// An event that gives us a chance to send well-formed disconnect messages to clients when an internal disconnect happens. + /// An event that gives us a chance to send well-formed disconnect messages to clients when an internal disconnect happens. /// public Func OnInternalDisconnect; @@ -30,8 +30,8 @@ namespace Impostor.Hazel /// The remote end point of this connection. /// /// - /// This is the end point of the other device given as an rather than a generic - /// as the base does. + /// This is the end point of the other device given as an rather than a generic + /// as the base does. /// public IPEndPoint RemoteEndPoint { get; protected set; } @@ -67,14 +67,14 @@ namespace Impostor.Hazel } /// - /// Called when socket is disconnected internally + /// Called when socket is disconnected internally /// internal async ValueTask DisconnectInternal(HazelInternalErrors error, string reason) { var handler = this.OnInternalDisconnect; if (handler != null) { - MessageWriter messageToRemote = handler(error); + var messageToRemote = handler(error); if (messageToRemote != null) { try diff --git a/src/Impostor.Hazel/NetworkConnectionListener.cs b/src/Impostor.Hazel/NetworkConnectionListener.cs index e1d7ffa..e2824b1 100644 --- a/src/Impostor.Hazel/NetworkConnectionListener.cs +++ b/src/Impostor.Hazel/NetworkConnectionListener.cs @@ -3,9 +3,9 @@ namespace Impostor.Hazel { /// - /// Abstract base class for a for network based connections. + /// Abstract base class for a for network based connections. /// - /// + /// public abstract class NetworkConnectionListener : ConnectionListener { /// diff --git a/src/Impostor.Hazel/NewConnectionEventArgs.cs b/src/Impostor.Hazel/NewConnectionEventArgs.cs index be9e7a2..77ec05d 100644 --- a/src/Impostor.Hazel/NewConnectionEventArgs.cs +++ b/src/Impostor.Hazel/NewConnectionEventArgs.cs @@ -5,13 +5,13 @@ namespace Impostor.Hazel public struct NewConnectionEventArgs { /// - /// The data received from the client in the handshake. - /// This data is yours. Remember to recycle it. + /// The data received from the client in the handshake. + /// This data is yours. Remember to recycle it. /// public readonly IMessageReader HandshakeData; /// - /// The to the new client. + /// The to the new client. /// public readonly Connection Connection; diff --git a/src/Impostor.Hazel/ObjectPoolCustom.cs b/src/Impostor.Hazel/ObjectPoolCustom.cs index 5c9ef9b..f1256eb 100644 --- a/src/Impostor.Hazel/ObjectPoolCustom.cs +++ b/src/Impostor.Hazel/ObjectPoolCustom.cs @@ -8,7 +8,7 @@ namespace Impostor.Hazel /// A fairly simple object pool for items that will be created a lot. /// /// The type that is pooled. - /// + /// public sealed class ObjectPoolCustom where T : IRecyclable { private int numberCreated; @@ -32,7 +32,7 @@ namespace Impostor.Hazel /// /// private readonly Func objectFactory; - + /// /// Internal constructor for our ObjectPool. /// @@ -48,7 +48,7 @@ namespace Impostor.Hazel internal T GetObject() { #if HAZEL_BAG - if (!pool.TryTake(out T item)) + if (!pool.TryTake(out var item)) { Interlocked.Increment(ref numberCreated); item = objectFactory.Invoke(); @@ -85,7 +85,7 @@ namespace Impostor.Hazel /// The item to return. internal void PutObject(T item) { - if (inuse.TryRemove(item, out bool b)) + if (inuse.TryRemove(item, out var b)) { #if HAZEL_BAG pool.Add(item); diff --git a/src/Impostor.Hazel/Udp/SendOptionInternal.cs b/src/Impostor.Hazel/Udp/SendOptionInternal.cs index c0c4e21..11baa85 100644 --- a/src/Impostor.Hazel/Udp/SendOptionInternal.cs +++ b/src/Impostor.Hazel/Udp/SendOptionInternal.cs @@ -11,7 +11,7 @@ Hello = 8, /// - /// A single byte of continued existence + /// A single byte of continued existence /// Ping = 12, diff --git a/src/Impostor.Hazel/Udp/UdpBroadcastListener.cs b/src/Impostor.Hazel/Udp/UdpBroadcastListener.cs index ed7b68d..3c768ef 100644 --- a/src/Impostor.Hazel/Udp/UdpBroadcastListener.cs +++ b/src/Impostor.Hazel/Udp/UdpBroadcastListener.cs @@ -89,21 +89,21 @@ namespace Impostor.Hazel.Udp return; } - if (numBytes < 3 + if (numBytes < 3 || buffer[0] != 4 || buffer[1] != 2) { this.StartListen(); return; } - IPEndPoint ipEnd = (IPEndPoint)endpt; - string data = UTF8Encoding.UTF8.GetString(buffer, 2, numBytes - 2); - int dataHash = data.GetHashCode(); + var ipEnd = (IPEndPoint)endpt; + var data = UTF8Encoding.UTF8.GetString(buffer, 2, numBytes - 2); + var dataHash = data.GetHashCode(); lock (packets) { - bool found = false; - for (int i = 0; i < this.packets.Count; ++i) + var found = false; + for (var i = 0; i < this.packets.Count; ++i) { var pkt = this.packets[i]; if (pkt == null || pkt.Data == null) @@ -146,11 +146,17 @@ namespace Impostor.Hazel.Udp { if (this.socket != null) { - try { this.socket.Shutdown(SocketShutdown.Both); } catch { } - try { this.socket.Close(); } catch { } - try { this.socket.Dispose(); } catch { } + try { this.socket.Shutdown(SocketShutdown.Both); } + catch { } + + try { this.socket.Close(); } + catch { } + + try { this.socket.Dispose(); } + catch { } + this.socket = null; } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Hazel/Udp/UdpBroadcaster.cs b/src/Impostor.Hazel/Udp/UdpBroadcaster.cs index 5fa1cca..32f0e18 100644 --- a/src/Impostor.Hazel/Udp/UdpBroadcaster.cs +++ b/src/Impostor.Hazel/Udp/UdpBroadcaster.cs @@ -26,7 +26,7 @@ namespace Impostor.Hazel.Udp /// public void SetData(string data) { - int len = UTF8Encoding.UTF8.GetByteCount(data); + var len = UTF8Encoding.UTF8.GetByteCount(data); this.data = new byte[len + 2]; this.data[0] = 4; this.data[1] = 2; @@ -69,11 +69,17 @@ namespace Impostor.Hazel.Udp { if (this.socket != null) { - try { this.socket.Shutdown(SocketShutdown.Both); } catch { } - try { this.socket.Close(); } catch { } - try { this.socket.Dispose(); } catch { } + try { this.socket.Shutdown(SocketShutdown.Both); } + catch { } + + try { this.socket.Close(); } + catch { } + + try { this.socket.Dispose(); } + catch { } + this.socket = null; } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Hazel/Udp/UdpClientConnection.cs b/src/Impostor.Hazel/Udp/UdpClientConnection.cs index 5125ebe..cb27e24 100644 --- a/src/Impostor.Hazel/Udp/UdpClientConnection.cs +++ b/src/Impostor.Hazel/Udp/UdpClientConnection.cs @@ -1,9 +1,7 @@ using System; -using System.Buffers; using System.Net; using System.Net.Sockets; using System.Threading; -using System.Threading.Channels; using System.Threading.Tasks; using Impostor.Api.Net.Messages; using Microsoft.Extensions.ObjectPool; @@ -14,7 +12,7 @@ namespace Impostor.Hazel.Udp /// /// Represents a client's connection to a server that uses the UDP protocol. /// - /// + /// public sealed class UdpClientConnection : UdpConnection { private static readonly ILogger Logger = Log.ForContext(); @@ -31,7 +29,7 @@ namespace Impostor.Hazel.Udp /// /// Creates a new UdpClientConnection. /// - /// A to connect to. + /// A to connect to. public UdpClientConnection(IPEndPoint remoteEndPoint, ObjectPool readerPool, IPMode ipMode = IPMode.IPv4) : base(null, readerPool) { EndPoint = remoteEndPoint; @@ -40,7 +38,7 @@ namespace Impostor.Hazel.Udp _socket = new UdpClient { - DontFragment = false + DontFragment = false, }; _reliablePacketTimer = new Timer(ManageReliablePacketsInternal, null, 100, Timeout.Infinite); @@ -213,8 +211,11 @@ namespace Impostor.Hazel.Udp { State = ConnectionState.NotConnected; - try { _socket.Close(); } catch { } - try { _socket.Dispose(); } catch { } + try { _socket.Close(); } + catch { } + + try { _socket.Dispose(); } + catch { } _reliablePacketTimer.Dispose(); _connectWaitLock.Dispose(); diff --git a/src/Impostor.Hazel/Udp/UdpConnection.KeepAlive.cs b/src/Impostor.Hazel/Udp/UdpConnection.KeepAlive.cs index a73291b..e8303a4 100644 --- a/src/Impostor.Hazel/Udp/UdpConnection.KeepAlive.cs +++ b/src/Impostor.Hazel/Udp/UdpConnection.KeepAlive.cs @@ -8,7 +8,6 @@ namespace Impostor.Hazel.Udp { partial class UdpConnection { - /// /// Class to hold packet data /// @@ -58,6 +57,7 @@ namespace Impostor.Hazel.Udp ResetKeepAliveTimer(); } } + private int keepAliveInterval = 1500; public int MissingPingsUntilDisconnect { get; set; } = 6; @@ -109,9 +109,9 @@ namespace Impostor.Hazel.Udp // pings should cause a disconnect. private async ValueTask SendPing() { - ushort id = (ushort)Interlocked.Increment(ref lastIDAllocated); + var id = (ushort)Interlocked.Increment(ref lastIDAllocated); - byte[] bytes = new byte[3]; + var bytes = new byte[3]; bytes[0] = (byte)UdpSendOption.Ping; bytes[1] = (byte)(id >> 8); bytes[2] = (byte)id; @@ -164,4 +164,4 @@ namespace Impostor.Hazel.Udp } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Hazel/Udp/UdpConnection.Reliable.cs b/src/Impostor.Hazel/Udp/UdpConnection.Reliable.cs index 7f43926..9c13f22 100644 --- a/src/Impostor.Hazel/Udp/UdpConnection.Reliable.cs +++ b/src/Impostor.Hazel/Udp/UdpConnection.Reliable.cs @@ -15,25 +15,25 @@ namespace Impostor.Hazel.Udp /// /// /// - /// For reliable delivery data is resent at specified intervals unless an acknowledgement is received from the + /// For reliable delivery data is resent at specified intervals unless an acknowledgement is received from the /// receiving device. The ResendTimeout specifies the interval between the packets being resent, each time a packet - /// is resent the interval is increased for that packet until the duration exceeds the value. + /// is resent the interval is increased for that packet until the duration exceeds the value. /// /// - /// Setting this to its default of 0 will mean the timeout is 2 times the value of the average ping, usually + /// Setting this to its default of 0 will mean the timeout is 2 times the value of the average ping, usually /// resulting in a more dynamic resend that responds to endpoints on slower or faster connections. /// /// public volatile int ResendTimeout = 0; /// - /// Max number of times to resend. 0 == no limit + /// Max number of times to resend. 0 == no limit /// public volatile int ResendLimit = 0; /// - /// A compounding multiplier to back off resend timeout. - /// Applied to ping before first timeout when ResendTimeout == 0. + /// A compounding multiplier to back off resend timeout. + /// Applied to ping before first timeout when ResendTimeout == 0. /// public volatile float ResendPingMultiplier = 2; @@ -48,7 +48,7 @@ namespace Impostor.Hazel.Udp internal ConcurrentDictionary reliableDataPacketsSent = new ConcurrentDictionary(); /// - /// Packet ids that have not been received, but are expected. + /// Packet ids that have not been received, but are expected. /// private HashSet reliableDataPacketsMissing = new HashSet(); @@ -63,7 +63,7 @@ namespace Impostor.Hazel.Udp /// Returns the average ping to this endpoint. /// /// - /// This returns the average ping for a one-way trip as calculated from the reliable packets that have been sent + /// This returns the average ping for a one-way trip as calculated from the reliable packets that have been sent /// and acknowledged by the endpoint. /// public float AveragePingMs = 500; @@ -72,7 +72,7 @@ namespace Impostor.Hazel.Udp /// The maximum times a message should be resent before marking the endpoint as disconnected. /// /// - /// Reliable packets will be resent at an interval defined in for the number of times + /// Reliable packets will be resent at an interval defined in for the number of times /// specified here. Once a packet has been retransmitted this number of times and has not been acknowledged the /// connection will be marked as disconnected and the Disconnected event /// will be invoked. @@ -136,10 +136,10 @@ namespace Impostor.Hazel.Udp var connection = this.Connection; if (!this.Acknowledged && connection != null) { - long lifetime = this.Stopwatch.ElapsedMilliseconds; + var lifetime = this.Stopwatch.ElapsedMilliseconds; if (lifetime >= connection.DisconnectTimeout) { - if (connection.reliableDataPacketsSent.TryRemove(this.Id, out Packet self)) + if (connection.reliableDataPacketsSent.TryRemove(this.Id, out var self)) { await connection.DisconnectInternal(HazelInternalErrors.ReliablePacketWithoutResponse, $"Reliable packet {self.Id} (size={this.Length}) was not ack'd after {lifetime}ms ({self.Retransmissions} resends)"); @@ -155,7 +155,7 @@ namespace Impostor.Hazel.Udp if (connection.ResendLimit != 0 && this.Retransmissions > connection.ResendLimit) { - if (connection.reliableDataPacketsSent.TryRemove(this.Id, out Packet self)) + if (connection.reliableDataPacketsSent.TryRemove(this.Id, out var self)) { await connection.DisconnectInternal(HazelInternalErrors.ReliablePacketWithoutResponse, $"Reliable packet {self.Id} (size={this.Length}) was not ack'd after {self.Retransmissions} resends ({lifetime}ms)"); @@ -196,12 +196,12 @@ namespace Impostor.Hazel.Udp internal async ValueTask ManageReliablePackets() { - int output = 0; + var output = 0; if (this.reliableDataPacketsSent.Count > 0) { foreach (var kvp in this.reliableDataPacketsSent) { - Packet pkt = kvp.Value; + var pkt = kvp.Value; try { @@ -222,12 +222,12 @@ namespace Impostor.Hazel.Udp /// The callback to make once the packet has been acknowledged. protected void AttachReliableID(byte[] buffer, int offset, int sendLength, Action ackCallback = null) { - ushort id = (ushort)Interlocked.Increment(ref lastIDAllocated); + var id = (ushort)Interlocked.Increment(ref lastIDAllocated); buffer[offset] = (byte)(id >> 8); buffer[offset + 1] = (byte)id; - Packet packet = Packet.GetObject(); + var packet = Packet.GetObject(); packet.Set( id, this, @@ -260,7 +260,7 @@ namespace Impostor.Hazel.Udp //Inform keepalive not to send for a while ResetKeepAliveTimer(); - byte[] bytes = new byte[data.Length + 3]; + var bytes = new byte[data.Length + 3]; //Add message type bytes[0] = sendOption; @@ -333,35 +333,35 @@ namespace Impostor.Hazel.Udp * * So... */ - + var result = true; lock (reliableDataPacketsMissing) { //Calculate overwritePointer - ushort overwritePointer = (ushort)(reliableReceiveLast - 32768); + var overwritePointer = (ushort)(reliableReceiveLast - 32768); //Calculate if it is a new packet by examining if it is within the range bool isNew; if (overwritePointer < reliableReceiveLast) - isNew = id > reliableReceiveLast || id <= overwritePointer; //Figure (2) + isNew = id > reliableReceiveLast || id <= overwritePointer; //Figure (2) else - isNew = id > reliableReceiveLast && id <= overwritePointer; //Figure (3) - + isNew = id > reliableReceiveLast && id <= overwritePointer; //Figure (3) + //If it's new or we've not received anything yet if (isNew) { // Mark items between the most recent receive and the id received as missing if (id > reliableReceiveLast) { - for (ushort i = (ushort)(reliableReceiveLast + 1); i < id; i++) + for (var i = (ushort)(reliableReceiveLast + 1); i < id; i++) { reliableDataPacketsMissing.Add(i); } } else { - int cnt = (ushort.MaxValue - reliableReceiveLast) + id; + var cnt = (ushort.MaxValue - reliableReceiveLast) + id; for (ushort i = 1; i < cnt; ++i) { reliableDataPacketsMissing.Add((ushort)(i + reliableReceiveLast)); @@ -371,7 +371,7 @@ namespace Impostor.Hazel.Udp //Update the most recently received reliableReceiveLast = id; } - + //Else it could be a missing packet else { @@ -382,7 +382,7 @@ namespace Impostor.Hazel.Udp } } } - + //Send an acknowledgement await SendAck(id); @@ -397,13 +397,13 @@ namespace Impostor.Hazel.Udp { this.pingsSinceAck = 0; - ushort id = (ushort)((bytes[1] << 8) + bytes[2]); + var id = (ushort)((bytes[1] << 8) + bytes[2]); AcknowledgeMessageId(id); if (bytes.Length == 4) { - byte recentPackets = bytes[3]; - for (int i = 1; i <= 8; ++i) + var recentPackets = bytes[3]; + for (var i = 1; i <= 8; ++i) { if ((recentPackets & 1) != 0) { @@ -420,7 +420,7 @@ namespace Impostor.Hazel.Udp private void AcknowledgeMessageId(ushort id) { // Dispose of timer and remove from dictionary - if (reliableDataPacketsSent.TryRemove(id, out Packet packet)) + if (reliableDataPacketsSent.TryRemove(id, out var packet)) { float rt = packet.Stopwatch.ElapsedMilliseconds; @@ -432,7 +432,7 @@ namespace Impostor.Hazel.Udp this.AveragePingMs = Math.Max(50, this.AveragePingMs * .7f + rt * .3f); } } - else if (this.activePingPackets.TryRemove(id, out PingPacket pingPkt)) + else if (this.activePingPackets.TryRemove(id, out var pingPkt)) { float rt = pingPkt.Stopwatch.ElapsedMilliseconds; @@ -455,7 +455,7 @@ namespace Impostor.Hazel.Udp byte recentPackets = 0; lock (this.reliableDataPacketsMissing) { - for (int i = 1; i <= 8; ++i) + for (var i = 1; i <= 8; ++i) { if (!this.reliableDataPacketsMissing.Contains((ushort)(id - i))) { @@ -464,12 +464,12 @@ namespace Impostor.Hazel.Udp } } - byte[] bytes = new byte[] + var bytes = new byte[] { (byte)UdpSendOption.Acknowledgement, (byte)(id >> 8), (byte)(id >> 0), - recentPackets + recentPackets, }; try diff --git a/src/Impostor.Hazel/Udp/UdpConnection.cs b/src/Impostor.Hazel/Udp/UdpConnection.cs index 5288d3c..4106bfe 100644 --- a/src/Impostor.Hazel/Udp/UdpConnection.cs +++ b/src/Impostor.Hazel/Udp/UdpConnection.cs @@ -34,7 +34,7 @@ namespace Impostor.Hazel.Udp Pipeline = Channel.CreateUnbounded(new UnboundedChannelOptions { SingleReader = true, - SingleWriter = true + SingleWriter = true, }); } @@ -113,13 +113,13 @@ namespace Impostor.Hazel.Udp /// protected abstract ValueTask WriteBytesToConnection(byte[] bytes, int length); - /// + /// public override async ValueTask SendAsync(IMessageWriter msg) { if (this._state != ConnectionState.Connected) throw new InvalidOperationException("Could not send data as this Connection is not connected. Did you disconnect?"); - byte[] buffer = new byte[msg.Length]; + var buffer = new byte[msg.Length]; Buffer.BlockCopy(msg.Buffer, 0, buffer, 0, msg.Length); switch (msg.SendOption) @@ -139,13 +139,13 @@ namespace Impostor.Hazel.Udp } } - /// + /// /// /// /// - /// Udp connections can currently send messages using and - /// . Fragmented messages are not currently supported and will default to - /// until implemented. + /// Udp connections can currently send messages using and + /// . Fragmented messages are not currently supported and will default to + /// until implemented. /// /// public override async ValueTask SendBytes(byte[] bytes, MessageType sendOption = MessageType.Unreliable) @@ -153,12 +153,12 @@ namespace Impostor.Hazel.Udp //Add header information and send await HandleSend(bytes, (byte)sendOption); } - + /// /// Handles the reliable/fragmented sending from this connection. /// /// The data being sent. - /// The specified as its byte value. + /// The specified as its byte value. /// The callback to invoke when this packet is acknowledged. /// The bytes that should actually be sent. protected async ValueTask HandleSend(byte[] data, byte sendOption, Action ackCallback = null) @@ -170,7 +170,7 @@ namespace Impostor.Hazel.Udp case (byte)UdpSendOption.Hello: await ReliableSend(sendOption, data, ackCallback); break; - + //Treat all else as unreliable default: await UnreliableSend(sendOption, data); @@ -226,14 +226,16 @@ namespace Impostor.Hazel.Udp { await DisconnectRemote("The remote sent a disconnect request", reader); } + break; - + //Treat everything else as unreliable default: using (var reader = message.Copy(1)) { await InvokeDataReceived(reader, MessageType.Unreliable); } + Statistics.LogUnreliableReceive(message.Length - 1, message.Length); break; } @@ -258,7 +260,7 @@ namespace Impostor.Hazel.Udp /// async ValueTask UnreliableSend(byte sendOption, byte[] data, int offset, int length) { - byte[] bytes = new byte[length + 1]; + var bytes = new byte[length + 1]; //Add message type bytes[0] = sendOption; @@ -293,8 +295,8 @@ namespace Impostor.Hazel.Udp return HandleSend(actualBytes, (byte)UdpSendOption.Hello, acknowledgeCallback); } - - /// + + /// protected override void Dispose(bool disposing) { if (disposing) diff --git a/src/Impostor.Hazel/Udp/UdpConnectionListener.cs b/src/Impostor.Hazel/Udp/UdpConnectionListener.cs index 573a00c..782bf61 100644 --- a/src/Impostor.Hazel/Udp/UdpConnectionListener.cs +++ b/src/Impostor.Hazel/Udp/UdpConnectionListener.cs @@ -4,7 +4,6 @@ using System.Collections.Concurrent; using System.Net; using System.Net.Sockets; using System.Threading; -using System.Threading.Channels; using System.Threading.Tasks; using Microsoft.Extensions.ObjectPool; using Serilog; @@ -20,11 +19,12 @@ namespace Impostor.Hazel.Udp private static readonly ILogger Logger = Log.ForContext(); /// - /// A callback for early connection rejection. - /// * Return false to reject connection. - /// * A null response is ok, we just won't send anything. + /// A callback for early connection rejection. + /// * Return false to reject connection. + /// * A null response is ok, we just won't send anything. /// public AcceptConnectionCheck AcceptConnection; + public delegate bool AcceptConnectionCheck(IPEndPoint endPoint, byte[] input, out byte[] response); private readonly UdpClient _socket; @@ -37,7 +37,7 @@ namespace Impostor.Hazel.Udp private Task _executingTask; /// - /// Creates a new UdpConnectionListener for the given , port and . + /// Creates a new UdpConnectionListener for the given , port and . /// /// The endpoint to listen on. /// @@ -72,7 +72,7 @@ namespace Impostor.Hazel.Udp } public int ConnectionCount => this._allConnections.Count; - + private async void ManageReliablePackets(object state) { foreach (var kvp in _allConnections) diff --git a/src/Impostor.Hazel/Udp/UdpConnectionRateLimit.cs b/src/Impostor.Hazel/Udp/UdpConnectionRateLimit.cs index 64881d3..b90d7b1 100644 --- a/src/Impostor.Hazel/Udp/UdpConnectionRateLimit.cs +++ b/src/Impostor.Hazel/Udp/UdpConnectionRateLimit.cs @@ -72,4 +72,4 @@ namespace Impostor.Hazel.Udp _timer.Dispose(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Hazel/Udp/UdpServerConnection.cs b/src/Impostor.Hazel/Udp/UdpServerConnection.cs index 8d3426e..8c6cc06 100644 --- a/src/Impostor.Hazel/Udp/UdpServerConnection.cs +++ b/src/Impostor.Hazel/Udp/UdpServerConnection.cs @@ -9,14 +9,14 @@ namespace Impostor.Hazel.Udp /// /// Represents a servers's connection to a client that uses the UDP protocol. /// - /// + /// internal sealed class UdpServerConnection : UdpConnection { /// /// The connection listener that we use the socket of. /// /// - /// Udp server connections utilize the same socket in the listener for sends/receives, this is the listener that + /// Udp server connections utilize the same socket in the listener for sends/receives, this is the listener that /// created this connection and is hence the listener this conenction sends and receives via. /// public UdpConnectionListener Listener { get; private set; } @@ -63,7 +63,7 @@ namespace Impostor.Hazel.Udp if (this._state != ConnectionState.Connected) return false; this._state = ConnectionState.NotConnected; } - + var bytes = EmptyDisconnectBytes; if (data != null && data.Length > 0) { diff --git a/src/Impostor.Patcher/Impostor.Patcher.Cli/Program.cs b/src/Impostor.Patcher/Impostor.Patcher.Cli/Program.cs index 76653a1..26c00d9 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Cli/Program.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.Cli/Program.cs @@ -23,7 +23,7 @@ namespace Impostor.Patcher.Cli "--name", () => AmongUsModifier.DefaultRegionName, "Name for server region" - ) + ), }; rootCommand.Handler = CommandHandler.Create((address, name) => diff --git a/src/Impostor.Patcher/Impostor.Patcher.Shared/AmongUsModifier.cs b/src/Impostor.Patcher/Impostor.Patcher.Shared/AmongUsModifier.cs index 7c1ced2..d3b6de7 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Shared/AmongUsModifier.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.Shared/AmongUsModifier.cs @@ -63,7 +63,7 @@ namespace Impostor.Patcher.Shared var libraries = new List { - steamApps + steamApps, }; var vdf = Path.Combine(steamApps, "libraryfolders.vdf"); @@ -174,7 +174,7 @@ namespace Impostor.Patcher.Shared var ip = ipAddress.ToString(); var region = new RegionInfo(RegionName, ip, new[] { - new ServerInfo($"{RegionName}-Master-1", ip, port) + new ServerInfo($"{RegionName}-Master-1", ip, port), }); region.Serialize(writer); @@ -246,4 +246,4 @@ namespace Impostor.Patcher.Shared public event EventHandler Error; public event EventHandler Saved; } -} \ No newline at end of file +} diff --git a/src/Impostor.Patcher/Impostor.Patcher.Shared/Configuration.cs b/src/Impostor.Patcher/Impostor.Patcher.Shared/Configuration.cs index b256156..56bf297 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Shared/Configuration.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.Shared/Configuration.cs @@ -62,4 +62,4 @@ namespace Impostor.Patcher.Shared } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/ErrorEventArgs.cs b/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/ErrorEventArgs.cs index 7211d5d..b7925d3 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/ErrorEventArgs.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/ErrorEventArgs.cs @@ -11,4 +11,4 @@ namespace Impostor.Patcher.Shared.Events public string Message { get; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/SavedEventArgs.cs b/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/SavedEventArgs.cs index c91d071..a0f08ae 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/SavedEventArgs.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.Shared/Events/SavedEventArgs.cs @@ -13,4 +13,4 @@ namespace Impostor.Patcher.Shared.Events public string IpAddress { get; } public ushort Port { get; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/RegionInfo.cs b/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/RegionInfo.cs index 01b74d1..77fbb6b 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/RegionInfo.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/RegionInfo.cs @@ -45,4 +45,4 @@ namespace Impostor.Patcher.Shared.Innersloth 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 index 7203c84..4768377 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/ServerInfo.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.Shared/Innersloth/ServerInfo.cs @@ -15,7 +15,7 @@ namespace Impostor.Patcher.Shared.Innersloth Ip = ip; Port = port; } - + public void Serialize(BinaryWriter writer) { writer.Write(Name); @@ -30,8 +30,8 @@ namespace Impostor.Patcher.Shared.Innersloth 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.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.Designer.cs b/src/Impostor.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.Designer.cs index 0f6320b..4667c45 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.Designer.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.Designer.cs @@ -81,7 +81,7 @@ this.lblUrl.Name = "lblUrl"; this.lblUrl.Size = new System.Drawing.Size(212, 13); this.lblUrl.TabIndex = 5; - this.lblUrl.Text = "https://github.com/AeonLucid/Impostor"; + this.lblUrl.Text = "https://github.com/Impostor/Impostor"; this.lblUrl.Click += new System.EventHandler(this.lblUrl_Click); // // label3 @@ -138,4 +138,4 @@ private System.Windows.Forms.Label label3; private System.Windows.Forms.ComboBox comboIp; } -} \ No newline at end of file +} diff --git a/src/Impostor.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.cs b/src/Impostor.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.cs index 5c06669..dd3696f 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.WinForms/Forms/FrmMain.cs @@ -95,7 +95,7 @@ namespace Impostor.Patcher.WinForms.Forms private void lblUrl_Click(object sender, EventArgs e) { - Process.Start("https://github.com/AeonLucid/Impostor"); + Process.Start("https://github.com/Impostor/Impostor"); } private void RefreshComboIps() @@ -111,4 +111,4 @@ namespace Impostor.Patcher.WinForms.Forms } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Patcher/Impostor.Patcher.WinForms/Program.cs b/src/Impostor.Patcher/Impostor.Patcher.WinForms/Program.cs index 7ca9035..f481490 100644 --- a/src/Impostor.Patcher/Impostor.Patcher.WinForms/Program.cs +++ b/src/Impostor.Patcher/Impostor.Patcher.WinForms/Program.cs @@ -14,4 +14,4 @@ namespace Impostor.Patcher.WinForms Application.Run(new FrmMain()); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Plugins.Debugger/DebugPlugin.cs b/src/Impostor.Plugins.Debugger/DebugPlugin.cs index 8f57e89..a978619 100644 --- a/src/Impostor.Plugins.Debugger/DebugPlugin.cs +++ b/src/Impostor.Plugins.Debugger/DebugPlugin.cs @@ -10,4 +10,4 @@ namespace Impostor.Plugins.Debugger public class DebugPlugin : PluginBase { } -} \ No newline at end of file +} diff --git a/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs b/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs index cc36ce6..c39ce31 100644 --- a/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs +++ b/src/Impostor.Plugins.Debugger/DebugPluginStartup.cs @@ -32,4 +32,4 @@ namespace Impostor.Plugins.Debugger }); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Plugins.Example/ExamplePlugin.cs b/src/Impostor.Plugins.Example/ExamplePlugin.cs index 139e42c..73fea6a 100644 --- a/src/Impostor.Plugins.Example/ExamplePlugin.cs +++ b/src/Impostor.Plugins.Example/ExamplePlugin.cs @@ -29,7 +29,7 @@ namespace Impostor.Plugins.Example var game = await _gameManager.CreateAsync(new GameOptionsData()); game.DisplayName = "Example game"; await game.SetPrivacyAsync(true); - + _logger.LogInformation("Created game {0}.", game.Code.Code); } diff --git a/src/Impostor.Plugins.Example/Handlers/PlayerEventListener.cs b/src/Impostor.Plugins.Example/Handlers/PlayerEventListener.cs index 0190d3b..c62433c 100644 --- a/src/Impostor.Plugins.Example/Handlers/PlayerEventListener.cs +++ b/src/Impostor.Plugins.Example/Handlers/PlayerEventListener.cs @@ -94,7 +94,7 @@ namespace Impostor.Plugins.Example.Handlers [EventListener] public void OnPlayerStartMeetingEvent(IPlayerStartMeetingEvent e) { - _logger.LogDebug($"Player {e.PlayerControl.PlayerInfo.PlayerName} start meeting, reason: " + (e.Body==null ? "Emergency call button" : "Found the body of the player "+e.Body.PlayerInfo.PlayerName)); + _logger.LogDebug($"Player {e.PlayerControl.PlayerInfo.PlayerName} start meeting, reason: " + (e.Body == null ? "Emergency call button" : "Found the body of the player " + e.Body.PlayerInfo.PlayerName)); } } } diff --git a/src/Impostor.Server/Config/DisconnectMessages.cs b/src/Impostor.Server/Config/DisconnectMessages.cs index a86735f..6bf8e72 100644 --- a/src/Impostor.Server/Config/DisconnectMessages.cs +++ b/src/Impostor.Server/Config/DisconnectMessages.cs @@ -16,4 +16,4 @@ public const string UsernameIllegalCharacters = "Your username contains illegal characters, please remove them."; } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Constants.cs b/src/Impostor.Server/Constants.cs index 62d90b2..ce0114a 100644 --- a/src/Impostor.Server/Constants.cs +++ b/src/Impostor.Server/Constants.cs @@ -5,4 +5,4 @@ public const int SpawnTimeout = 2500; public const int ConnectionTimeout = 2500; } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Events/MultiDisposable.cs b/src/Impostor.Server/Events/MultiDisposable.cs index b68f064..b1e2348 100644 --- a/src/Impostor.Server/Events/MultiDisposable.cs +++ b/src/Impostor.Server/Events/MultiDisposable.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace Impostor.Server.Events { /// - /// Disposes multiple . + /// Disposes multiple . /// internal class MultiDisposable : IDisposable { diff --git a/src/Impostor.Server/Events/Register/RegisteredEventListener.cs b/src/Impostor.Server/Events/Register/RegisteredEventListener.cs index 6517aac..76d2a2a 100644 --- a/src/Impostor.Server/Events/Register/RegisteredEventListener.cs +++ b/src/Impostor.Server/Events/Register/RegisteredEventListener.cs @@ -159,7 +159,7 @@ namespace Impostor.Server.Events.Register throw new InvalidOperationException($"The method {method.GetFriendlyName()} must return void or ValueTask."); } - return Expression.Lambda>(invoke, instance, eventParameter, provider) + return Expression.Lambda>(invoke, instance, eventParameter, provider) .Compile(); } } diff --git a/src/Impostor.Server/Events/Register/TemporaryEventRegister.cs b/src/Impostor.Server/Events/Register/TemporaryEventRegister.cs index 1446ad1..f2bfee2 100644 --- a/src/Impostor.Server/Events/Register/TemporaryEventRegister.cs +++ b/src/Impostor.Server/Events/Register/TemporaryEventRegister.cs @@ -56,4 +56,4 @@ namespace Impostor.Server.Events.Register } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Extensions/NodeLocatorExtensions.cs b/src/Impostor.Server/Extensions/NodeLocatorExtensions.cs index 370bca6..96ceb4d 100644 --- a/src/Impostor.Server/Extensions/NodeLocatorExtensions.cs +++ b/src/Impostor.Server/Extensions/NodeLocatorExtensions.cs @@ -10,4 +10,4 @@ namespace Impostor.Server return await nodeLocator.FindAsync(gameCode) != null; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Extensions/TypeExtensions.cs b/src/Impostor.Server/Extensions/TypeExtensions.cs index 55d42fb..396d987 100644 --- a/src/Impostor.Server/Extensions/TypeExtensions.cs +++ b/src/Impostor.Server/Extensions/TypeExtensions.cs @@ -64,4 +64,4 @@ namespace Impostor.Server return str; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Factories/IClientFactory.cs b/src/Impostor.Server/Net/Factories/IClientFactory.cs index bec1b79..a72a23b 100644 --- a/src/Impostor.Server/Net/Factories/IClientFactory.cs +++ b/src/Impostor.Server/Net/Factories/IClientFactory.cs @@ -8,4 +8,4 @@ namespace Impostor.Server.Net.Factories { ClientBase Create(IHazelConnection connection, string name, int clientVersion, ISet mods); } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/GameCodeFactory.cs b/src/Impostor.Server/Net/GameCodeFactory.cs index 2a0553f..f8b0de4 100644 --- a/src/Impostor.Server/Net/GameCodeFactory.cs +++ b/src/Impostor.Server/Net/GameCodeFactory.cs @@ -9,4 +9,4 @@ namespace Impostor.Server.Net return GameCode.Create(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/GameObject.cs b/src/Impostor.Server/Net/Inner/GameObject.cs index 9b53d70..7fd4f01 100644 --- a/src/Impostor.Server/Net/Inner/GameObject.cs +++ b/src/Impostor.Server/Net/Inner/GameObject.cs @@ -26,4 +26,4 @@ namespace Impostor.Server.Net.Inner return result; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/InnerNetObject.cs b/src/Impostor.Server/Net/Inner/InnerNetObject.cs index 5b65f46..8cbea9a 100644 --- a/src/Impostor.Server/Net/Inner/InnerNetObject.cs +++ b/src/Impostor.Server/Net/Inner/InnerNetObject.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Threading.Tasks; +using System.Threading.Tasks; using Impostor.Api.Net; using Impostor.Api.Net.Inner; using Impostor.Api.Net.Messages; diff --git a/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs b/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs index 0e475b8..ff5c21d 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Components/InnerCustomNetworkTransform.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Numerics; +using System.Numerics; using System.Threading.Tasks; using Impostor.Api; using Impostor.Api.Events.Managers; diff --git a/src/Impostor.Server/Net/Inner/Objects/Components/InnerPlayerPhysics.cs b/src/Impostor.Server/Net/Inner/Objects/Components/InnerPlayerPhysics.cs index 69f8dcd..4eb5f8a 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Components/InnerPlayerPhysics.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Components/InnerPlayerPhysics.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading.Tasks; using Impostor.Api.Events.Managers; using Impostor.Api.Innersloth; diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerLobbyBehaviour.cs b/src/Impostor.Server/Net/Inner/Objects/InnerLobbyBehaviour.cs index 78be5bd..3dfd741 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerLobbyBehaviour.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerLobbyBehaviour.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Impostor.Api.Games; using Impostor.Api.Net; using Impostor.Api.Net.Inner.Objects; @@ -20,17 +21,17 @@ namespace Impostor.Server.Net.Inner.Objects public override ValueTask SerializeAsync(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public override ValueTask DeserializeAsync(IClientPlayer sender, IClientPlayer? target, IMessageReader reader, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public override ValueTask HandleRpcAsync(ClientPlayer sender, ClientPlayer? target, RpcCalls call, IMessageReader reader) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } } diff --git a/src/Impostor.Server/Net/Inner/Objects/InnerMeetingHud.cs b/src/Impostor.Server/Net/Inner/Objects/InnerMeetingHud.cs index 8f9c8f5..a2d6f0e 100644 --- a/src/Impostor.Server/Net/Inner/Objects/InnerMeetingHud.cs +++ b/src/Impostor.Server/Net/Inner/Objects/InnerMeetingHud.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/IActivatable.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/IActivatable.cs index e595b25..66a164c 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/IActivatable.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/IActivatable.cs @@ -4,4 +4,4 @@ { bool IsActive { get; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ISystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ISystemType.cs index a6ef88e..441d7c3 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ISystemType.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ISystemType.cs @@ -8,4 +8,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems void Deserialize(IMessageReader reader, bool initialState); } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/HudOverrideSystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/HudOverrideSystemType.cs index 42aa8d3..4349233 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/HudOverrideSystemType.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/HudOverrideSystemType.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Net.Messages; +using System; +using Impostor.Api.Net.Messages; namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus { @@ -8,7 +9,7 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus public void Serialize(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void Deserialize(IMessageReader reader, bool initialState) @@ -16,4 +17,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus IsActive = reader.ReadBoolean(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/LifeSuppSystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/LifeSuppSystemType.cs index f644024..681ebe1 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/LifeSuppSystemType.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/LifeSuppSystemType.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Impostor.Api.Net.Messages; namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus @@ -19,7 +20,7 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus public void Serialize(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void Deserialize(IMessageReader reader, bool initialState) @@ -41,4 +42,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/MedScanSystem.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/MedScanSystem.cs index 007b9d0..4c2287f 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/MedScanSystem.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/MedScanSystem.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Impostor.Api.Net.Messages; namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus @@ -14,7 +15,7 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus public void Serialize(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void Deserialize(IMessageReader reader, bool initialState) @@ -29,4 +30,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/ReactorSystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/ReactorSystemType.cs index 4380918..7bc2ab3 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/ReactorSystemType.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/ReactorSystemType.cs @@ -20,7 +20,7 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus public void Serialize(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void Deserialize(IMessageReader reader, bool initialState) @@ -36,4 +36,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SabotageSystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SabotageSystemType.cs index 193cfe8..73c10c3 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SabotageSystemType.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SabotageSystemType.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Net.Messages; +using System; +using Impostor.Api.Net.Messages; namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus { @@ -15,7 +16,7 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus public void Serialize(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void Deserialize(IMessageReader reader, bool initialState) @@ -23,4 +24,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus Timer = reader.ReadSingle(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SecurityCameraSystemType.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SecurityCameraSystemType.cs index df41b68..d796455 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SecurityCameraSystemType.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SecurityCameraSystemType.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Net.Messages; +using System; +using Impostor.Api.Net.Messages; namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus { @@ -8,7 +9,7 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus public void Serialize(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void Deserialize(IMessageReader reader, bool initialState) @@ -16,4 +17,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus InUse = reader.ReadByte(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SwitchSystem.cs b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SwitchSystem.cs index 925774a..eb2b572 100644 --- a/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SwitchSystem.cs +++ b/src/Impostor.Server/Net/Inner/Objects/Systems/ShipStatus/SwitchSystem.cs @@ -1,4 +1,5 @@ -using Impostor.Api.Net.Messages; +using System; +using Impostor.Api.Net.Messages; namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus { @@ -14,7 +15,7 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus public void Serialize(IMessageWriter writer, bool initialState) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public void Deserialize(IMessageReader reader, bool initialState) @@ -24,4 +25,4 @@ namespace Impostor.Server.Net.Inner.Objects.Systems.ShipStatus Value = reader.ReadByte(); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Inner/SpawnFlags.cs b/src/Impostor.Server/Net/Inner/SpawnFlags.cs index 1860098..28c2a1a 100644 --- a/src/Impostor.Server/Net/Inner/SpawnFlags.cs +++ b/src/Impostor.Server/Net/Inner/SpawnFlags.cs @@ -8,4 +8,4 @@ namespace Impostor.Server.Net.Inner None = 0, IsClientCharacter = 1, } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Manager/ClientManager.Api.cs b/src/Impostor.Server/Net/Manager/ClientManager.Api.cs index 6cbe5bf..1ff970d 100644 --- a/src/Impostor.Server/Net/Manager/ClientManager.Api.cs +++ b/src/Impostor.Server/Net/Manager/ClientManager.Api.cs @@ -8,4 +8,4 @@ namespace Impostor.Server.Net.Manager { IEnumerable IClientManager.Clients => _clients.Values; } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Manager/GameManager.cs b/src/Impostor.Server/Net/Manager/GameManager.cs index eef5d53..b10e791 100644 --- a/src/Impostor.Server/Net/Manager/GameManager.cs +++ b/src/Impostor.Server/Net/Manager/GameManager.cs @@ -115,7 +115,7 @@ namespace Impostor.Server.Net.Manager // TODO: Prevent duplicates when using server redirector using INodeProvider. var (success, game) = await TryCreateAsync(options); - for (int i = 0; i < 10 && !success; i++) + for (var i = 0; i < 10 && !success; i++) { (success, game) = await TryCreateAsync(options); } diff --git a/src/Impostor.Server/Net/Redirector/ClientRedirector.cs b/src/Impostor.Server/Net/Redirector/ClientRedirector.cs index afae57e..0cfa76d 100644 --- a/src/Impostor.Server/Net/Redirector/ClientRedirector.cs +++ b/src/Impostor.Server/Net/Redirector/ClientRedirector.cs @@ -10,7 +10,6 @@ using Impostor.Server.Config; using Impostor.Server.Net.Hazel; using Impostor.Server.Net.Manager; using Serilog; -using ILogger = Serilog.ILogger; namespace Impostor.Server.Net.Redirector { diff --git a/src/Impostor.Server/Net/Redirector/INodeProvider.cs b/src/Impostor.Server/Net/Redirector/INodeProvider.cs index 318fcb2..fb7240c 100644 --- a/src/Impostor.Server/Net/Redirector/INodeProvider.cs +++ b/src/Impostor.Server/Net/Redirector/INodeProvider.cs @@ -6,4 +6,4 @@ namespace Impostor.Server.Net.Redirector { IPEndPoint Get(); } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/Redirector/NodeProviderConfig.cs b/src/Impostor.Server/Net/Redirector/NodeProviderConfig.cs index 4e19c43..7e2982e 100644 --- a/src/Impostor.Server/Net/Redirector/NodeProviderConfig.cs +++ b/src/Impostor.Server/Net/Redirector/NodeProviderConfig.cs @@ -40,4 +40,4 @@ namespace Impostor.Server.Net.Redirector } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Net/State/Game.Data.cs b/src/Impostor.Server/Net/State/Game.Data.cs index b928a3c..9e5fd01 100644 --- a/src/Impostor.Server/Net/State/Game.Data.cs +++ b/src/Impostor.Server/Net/State/Game.Data.cs @@ -1,14 +1,10 @@ using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using Impostor.Api; -using Impostor.Api.Innersloth; using Impostor.Api.Net.Inner; using Impostor.Api.Net.Messages; -using Impostor.Api.Net.Messages.S2C; using Impostor.Api.Unity; -using Impostor.Hazel; using Impostor.Server.Events.Meeting; using Impostor.Server.Events.Player; using Impostor.Server.Net.Inner; diff --git a/src/Impostor.Server/Net/State/Game.Outgoing.cs b/src/Impostor.Server/Net/State/Game.Outgoing.cs index 21b6067..5c84f94 100644 --- a/src/Impostor.Server/Net/State/Game.Outgoing.cs +++ b/src/Impostor.Server/Net/State/Game.Outgoing.cs @@ -55,7 +55,7 @@ namespace Impostor.Server.Net.State writer.StartMessage(GameDataTag.RpcFlag); writer.WritePacked(targetNetId); - writer.Write((byte) callId); + writer.Write((byte)callId); return writer; } diff --git a/src/Impostor.Server/Plugins/IAssemblyInformation.cs b/src/Impostor.Server/Plugins/IAssemblyInformation.cs index fb36e92..f724cf2 100644 --- a/src/Impostor.Server/Plugins/IAssemblyInformation.cs +++ b/src/Impostor.Server/Plugins/IAssemblyInformation.cs @@ -11,4 +11,4 @@ namespace Impostor.Server.Plugins Assembly Load(AssemblyLoadContext context); } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Plugins/LoadedAssemblyInformation.cs b/src/Impostor.Server/Plugins/LoadedAssemblyInformation.cs index 720367c..5f7d0bb 100644 --- a/src/Impostor.Server/Plugins/LoadedAssemblyInformation.cs +++ b/src/Impostor.Server/Plugins/LoadedAssemblyInformation.cs @@ -22,4 +22,4 @@ namespace Impostor.Server.Plugins return _assembly; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Plugins/PluginConfig.cs b/src/Impostor.Server/Plugins/PluginConfig.cs index 22dc9e9..66afceb 100644 --- a/src/Impostor.Server/Plugins/PluginConfig.cs +++ b/src/Impostor.Server/Plugins/PluginConfig.cs @@ -8,4 +8,4 @@ namespace Impostor.Server.Plugins public List LibraryPaths { get; set; } = new List(); } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Plugins/PluginLoaderService.cs b/src/Impostor.Server/Plugins/PluginLoaderService.cs index 84238f7..40e13b5 100644 --- a/src/Impostor.Server/Plugins/PluginLoaderService.cs +++ b/src/Impostor.Server/Plugins/PluginLoaderService.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Impostor.Api.Plugins; diff --git a/src/Impostor.Server/Properties/AssemblyInfo.cs b/src/Impostor.Server/Properties/AssemblyInfo.cs index 84c5158..eed7af6 100644 --- a/src/Impostor.Server/Properties/AssemblyInfo.cs +++ b/src/Impostor.Server/Properties/AssemblyInfo.cs @@ -1,5 +1,5 @@ using System.Runtime.CompilerServices; -[assembly:InternalsVisibleTo("Impostor.Benchmarks")] -[assembly:InternalsVisibleTo("Impostor.Tests")] -[assembly:InternalsVisibleTo("Impostor.Tools.ServerReplay")] +[assembly: InternalsVisibleTo("Impostor.Benchmarks")] +[assembly: InternalsVisibleTo("Impostor.Tests")] +[assembly: InternalsVisibleTo("Impostor.Tools.ServerReplay")] diff --git a/src/Impostor.Server/Recorder/PacketRecorder.cs b/src/Impostor.Server/Recorder/PacketRecorder.cs index c6531b4..905e026 100644 --- a/src/Impostor.Server/Recorder/PacketRecorder.cs +++ b/src/Impostor.Server/Recorder/PacketRecorder.cs @@ -17,7 +17,7 @@ using Microsoft.Extensions.Options; namespace Impostor.Server.Recorder { /// - /// Records all packets received in . + /// Records all packets received in . /// internal class PacketRecorder : BackgroundService { diff --git a/src/Impostor.Server/Recorder/PacketSerializationContextPooledObjectPolicy.cs b/src/Impostor.Server/Recorder/PacketSerializationContextPooledObjectPolicy.cs index 17b355f..e45948e 100644 --- a/src/Impostor.Server/Recorder/PacketSerializationContextPooledObjectPolicy.cs +++ b/src/Impostor.Server/Recorder/PacketSerializationContextPooledObjectPolicy.cs @@ -15,4 +15,4 @@ namespace Impostor.Server.Recorder return true; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Server/Recorder/ServerReplayVersion.cs b/src/Impostor.Server/Recorder/ServerReplayVersion.cs index 648205b..2eb3b49 100644 --- a/src/Impostor.Server/Recorder/ServerReplayVersion.cs +++ b/src/Impostor.Server/Recorder/ServerReplayVersion.cs @@ -1,17 +1,17 @@ namespace Impostor.Server.Recorder { /// - /// Version of the server replay data format. + /// Version of the server replay data format. /// public enum ServerReplayVersion { /// - /// Initial version + /// Initial version /// Initial = 1, /// - /// Latest version + /// Latest version /// Latest = Initial, } diff --git a/src/Impostor.Tests/Events/EventManagerTests.cs b/src/Impostor.Tests/Events/EventManagerTests.cs index d222d79..a510803 100644 --- a/src/Impostor.Tests/Events/EventManagerTests.cs +++ b/src/Impostor.Tests/Events/EventManagerTests.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Net.Sockets; using System.Threading.Tasks; using Impostor.Api.Events; using Impostor.Api.Events.Managers; @@ -11,10 +10,10 @@ namespace Impostor.Tests.Events { public class EventManagerTests { - public static readonly IEnumerable TestModes = new [] + public static readonly IEnumerable TestModes = new[] { new object[] { TestMode.Service }, - new object[] { TestMode.Temporary } + new object[] { TestMode.Temporary }, }; [Theory] @@ -38,14 +37,14 @@ namespace Impostor.Tests.Events await eventManager.CallAsync(new SetValueEvent(1)); - Assert.Equal(new [] + Assert.Equal(new[] { EventPriority.Monitor, EventPriority.Highest, EventPriority.High, EventPriority.Normal, EventPriority.Low, - EventPriority.Lowest + EventPriority.Lowest, }, listener.Priorities); } @@ -78,10 +77,10 @@ namespace Impostor.Tests.Events await eventManager.CallAsync(new SetValueEvent(1)); - Assert.Equal(new [] + Assert.Equal(new[] { EventPriority.Monitor, - EventPriority.Highest + EventPriority.Highest, }, listener.Priorities); } @@ -115,7 +114,7 @@ namespace Impostor.Tests.Events public enum TestMode { Service, - Temporary + Temporary, } public interface ISetValueEvent : IEventCancelable diff --git a/src/Impostor.Tests/GameCodeTests.cs b/src/Impostor.Tests/GameCodeTests.cs index de98123..6f0c23b 100644 --- a/src/Impostor.Tests/GameCodeTests.cs +++ b/src/Impostor.Tests/GameCodeTests.cs @@ -1,5 +1,4 @@ using Impostor.Api.Innersloth; - using Xunit; namespace Impostor.Tests @@ -26,4 +25,4 @@ namespace Impostor.Tests Assert.Equal(codeInt, GameCodeParser.GameNameToInt(code)); } } -} \ No newline at end of file +} diff --git a/src/Impostor.Tests/Hazel/MessageReaderTests.cs b/src/Impostor.Tests/Hazel/MessageReaderTests.cs index e7fa0df..c0ecbdd 100644 --- a/src/Impostor.Tests/Hazel/MessageReaderTests.cs +++ b/src/Impostor.Tests/Hazel/MessageReaderTests.cs @@ -72,7 +72,7 @@ namespace Impostor.Tests.Hazel public void ReadProperString() { const string Test1 = "Hello"; - string Test2 = new string(' ', 1024); + var Test2 = new string(' ', 1024); var msg = new MessageWriter(2048); msg.StartMessage(1); msg.Write(Test1); @@ -128,18 +128,18 @@ namespace Impostor.Tests.Hazel var msg = new MessageWriter(2048); msg.StartMessage(1); - msg.StartMessage(2); - msg.Write(Test1); - msg.Write(Test2); - msg.StartMessage(2); - msg.Write(Test1); - msg.Write(Test2); - msg.StartMessage(2); - msg.Write(Test1); - msg.Write(Test2); - msg.EndMessage(); - msg.EndMessage(); - msg.EndMessage(); + msg.StartMessage(2); + msg.Write(Test1); + msg.Write(Test2); + msg.StartMessage(2); + msg.Write(Test1); + msg.Write(Test2); + msg.StartMessage(2); + msg.Write(Test1); + msg.Write(Test2); + msg.EndMessage(); + msg.EndMessage(); + msg.EndMessage(); msg.EndMessage(); // Read message. @@ -217,7 +217,7 @@ namespace Impostor.Tests.Hazel 0x20, 0x6C, 0x6F, 0x6E, 0x67, 0x20, 0x70, 0x61, 0x63, 0x6B, 0x65, 0x74, 0x20, 0x74, 0x6F, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x63, 0x6F, 0x70, - 0x79, 0x69, 0x6E, 0x67, 0x2E + 0x79, 0x69, 0x6E, 0x67, 0x2E, }; var readerPool = CreateReaderPool(); @@ -301,15 +301,15 @@ namespace Impostor.Tests.Hazel var messageWriter = new MessageWriter(1024); messageWriter.StartMessage(0); - messageWriter.StartMessage(1); - messageWriter.Write("HiTest1"); - messageWriter.StartMessage(2); - messageWriter.Write("RemoveMe!"); - messageWriter.EndMessage(); - messageWriter.EndMessage(); - messageWriter.StartMessage(2); - messageWriter.Write("HiTest2"); - messageWriter.EndMessage(); + messageWriter.StartMessage(1); + messageWriter.Write("HiTest1"); + messageWriter.StartMessage(2); + messageWriter.Write("RemoveMe!"); + messageWriter.EndMessage(); + messageWriter.EndMessage(); + messageWriter.StartMessage(2); + messageWriter.Write("HiTest2"); + messageWriter.EndMessage(); messageWriter.EndMessage(); // Copy buffer. diff --git a/src/Impostor.Tests/Hazel/MessageWriterTests.cs b/src/Impostor.Tests/Hazel/MessageWriterTests.cs index 83d67da..f158191 100644 --- a/src/Impostor.Tests/Hazel/MessageWriterTests.cs +++ b/src/Impostor.Tests/Hazel/MessageWriterTests.cs @@ -35,4 +35,4 @@ namespace Impostor.Tests.Hazel } } } -} \ No newline at end of file +} diff --git a/src/Impostor.Tools.Proxy/HexUtils.cs b/src/Impostor.Tools.Proxy/HexUtils.cs index 79517b4..f04e226 100644 --- a/src/Impostor.Tools.Proxy/HexUtils.cs +++ b/src/Impostor.Tools.Proxy/HexUtils.cs @@ -8,28 +8,28 @@ namespace Impostor.Tools.Proxy public static string HexDump(byte[] bytes, int bytesPerLine = 16) { if (bytes == null) return ""; - int bytesLength = bytes.Length; + var bytesLength = bytes.Length; - char[] HexChars = "0123456789ABCDEF".ToCharArray(); + var HexChars = "0123456789ABCDEF".ToCharArray(); - int firstHexColumn = - 8 // 8 characters for the address - + 3; // 3 spaces + var 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 + var 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) + var 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); + var line = (new string(' ', lineLength - Environment.NewLine.Length) + Environment.NewLine).ToCharArray(); + var expectedLines = (bytesLength + bytesPerLine - 1) / bytesPerLine; + var result = new StringBuilder(expectedLines * lineLength); - for (int i = 0; i < bytesLength; i += bytesPerLine) + for (var i = 0; i < bytesLength; i += bytesPerLine) { line[0] = HexChars[(i >> 28) & 0xF]; line[1] = HexChars[(i >> 24) & 0xF]; @@ -40,10 +40,10 @@ namespace Impostor.Tools.Proxy line[6] = HexChars[(i >> 4) & 0xF]; line[7] = HexChars[(i >> 0) & 0xF]; - int hexColumn = firstHexColumn; - int charColumn = firstCharColumn; + var hexColumn = firstHexColumn; + var charColumn = firstCharColumn; - for (int j = 0; j < bytesPerLine; j++) + for (var j = 0; j < bytesPerLine; j++) { if (j > 0 && (j & 7) == 0) hexColumn++; if (i + j >= bytesLength) @@ -54,17 +54,20 @@ namespace Impostor.Tools.Proxy } else { - byte b = bytes[i + j]; + var 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 +} diff --git a/src/Impostor.Tools.Proxy/Program.cs b/src/Impostor.Tools.Proxy/Program.cs index 468cdd1..c7f9cfa 100644 --- a/src/Impostor.Tools.Proxy/Program.cs +++ b/src/Impostor.Tools.Proxy/Program.cs @@ -18,22 +18,22 @@ namespace Impostor.Tools.Proxy private static readonly Dictionary TagMap = new Dictionary { - {0, "HostGame"}, - {1, "JoinGame"}, - {2, "StartGame"}, - {3, "RemoveGame"}, - {4, "RemovePlayer"}, - {5, "GameData"}, - {6, "GameDataTo"}, - {7, "JoinedGame"}, - {8, "EndGame"}, - {9, "GetGameList"}, - {10, "AlterGame"}, - {11, "KickPlayer"}, - {12, "WaitForHost"}, - {13, "Redirect"}, - {14, "ReselectServer"}, - {16, "GetGameListV2"} + { 0, "HostGame" }, + { 1, "JoinGame" }, + { 2, "StartGame" }, + { 3, "RemoveGame" }, + { 4, "RemovePlayer" }, + { 5, "GameData" }, + { 6, "GameDataTo" }, + { 7, "JoinedGame" }, + { 8, "EndGame" }, + { 9, "GetGameList" }, + { 10, "AlterGame" }, + { 11, "KickPlayer" }, + { 12, "WaitForHost" }, + { 13, "Redirect" }, + { 14, "ReselectServer" }, + { 16, "GetGameListV2" }, }; private static IServiceProvider _serviceProvider; @@ -46,7 +46,7 @@ namespace Impostor.Tools.Proxy _serviceProvider = services.BuildServiceProvider(); _readerPool = _serviceProvider.GetRequiredService>(); - + var devices = LivePacketDevice.AllLocalMachine; if (devices.Count == 0) { @@ -77,7 +77,7 @@ namespace Impostor.Tools.Proxy var ip = packet.Ethernet.IpV4; var ipSrc = ip.Source.ToString(); var udp = ip.Udp; - + // True if this is our own packet. using (var stream = udp.Payload.ToMemoryStream()) { @@ -86,14 +86,14 @@ namespace Impostor.Tools.Proxy reader.Update(stream.ToArray()); var option = reader.Buffer[0]; - if (option == (byte) MessageType.Reliable) + if (option == (byte)MessageType.Reliable) { reader.Seek(reader.Position + 3); } - else if (option == (byte) UdpSendOption.Acknowledgement || - option == (byte) UdpSendOption.Ping || - option == (byte) UdpSendOption.Hello || - option == (byte) UdpSendOption.Disconnect) + else if (option == (byte)UdpSendOption.Acknowledgement || + option == (byte)UdpSendOption.Ping || + option == (byte)UdpSendOption.Hello || + option == (byte)UdpSendOption.Disconnect) { return; } @@ -101,9 +101,9 @@ namespace Impostor.Tools.Proxy { reader.Seek(reader.Position + 1); } - + var isSent = ipSrc.StartsWith("192."); - + while (true) { if (reader.Position >= reader.Length) @@ -120,7 +120,7 @@ namespace Impostor.Tools.Proxy { HandleToClient(ipSrc, message); } - + if (message.Position < message.Length) { Console.ForegroundColor = ConsoleColor.Red; @@ -160,6 +160,7 @@ namespace Impostor.Tools.Proxy { Console.WriteLine("- PlayerId " + packet.ReadPackedInt32()); } + break; case 10: Console.WriteLine("- GameCode " + packet.ReadInt32()); diff --git a/src/Impostor.Tools.ServerReplay/Mocks/MockGameCodeFactory.cs b/src/Impostor.Tools.ServerReplay/Mocks/MockGameCodeFactory.cs index 1111b7e..7dc9196 100644 --- a/src/Impostor.Tools.ServerReplay/Mocks/MockGameCodeFactory.cs +++ b/src/Impostor.Tools.ServerReplay/Mocks/MockGameCodeFactory.cs @@ -11,4 +11,4 @@ namespace Impostor.Tools.ServerReplay.Mocks return Result; } } -} \ No newline at end of file +} diff --git a/src/Impostor.Tools.ServerReplay/Program.cs b/src/Impostor.Tools.ServerReplay/Program.cs index 261d679..65401ef 100644 --- a/src/Impostor.Tools.ServerReplay/Program.cs +++ b/src/Impostor.Tools.ServerReplay/Program.cs @@ -89,7 +89,7 @@ namespace Impostor.Tools.ServerReplay services.AddSingleton(new ServerEnvironment { - IsReplay = true + IsReplay = true, }); services.AddSingleton();