Skip to content

Commit d3670ea

Browse files
authored
Allows cfg to be updated with any changes rather than always using default properties for those missing (SubnauticaNitrox#1545)
* Allows cfg to be updated with any changes rather than always using default properties for those missing * Changed Update to handle null actions
1 parent 4a35596 commit d3670ea

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

NitroxModel/Serialization/NitroxConfig.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ public void Serialize()
131131
/// Ensures updates are properly persisted to the backing config file without overwriting user edits.
132132
/// </summary>
133133
/// <param name="config"></param>
134-
public void Update(Action<T> config)
134+
public void Update(Action<T> config = null)
135135
{
136136
try
137137
{
138138
Deserialize();
139-
config(this as T);
139+
config?.Invoke(this as T);
140140
}
141141
finally
142142
{

NitroxServer/Serialization/ServerConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public string SaveName
109109
public static ServerConfig Load()
110110
{
111111
ServerConfig config = new();
112-
config.Deserialize();
112+
config.Update();
113113
return config;
114114
}
115115
}

NitroxServer/Server.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ public void Stop(bool shouldSave = true)
133133
if (shouldSave)
134134
{
135135
Save();
136-
if (!serverConfig.ConfigFileExists)
137-
{
138-
serverConfig.Serialize();
139-
}
140136
}
141137

142138
server.Stop();

0 commit comments

Comments
 (0)