- 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:
@@ -102,7 +102,7 @@ namespace Barotrauma
|
|||||||
XDocument doc = ToolBox.TryLoadXml(GameServer.SettingsFile);
|
XDocument doc = ToolBox.TryLoadXml(GameServer.SettingsFile);
|
||||||
if (doc == null)
|
if (doc == null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("File \""+GameServer.SettingsFile+"\" not found. Starting the server with default settings.");
|
DebugConsole.ThrowError("File \"" + GameServer.SettingsFile + "\" not found. Starting the server with default settings.");
|
||||||
Server = new GameServer("Server", 14242, false, "", false, 10);
|
Server = new GameServer("Server", 14242, false, "", false, 10);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ namespace Barotrauma
|
|||||||
ToolBox.GetAttributeInt(doc.Root, "port", 14242),
|
ToolBox.GetAttributeInt(doc.Root, "port", 14242),
|
||||||
ToolBox.GetAttributeBool(doc.Root, "public", false),
|
ToolBox.GetAttributeBool(doc.Root, "public", false),
|
||||||
ToolBox.GetAttributeString(doc.Root, "password", ""),
|
ToolBox.GetAttributeString(doc.Root, "password", ""),
|
||||||
ToolBox.GetAttributeBool(doc.Root, "attemptupnp", false),
|
ToolBox.GetAttributeBool(doc.Root, "enableupnp", false),
|
||||||
ToolBox.GetAttributeInt(doc.Root, "maxplayers", 10));
|
ToolBox.GetAttributeInt(doc.Root, "maxplayers", 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -734,6 +734,9 @@
|
|||||||
<Content Include="$(MSBuildThisFileDirectory)serverconfig.xml">
|
<Content Include="$(MSBuildThisFileDirectory)serverconfig.xml">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="$(MSBuildThisFileDirectory)serversettings.xml">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="$(MSBuildThisFileDirectory)Content\blurshader.xnb">
|
<None Include="$(MSBuildThisFileDirectory)Content\blurshader.xnb">
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ namespace Barotrauma.Networking
|
|||||||
AdminAuthPass = "";
|
AdminAuthPass = "";
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.Public = isPublic;
|
this.isPublic = isPublic;
|
||||||
|
this.maxPlayers = maxPlayers;
|
||||||
this.password = "";
|
this.password = "";
|
||||||
if (password.Length>0)
|
if (password.Length>0)
|
||||||
{
|
{
|
||||||
@@ -107,8 +108,7 @@ namespace Barotrauma.Networking
|
|||||||
config.EnableUPnP = true;
|
config.EnableUPnP = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.MaximumConnections = maxPlayers*2; //double the lidgren connections for unauthenticated players
|
config.MaximumConnections = maxPlayers * 2; //double the lidgren connections for unauthenticated players
|
||||||
MaxPlayers = maxPlayers;
|
|
||||||
|
|
||||||
config.DisableMessageType(NetIncomingMessageType.DebugMessage |
|
config.DisableMessageType(NetIncomingMessageType.DebugMessage |
|
||||||
NetIncomingMessageType.WarningMessage | NetIncomingMessageType.Receipt |
|
NetIncomingMessageType.WarningMessage | NetIncomingMessageType.Receipt |
|
||||||
@@ -229,7 +229,7 @@ namespace Barotrauma.Networking
|
|||||||
request.AddParameter("servername", name);
|
request.AddParameter("servername", name);
|
||||||
request.AddParameter("serverport", Port);
|
request.AddParameter("serverport", Port);
|
||||||
request.AddParameter("currplayers", connectedClients.Count);
|
request.AddParameter("currplayers", connectedClients.Count);
|
||||||
request.AddParameter("maxplayers", MaxPlayers);
|
request.AddParameter("maxplayers", maxPlayers);
|
||||||
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
|
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
|
||||||
request.AddParameter("version", GameMain.Version.ToString());
|
request.AddParameter("version", GameMain.Version.ToString());
|
||||||
if (GameMain.Config.SelectedContentPackage != null)
|
if (GameMain.Config.SelectedContentPackage != null)
|
||||||
@@ -284,7 +284,7 @@ namespace Barotrauma.Networking
|
|||||||
request.AddParameter("serverport", Port);
|
request.AddParameter("serverport", Port);
|
||||||
request.AddParameter("gamestarted", gameStarted ? 1 : 0);
|
request.AddParameter("gamestarted", gameStarted ? 1 : 0);
|
||||||
request.AddParameter("currplayers", connectedClients.Count);
|
request.AddParameter("currplayers", connectedClients.Count);
|
||||||
request.AddParameter("maxplayers", MaxPlayers);
|
request.AddParameter("maxplayers", maxPlayers);
|
||||||
|
|
||||||
Log("Refreshing connection with master server...", ServerLog.MessageType.ServerMessage);
|
Log("Refreshing connection with master server...", ServerLog.MessageType.ServerMessage);
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
inc.SenderConnection.Deny("You have been banned from the server");
|
inc.SenderConnection.Deny("You have been banned from the server");
|
||||||
}
|
}
|
||||||
else if (ConnectedClients.Count >= MaxPlayers)
|
else if (ConnectedClients.Count >= maxPlayers)
|
||||||
{
|
{
|
||||||
inc.SenderConnection.Deny("Server full");
|
inc.SenderConnection.Deny("Server full");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace Barotrauma.Networking
|
|||||||
if (unauthClient == null)
|
if (unauthClient == null)
|
||||||
{
|
{
|
||||||
//new client, generate nonce and add to unauth queue
|
//new client, generate nonce and add to unauth queue
|
||||||
if (ConnectedClients.Count >= MaxPlayers)
|
if (ConnectedClients.Count >= maxPlayers)
|
||||||
{
|
{
|
||||||
//server is full, can't allow new connection
|
//server is full, can't allow new connection
|
||||||
conn.Disconnect("Server full");
|
conn.Disconnect("Server full");
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private bool autoRestart;
|
private bool autoRestart;
|
||||||
|
|
||||||
|
private bool isPublic;
|
||||||
|
|
||||||
|
private int maxPlayers;
|
||||||
|
|
||||||
private List<SavedClientPermission> clientPermissions = new List<SavedClientPermission>();
|
private List<SavedClientPermission> clientPermissions = new List<SavedClientPermission>();
|
||||||
|
|
||||||
[HasDefaultValue(true, true)]
|
[HasDefaultValue(true, true)]
|
||||||
@@ -171,40 +175,19 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HasDefaultValue(8, true)]
|
[HasDefaultValue(true, true)]
|
||||||
private int MaxPlayers
|
public bool AllowRespawn
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
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
|
public YesNoMaybe TraitorsEnabled
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HasDefaultValue(true, true)]
|
|
||||||
public bool AllowRespawn
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SelectionMode SubSelectionMode
|
public SelectionMode SubSelectionMode
|
||||||
{
|
{
|
||||||
get { return subSelectionMode; }
|
get { return subSelectionMode; }
|
||||||
@@ -247,6 +230,12 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
ObjectProperty.SaveProperties(this, doc.Root, true);
|
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("SubSelection", subSelectionMode.ToString());
|
||||||
doc.Root.SetAttributeValue("ModeSelection", modeSelectionMode.ToString());
|
doc.Root.SetAttributeValue("ModeSelection", modeSelectionMode.ToString());
|
||||||
|
|
||||||
|
|||||||
@@ -91,14 +91,12 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public Voting Voting;
|
public Voting Voting;
|
||||||
|
|
||||||
[HasDefaultValue(14242, true)]
|
|
||||||
public int Port
|
public int Port
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HasDefaultValue("", true)]
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return name; }
|
get { return name; }
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<serversettings
|
||||||
|
name="Server"
|
||||||
|
ServerMessage=""
|
||||||
|
port="14242"
|
||||||
|
password=""
|
||||||
|
public="True"
|
||||||
|
maxplayers="10"
|
||||||
|
attemptupnp="false"
|
||||||
|
randomizeseed="True"
|
||||||
|
respawninterval="300"
|
||||||
|
maxtransporttime="180"
|
||||||
|
minrespawnratio="0.2"
|
||||||
|
autorestartinterval="60"
|
||||||
|
allowspectating="True"
|
||||||
|
endroundatlevelend="True"
|
||||||
|
saveserverlogs="True"
|
||||||
|
allowfiletransfers="True"
|
||||||
|
allowrespawn="True"
|
||||||
|
allowvotekick="True"
|
||||||
|
endvoterequiredratio="0.6"
|
||||||
|
kickvoterequiredratio="0.6"
|
||||||
|
SubSelection="Manual"
|
||||||
|
ModeSelection="Manual"
|
||||||
|
TraitorsEnabled="No"
|
||||||
|
/>
|
||||||
Reference in New Issue
Block a user