From 3c6822aa64bb08cdbcf827a6b9113c8994815fb1 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Thu, 1 Dec 2022 17:56:26 +0100 Subject: [PATCH] add dotnet-format as pre-commit hook --- .githooks/pre-commit | 7 +++++++ Pal.Client/LocalState.cs | 2 +- Pal.Client/Net/GrpcLogger.cs | 4 ++-- Pal.Client/Plugin.cs | 10 +++++----- Pal.Client/Windows/StatisticsWindow.cs | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..f701376 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,7 @@ +#!/bin/sh +# +# Use with: +# +# $> git config core.hooksPath .githooks +# +dotnet format --exclude vendor/ diff --git a/Pal.Client/LocalState.cs b/Pal.Client/LocalState.cs index 23ad8b4..ae62a9f 100644 --- a/Pal.Client/LocalState.cs +++ b/Pal.Client/LocalState.cs @@ -14,7 +14,7 @@ namespace Pal.Client { private static readonly JsonSerializerOptions _jsonSerializerOptions = new JsonSerializerOptions { IncludeFields = true }; private static readonly int _currentVersion = 3; - + public uint TerritoryType { get; set; } public ConcurrentBag Markers { get; set; } = new(); diff --git a/Pal.Client/Net/GrpcLogger.cs b/Pal.Client/Net/GrpcLogger.cs index eb900b1..07f0ccf 100644 --- a/Pal.Client/Net/GrpcLogger.cs +++ b/Pal.Client/Net/GrpcLogger.cs @@ -14,8 +14,8 @@ namespace Pal.Client.Net _name = name; } - public IDisposable BeginScope(TState state) - where TState: notnull + public IDisposable BeginScope(TState state) + where TState : notnull => NullScope.Instance; public bool IsEnabled(LogLevel logLevel) => logLevel != LogLevel.None; diff --git a/Pal.Client/Plugin.cs b/Pal.Client/Plugin.cs index b47944c..1e28102 100644 --- a/Pal.Client/Plugin.cs +++ b/Pal.Client/Plugin.cs @@ -190,7 +190,7 @@ namespace Pal.Client { Splatoon.RemoveDynamicElements(SPLATOON_TRAP_HOARD); Splatoon.RemoveDynamicElements(SPLATOON_REGULAR_COFFERS); - } + } catch { // destroyed on territory change either way @@ -335,7 +335,7 @@ namespace Pal.Client // markers discovered afterwards are automatically marked seen. if (accountId != null && knownMarker.NetworkId != null && !knownMarker.RemoteSeenRequested && !knownMarker.RemoteSeenOn.Contains(accountId.Value)) updateSeenMarkers = true; - + continue; } @@ -667,7 +667,7 @@ namespace Pal.Client case 2009504: result.Add(new Marker(Marker.EType.Trap, obj.Position) { Seen = true }); break; - + case 2007542: case 2007543: result.Add(new Marker(Marker.EType.Hoard, obj.Position) { Seen = true }); @@ -683,11 +683,11 @@ namespace Pal.Client } internal bool IsInDeepDungeon() => - Service.ClientState.IsLoggedIn + Service.ClientState.IsLoggedIn && Service.Condition[ConditionFlag.InDeepDungeon] && typeof(ETerritoryType).IsEnumDefined(Service.ClientState.TerritoryType); - internal static Element CreateSplatoonElement(Marker.EType type, Vector3 pos, Vector4 color, bool fill = false) + internal static Element CreateSplatoonElement(Marker.EType type, Vector3 pos, Vector4 color, bool fill = false) => CreateSplatoonElement(type, pos, ImGui.ColorConvertFloat4ToU32(color), fill); internal static Element CreateSplatoonElement(Marker.EType type, Vector3 pos, uint color, bool fill = false) diff --git a/Pal.Client/Windows/StatisticsWindow.cs b/Pal.Client/Windows/StatisticsWindow.cs index 4b270d9..5969f97 100644 --- a/Pal.Client/Windows/StatisticsWindow.cs +++ b/Pal.Client/Windows/StatisticsWindow.cs @@ -74,7 +74,7 @@ namespace Pal.Client.Windows territoryStatistics.TrapCount = null; territoryStatistics.HoardCofferCount = null; } - + foreach (var floor in floorStatistics) { if (_territoryStatistics.TryGetValue((ETerritoryType)floor.TerritoryType, out TerritoryStatistics? territoryStatistics))