- Fixed some properties in GameServerSettings not being saved due to being private.

- Fixed serversettings.xml overriding the settings entered in the "host server" menu in the client project.
- Added a default serversettings.xml file.

TODO: either add an error/warning of some sort if trying to use any of the ObjectProperty attributes on a non-public property or make ObjectProperty compatible with private properties. + Refactor Properties.cs, class/method naming in particular.
This commit is contained in:
Joonas Rikkonen
2017-07-20 21:03:00 +03:00
parent d694c7efdc
commit ce3a8df9e0
7 changed files with 55 additions and 39 deletions
@@ -80,8 +80,12 @@ namespace Barotrauma.Networking
private bool autoRestart;
private List<SavedClientPermission> clientPermissions = new List<SavedClientPermission>();
private bool isPublic;
private int maxPlayers;
private List<SavedClientPermission> clientPermissions = new List<SavedClientPermission>();
[HasDefaultValue(true, true)]
public bool RandomizeSeed
{
@@ -170,41 +174,20 @@ namespace Barotrauma.Networking
AutoRestartTimer = autoRestart ? AutoRestartInterval : 0.0f;
}
}
[HasDefaultValue(8, true)]
private int MaxPlayers
[HasDefaultValue(true, true)]
public bool AllowRespawn
{
get;
set;
}
[HasDefaultValue(false, true)]
private bool Public
{
get;
set;
}
[HasDefaultValue(false, true)]
private bool AttemptUPNP
{
get { return config.EnableUPnP; }
set { config.EnableUPnP = value; }
}
public YesNoMaybe TraitorsEnabled
{
get;
set;
}
[HasDefaultValue(true, true)]
public bool AllowRespawn
{
get;
set;
}
public SelectionMode SubSelectionMode
{
get { return subSelectionMode; }
@@ -246,6 +229,12 @@ namespace Barotrauma.Networking
XDocument doc = new XDocument(new XElement("serversettings"));
ObjectProperty.SaveProperties(this, doc.Root, true);
doc.Root.SetAttributeValue("name", name);
doc.Root.SetAttributeValue("public", isPublic);
doc.Root.SetAttributeValue("port", config.Port);
doc.Root.SetAttributeValue("maxplayers", maxPlayers);
doc.Root.SetAttributeValue("enableupnp", config.EnableUPnP);
doc.Root.SetAttributeValue("SubSelection", subSelectionMode.ToString());
doc.Root.SetAttributeValue("ModeSelection", modeSelectionMode.ToString());