Skip to content

Commit f5cb50c

Browse files
committed
start preparing types for live config editor page on the server
1 parent ad5be3c commit f5cb50c

24 files changed

+298
-104
lines changed

Framework/Intersect.Framework.Core/Config/FloodThreshholds.cs renamed to Framework/Intersect.Framework.Core/Config/FloodThresholdOptions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Intersect.Config;
22

3-
public partial class FloodThreshholds
3+
public partial class FloodThresholdOptions
44
{
55
/// <summary>
66
/// The largest a single packet should be before it's considered flooding.
@@ -17,19 +17,19 @@ public partial class FloodThreshholds
1717
/// </summary>
1818
public int KickAvgPacketPerSec { get; set; } = 30;
1919

20-
public static FloodThreshholds Editor()
20+
public static FloodThresholdOptions Editor()
2121
{
22-
return new FloodThreshholds()
22+
return new FloodThresholdOptions()
2323
{
2424
MaxPacketSize = int.MaxValue,
2525
MaxPacketPerSec = int.MaxValue,
2626
KickAvgPacketPerSec = int.MaxValue
2727
};
2828
}
2929

30-
public static FloodThreshholds NotLoggedIn()
30+
public static FloodThresholdOptions NotLoggedIn()
3131
{
32-
return new FloodThreshholds()
32+
return new FloodThresholdOptions()
3333
{
3434
MaxPacketSize = 10240,
3535
MaxPacketPerSec = 5,

Framework/Intersect.Framework.Core/Config/InstancingOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System.Runtime.Serialization;
2+
using Intersect.Framework.Annotations;
23

34
namespace Intersect.Config;
45

6+
[RequiresRestart]
57
public partial class InstancingOptions
68
{
79
/// <summary>

Framework/Intersect.Framework.Core/Config/LoggingOptions.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
using Intersect.Framework.Core.Serialization;
22
using Microsoft.Extensions.Logging;
33
using Newtonsoft.Json;
4+
using Serilog.Core;
5+
using Serilog.Extensions.Logging;
46

57
namespace Intersect.Config;
68

79
public partial class LoggingOptions
810
{
11+
private const LogLevel DefaultLogLevel = LogLevel.Information;
12+
13+
public static readonly LoggingLevelSwitch LoggingLevelSwitch = new(LevelConvert.ToSerilogLevel(DefaultLogLevel));
14+
15+
private LogLevel _level = DefaultLogLevel;
16+
917
[JsonConverter(typeof(SafeStringEnumConverter))]
10-
public LogLevel Level { get; set; } = LogLevel.Information;
18+
public LogLevel Level
19+
{
20+
get => _level;
21+
set
22+
{
23+
if (value == _level)
24+
{
25+
return;
26+
}
27+
28+
_level = value;
29+
LoggingLevelSwitch.MinimumLevel = LevelConvert.ToSerilogLevel(_level);
30+
}
31+
}
1132

1233
/// <summary>
1334
/// Determines whether chat logs should be written into the logging database

Framework/Intersect.Framework.Core/Config/MapOptions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System.Runtime.Serialization;
2+
using Intersect.Framework.Annotations;
23
using Newtonsoft.Json;
34

45
namespace Intersect.Config;
56

67
/// <summary>
78
/// Options for the game map.
89
/// </summary>
10+
[RequiresRestart]
911
public partial class MapOptions
1012
{
1113
public const int DefaultMapWidth = 32;
@@ -29,7 +31,7 @@ public partial class MapOptions
2931
public bool EnableCrossingDiagonalBlocks { get; set; }
3032

3133
/// <summary>
32-
/// Indicates whether or not diagonal movement is enabled for entities within the map.
34+
/// Indicates whether diagonal movement is enabled for entities within the map.
3335
/// </summary>
3436
public bool EnableDiagonalMovement
3537
{

Framework/Intersect.Framework.Core/Config/MetricsOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using Intersect.Framework.Annotations;
2+
13
namespace Intersect.Config;
24

35
/// <summary>
@@ -8,5 +10,6 @@ public partial class MetricsOptions
810
/// <summary>
911
/// Track game performance metrics
1012
/// </summary>
13+
[RequiresRestart]
1114
public bool Enable { get; set; } = false;
1215
}

Framework/Intersect.Framework.Core/Config/NpcOptions.cs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,48 @@
66
public partial class NpcOptions
77
{
88
/// <summary>
9-
/// Configures whether or not Npcs are allowed to reset after moving out of a specified radius when starting to fight another entity.
9+
/// If NPCs are allowed to reset after moving out of a specified radius when starting to fight another entity.
1010
/// </summary>
11-
public bool AllowResetRadius = false;
11+
public bool AllowResetRadius { get; set; } = false;
1212

1313
/// <summary>
1414
/// Configures the radius in which an NPC is allowed to move after starting to fight another entity.
1515
/// </summary>
16-
public int ResetRadius = 8;
16+
public int ResetRadius { get; set; } = 8;
1717

1818
/// <summary>
19-
/// Configures whether or not the NPC is allowed to gain a new reset center point while it is still busy moving to its original reset point.
20-
/// NOTE: Can be used to allow the NPCs to be dragged far far away, as it constantly resets the center of its radius!!!
19+
/// If the NPC is allowed to gain a new reset center point while it is still busy moving to its original reset point.
20+
/// NOTE: Can be used to allow the NPCs to be dragged very far away, as it constantly resets the center of its radius!!!
2121
/// </summary>
22-
23-
public bool AllowNewResetLocationBeforeFinish = false;
22+
public bool AllowNewResetLocationBeforeFinish { get; set; } = false;
2423

2524
/// <summary>
26-
/// Configures whether or not the NPC should completely restore its vitals and statusses once it starts resetting.
25+
/// If the NPC should completely restore its vitals and statusses once it starts resetting.
2726
/// </summary>
28-
public bool ResetVitalsAndStatusses = false;
27+
public bool ResetVitalsAndStatusses { get; set; } = false;
2928

3029
/// <summary>
31-
/// Configures whether or not the NPCs health should continue to reset to full and clear statuses while working its way to the reset location
30+
/// If the NPCs health should continue to reset to full and clear statuses while working its way to the reset location
3231
/// </summary>
33-
public bool ContinuouslyResetVitalsAndStatuses = false;
32+
public bool ContinuouslyResetVitalsAndStatuses { get; set; } = false;
3433

3534
/// <summary>
3635
/// If true, a NPC can be attacked while they are resetting. Their new attacker will become a target if they are within the reset radius
3736
/// </summary>
38-
public bool AllowEngagingWhileResetting = false;
37+
public bool AllowEngagingWhileResetting { get; set; } = false;
3938

4039
/// <summary>
41-
/// Configures whether or not the level of an Npc is shown next to their name.
40+
/// If the level of an NPC is shown next to their name.
4241
/// </summary>
43-
public bool ShowLevelByName = false;
42+
public bool ShowLevelByName { get; set; } = false;
4443

4544
/// <summary>
46-
/// If true, NPCs that are resetting will walkthrough players
45+
/// If true, NPCs that are resetting will walk through players
4746
/// </summary>
48-
public bool IntangibleDuringReset = true;
47+
public bool IntangibleDuringReset { get; set; } = true;
4948

5049
/// <summary>
5150
/// If true, NPCs will go to reset state if their combat timer is exceeded
5251
/// </summary>
53-
public bool ResetIfCombatTimerExceeded = true;
52+
public bool ResetIfCombatTimerExceeded { get; set; } = true;
5453
}

Framework/Intersect.Framework.Core/Config/Options.cs

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,61 @@
1+
using System.ComponentModel;
12
using Intersect.Config;
23
using Intersect.Config.Guilds;
34
using Intersect.Core;
5+
using Intersect.Framework.Annotations;
46
using Microsoft.Extensions.Logging;
57
using Newtonsoft.Json;
68

79
namespace Intersect;
810

911
public partial class Options
1012
{
13+
#region Constants
14+
15+
public const string DefaultGameName = "Intersect";
16+
17+
public const int DefaultServerPort = 5400;
18+
19+
#endregion
20+
21+
#region Static Properties
22+
23+
public static string ResourcesDirectory { get; set; } = "resources";
24+
25+
public static Options Instance { get; private set; }
26+
27+
public static Options? PendingChanges { get; private set; }
28+
29+
public static bool IsLoaded => Instance != null;
30+
31+
#endregion Static Properties
32+
1133
#region Transient Properties
1234

35+
[Ignore]
1336
[JsonIgnore]
1437
public string OptionsData { get; private set; } = string.Empty;
1538

39+
[Ignore]
1640
[JsonIgnore]
1741
public bool SendingToClient { get; set; } = true;
1842

43+
[Ignore]
44+
public bool SmtpValid { get; private set; }
45+
1946
#endregion Transient Properties
2047

2148
#region Configuration Properties
2249

2350
#region Game Core
2451

2552
[JsonProperty(Order = -100)]
26-
public string GameName { get; set; } = DEFAULT_GAME_NAME;
53+
[RequiresRestart]
54+
public string GameName { get; set; } = DefaultGameName;
2755

2856
[JsonProperty(Order = -100)]
29-
public ushort ServerPort { get; set; } = DEFAULT_SERVER_PORT;
57+
[RequiresRestart]
58+
public ushort ServerPort { get; set; } = DefaultServerPort;
3059

3160
#endregion Game Core
3261

@@ -52,12 +81,15 @@ public partial class Options
5281
#region Network Visibility
5382

5483
[JsonProperty(Order = -91)]
84+
[RequiresRestart]
5585
public bool UPnP { get; set; } = true;
5686

5787
[JsonProperty(Order = -91)]
88+
[RequiresRestart]
5889
public bool OpenPortChecker { get; set; } = true;
5990

6091
[JsonProperty(Order = -91, NullValueHandling = NullValueHandling.Include)]
92+
[RequiresRestart]
6193
public string? PortCheckerUrl { get; set; }
6294

6395
#endregion Network Visibility
@@ -75,44 +107,54 @@ public partial class Options
75107
#region Database
76108

77109
[JsonProperty(Order = -70)]
110+
[RequiresRestart]
78111
public DatabaseOptions GameDatabase = new();
79112

80113
[JsonProperty(Order = -70)]
114+
[RequiresRestart]
81115
public DatabaseOptions LoggingDatabase = new();
82116

83117
[JsonProperty(Order = -70)]
118+
[RequiresRestart]
84119
public DatabaseOptions PlayerDatabase = new();
85120

86121
#endregion Database
87122

88123
#region Security
89124

90125
[JsonProperty(Order = -60)]
126+
[RequiresRestart]
91127
public SecurityOptions Security = new();
92128

93129
[JsonProperty(Order = -60)]
130+
[RequiresRestart]
94131
public SmtpSettings SmtpSettings = new();
95132

96133
#endregion Security
97134

98135
#region Other Game Properties
99136

137+
[RequiresRestart]
100138
public List<string> AnimatedSprites { get; set; } = [];
101139

140+
[RequiresRestart]
102141
public PacketOptions Packets = new();
103142

104143
public ChatOptions Chat = new();
105144

145+
[RequiresRestart]
106146
public CombatOptions Combat = new();
107147

148+
[RequiresRestart]
108149
public EquipmentOptions Equipment = new();
109150

151+
[RequiresRestart]
110152
public int EventWatchdogKillThreshold { get; set; } = 5000;
111153

112154
/// <summary>
113155
/// Passability configuration by map zone
114156
/// </summary>
115-
public Passability Passability { get; } = new();
157+
public PassabilityOptions Passability { get; } = new();
116158

117159
public ushort ValidPasswordResetTimeMinutes { get; set; } = 30;
118160

@@ -144,12 +186,6 @@ public partial class Options
144186

145187
#endregion Configuration Properties
146188

147-
public static Options Instance { get; private set; }
148-
149-
public static bool IsLoaded => Instance != null;
150-
151-
public bool SmtpValid { get; set; }
152-
153189
public void FixAnimatedSprites()
154190
{
155191
for (var i = 0; i < AnimatedSprites.Count; i++)
@@ -158,8 +194,6 @@ public void FixAnimatedSprites()
158194
}
159195
}
160196

161-
public static string ResourcesDirectory { get; set; } = "resources";
162-
163197
public static bool LoadFromDisk()
164198
{
165199
Options instance = new();
@@ -265,15 +299,4 @@ public bool ShouldSerializeSecurity()
265299
{
266300
return !SendingToClient;
267301
}
268-
269-
#region Constants
270-
271-
// TODO: Clean these up
272-
//Values that cannot easily be changed:
273-
274-
public const string DEFAULT_GAME_NAME = "Intersect";
275-
276-
public const int DEFAULT_SERVER_PORT = 5400;
277-
278-
#endregion
279302
}

Framework/Intersect.Framework.Core/Config/PacketSecurityOptions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ public partial class PacketSecurityOptions
5454
/// Packet flooding detection thresholds for the game editor. (No Restrictions.)
5555
/// </summary>
5656
[JsonProperty("EditorFloodThreshholds")]
57-
public FloodThreshholds EditorThreshholds = FloodThreshholds.Editor();
57+
public FloodThresholdOptions EditorThreshholds = FloodThresholdOptions.Editor();
5858

5959
/// <summary>
6060
/// Packet flooding detection thresholds for general players. Pretty strict.
6161
/// Might need to be adjusted if there is a lot of high paceed actions/movement/combat in your game.
6262
/// </summary>
6363
[JsonProperty("PlayerFloodThreshholds")]
64-
public FloodThreshholds PlayerThreshholds = new();
64+
public FloodThresholdOptions PlayerThreshholds = new();
6565

6666
/// <summary>
6767
/// Packet flooding detection thresholds for mods/admins. Hopefully you trust these guys.
6868
/// Limits need to be higher than general players since they can warp quickly around the world with shift click.
6969
/// </summary>
7070
[JsonProperty("ModAdminFloodThreshholds")]
71-
public FloodThreshholds ModAdminThreshholds = FloodThreshholds.Editor();
71+
public FloodThresholdOptions ModAdminThreshholds = FloodThresholdOptions.Editor();
7272

7373
/// <summary>
7474
/// Packet flooding detection threshholds for all users who are not yet logged in.
7575
/// </summary>
7676
[JsonProperty("FloodThreshholds")]
77-
public FloodThreshholds Threshholds = FloodThreshholds.NotLoggedIn();
77+
public FloodThresholdOptions Threshholds = FloodThresholdOptions.NotLoggedIn();
7878
#endregion
7979
}

0 commit comments

Comments
 (0)