Skip to content

Commit 002878f

Browse files
authored
fix: don't run Distinct() over the directions and correct the length (AscensionGameDev#2020)
1 parent c1c7cf6 commit 002878f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Intersect (Core)/Configuration/ClientConfiguration.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Intersect.Enums;
55
using Intersect.Logging;
6+
using Intersect.Utilities;
67
using Newtonsoft.Json;
78

89
namespace Intersect.Configuration
@@ -42,7 +43,7 @@ public static ClientConfiguration LoadAndSave(string? filePath = default)
4243

4344
public static List<DisplayDirection> DEFAULT_ENTITY_BAR_DIRECTIONS =>
4445
Enumerable
45-
.Range(0, Enum.GetValues<Vital>().Length)
46+
.Range(0, 1 + Enum.GetValues<Vital>().Length)
4647
.Select(_ => DisplayDirection.StartToEnd)
4748
.ToList();
4849

@@ -60,7 +61,7 @@ public static ClientConfiguration LoadAndSave(string? filePath = default)
6061

6162
public const bool DEFAULT_TYPEWRITER_ENABLED = true;
6263

63-
public static List<char> DEFAULT_TYPEWRITER_FULL_STOP_CHARACTERS => new List<char>()
64+
public static List<char> DEFAULT_TYPEWRITER_FULL_STOP_CHARACTERS => new()
6465
{
6566
'.',
6667
'!',
@@ -72,7 +73,7 @@ public static ClientConfiguration LoadAndSave(string? filePath = default)
7273

7374
public const long DEFAULT_TYPEWRITER_PART_DELAY = 6;
7475

75-
public static List<char> DEFAULT_TYPEWRITER_PAUSE_CHARACTERS => new List<char>()
76+
public static List<char> DEFAULT_TYPEWRITER_PAUSE_CHARACTERS => new()
7677
{
7778
',',
7879
';',
@@ -85,7 +86,7 @@ public static ClientConfiguration LoadAndSave(string? filePath = default)
8586

8687
public const int DEFAULT_TYPEWRITER_SOUND_FREQUENCY = 5;
8788

88-
public static List<string> DEFAULT_TYPEWRITER_SOUNDS => new List<string>()
89+
public static List<string> DEFAULT_TYPEWRITER_SOUNDS => new()
8990
{
9091
"octave-beep-tapped.wav"
9192
};
@@ -94,19 +95,16 @@ public static ClientConfiguration LoadAndSave(string? filePath = default)
9495

9596
#region Static Properties and Methods
9697

97-
public static ClientConfiguration Instance { get; } = new ClientConfiguration();
98+
public static ClientConfiguration Instance { get; } = new();
9899

99100
public void Validate()
100101
{
101-
ChatLines = Math.Min(Math.Max(ChatLines, 10), 500);
102+
ChatLines = MathHelper.Clamp(ChatLines, 10, 500);
102103

103-
var entityBarDirections = EntityBarDirections.Distinct()?.ToList();
104104
EntityBarDirections = DEFAULT_ENTITY_BAR_DIRECTIONS.Select(
105-
(direction, index) =>
106-
(entityBarDirections?.Count ?? 0) > index
107-
? entityBarDirections[index]
108-
: direction
109-
).ToList();
105+
(direction, index) => EntityBarDirections.Count > index ? EntityBarDirections[index] : direction
106+
)
107+
.ToList();
110108

111109
GameFont = string.IsNullOrWhiteSpace(GameFont) ? DEFAULT_FONT : GameFont.Trim();
112110
Host = string.IsNullOrWhiteSpace(Host) ? DEFAULT_HOST : Host.Trim();
@@ -176,7 +174,7 @@ public void Validate()
176174
/// Static background Example: { "background.png" },
177175
/// Animated background Example: { "background_0.png", "background_1.png", "background_2.png" },
178176
/// </summary>
179-
public List<string> MenuBackground { get; set; } = new List<string> { "background.png" };
177+
public List<string> MenuBackground { get; set; } = new() { "background.png" };
180178

181179
/// <summary>
182180
/// Sets the display mode of the main menu's background.
@@ -191,7 +189,7 @@ public void Validate()
191189
/// <summary>
192190
/// A list from which introductory images are drawn when the game client is launched.
193191
/// </summary>
194-
public List<string> IntroImages { get; set; } = new List<string>();
192+
public List<string> IntroImages { get; set; } = new();
195193

196194
/// <summary>
197195
/// The address for the update manifest file generated by the editor.

0 commit comments

Comments
 (0)