Skip to content

Commit

Permalink
Allows cfg to be updated with any changes rather than always using de…
Browse files Browse the repository at this point in the history
…fault properties for those missing (#1545)

* Allows cfg to be updated with any changes rather than always using default properties for those missing

* Changed Update to handle null actions
  • Loading branch information
Coding-Hen authored Jul 25, 2021
1 parent 4a35596 commit d3670ea
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions NitroxModel/Serialization/NitroxConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ public void Serialize()
/// Ensures updates are properly persisted to the backing config file without overwriting user edits.
/// </summary>
/// <param name="config"></param>
public void Update(Action<T> config)
public void Update(Action<T> config = null)
{
try
{
Deserialize();
config(this as T);
config?.Invoke(this as T);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion NitroxServer/Serialization/ServerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public string SaveName
public static ServerConfig Load()
{
ServerConfig config = new();
config.Deserialize();
config.Update();
return config;
}
}
Expand Down
4 changes: 0 additions & 4 deletions NitroxServer/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public void Stop(bool shouldSave = true)
if (shouldSave)
{
Save();
if (!serverConfig.ConfigFileExists)
{
serverConfig.Serialize();
}
}

server.Stop();
Expand Down

0 comments on commit d3670ea

Please sign in to comment.