(8efab43bb) Added "setmaxplayers" command, allow clients to use "setpassword" and remove password protection if the password argument is empty.
This commit is contained in:
@@ -452,6 +452,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
commands.Add(new Command("clientlist", "", (string[] args) => { }));
|
commands.Add(new Command("clientlist", "", (string[] args) => { }));
|
||||||
AssignRelayToServer("clientlist", true);
|
AssignRelayToServer("clientlist", true);
|
||||||
|
commands.Add(new Command("setmaxplayers|maxplayers", "", (string[] args) => { }));
|
||||||
|
AssignRelayToServer("setmaxplayers", true);
|
||||||
|
commands.Add(new Command("setpassword|password", "", (string[] args) => { }));
|
||||||
|
AssignRelayToServer("setpassword", true);
|
||||||
|
|
||||||
AssignOnExecute("control", (string[] args) =>
|
AssignOnExecute("control", (string[] args) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -788,11 +788,47 @@ namespace Barotrauma
|
|||||||
GameMain.Server.SendConsoleMessage("The code words are: " + traitorManager.codeWords + ", response: " + traitorManager.codeResponse + ".", client);
|
GameMain.Server.SendConsoleMessage("The code words are: " + traitorManager.codeWords + ", response: " + traitorManager.codeResponse + ".", client);
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.Add(new Command("setpassword|setserverpassword", "setpassword [password]: Changes the password of the server that's being hosted.", (string[] args) =>
|
commands.Add(new Command("setpassword|setserverpassword|password", "setpassword [password]: Changes the password of the server that's being hosted.", (string[] args) =>
|
||||||
|
{
|
||||||
|
if (GameMain.Server == null) { return; }
|
||||||
|
GameMain.Server.ServerSettings.SetPassword(args.Length > 0 ? args[0] : "");
|
||||||
|
NewMessage(GameMain.Server.ServerSettings.HasPassword ? "Changed the server password." : "Removed password protection from the server.");
|
||||||
|
}));
|
||||||
|
AssignOnClientRequestExecute("setpassword", (Client client, Vector2 cursorPos, string[] args) =>
|
||||||
|
{
|
||||||
|
if (GameMain.Server == null) { return; }
|
||||||
|
GameMain.Server.ServerSettings.SetPassword(args.Length > 0 ? args[0] : "");
|
||||||
|
NewMessage(client.Name + " " + (GameMain.Server.ServerSettings.HasPassword ? " changed the server password to \"" + args[0] + "\"." : " removed password protection from the server."));
|
||||||
|
GameMain.Server.SendConsoleMessage(GameMain.Server.ServerSettings.HasPassword ? "Changed the server password." : "Removed password protection from the server.", client);
|
||||||
|
});
|
||||||
|
|
||||||
|
commands.Add(new Command("setmaxplayers|maxplayers", "setmaxplayers [max players]: Sets the maximum player count of the server that's being hosted.", (string[] args) =>
|
||||||
{
|
{
|
||||||
if (GameMain.Server == null || args.Length == 0) return;
|
if (GameMain.Server == null || args.Length == 0) return;
|
||||||
GameMain.Server.ServerSettings.SetPassword(args[0]);
|
if (!int.TryParse(args[0], out int maxPlayers))
|
||||||
|
{
|
||||||
|
NewMessage(args[0] + " is not a valid player count.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameMain.Server.ServerSettings.MaxPlayers = maxPlayers;
|
||||||
|
NewMessage("Set the maximum player count to " + maxPlayers + ".");
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
AssignOnClientRequestExecute("setmaxplayers", (Client client, Vector2 cursorPos, string[] args) =>
|
||||||
|
{
|
||||||
|
if (GameMain.Server == null || args.Length == 0) return;
|
||||||
|
if (!int.TryParse(args[0], out int maxPlayers))
|
||||||
|
{
|
||||||
|
GameMain.Server.SendConsoleMessage(args[0] + " is not a valid player count.", client);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameMain.Server.ServerSettings.MaxPlayers = maxPlayers;
|
||||||
|
NewMessage(client.Name + " set the maximum player count to " + maxPlayers + ".");
|
||||||
|
GameMain.Server.SendConsoleMessage("Set the maximum player count to " + maxPlayers + ".", client);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
commands.Add(new Command("restart|reset", "restart/reset: Close and restart the server.", (string[] args) =>
|
commands.Add(new Command("restart|reset", "restart/reset: Close and restart the server.", (string[] args) =>
|
||||||
{
|
{
|
||||||
@@ -1589,12 +1625,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
commands.Add(new Command("setpassword|setserverpassword", "setpassword [password]: Changes the password of the server that's being hosted.", (string[] args) =>
|
|
||||||
{
|
|
||||||
if (GameMain.Server == null || args.Length == 0) return;
|
|
||||||
GameMain.Server.ServerSettings.SetPassword(args[0]);
|
|
||||||
}));
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
commands.Add(new Command("spamevents", "A debug command that creates a ton of entity events.", (string[] args) =>
|
commands.Add(new Command("spamevents", "A debug command that creates a ton of entity events.", (string[] args) =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -611,6 +611,7 @@ namespace Barotrauma.Networking
|
|||||||
public int MaxPlayers
|
public int MaxPlayers
|
||||||
{
|
{
|
||||||
get { return maxPlayers; }
|
get { return maxPlayers; }
|
||||||
|
set { maxPlayers = MathHelper.Clamp(value, 1, NetConfig.MaxPlayers); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MissionType> AllowedRandomMissionTypes
|
public List<MissionType> AllowedRandomMissionTypes
|
||||||
@@ -635,7 +636,14 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public void SetPassword(string password)
|
public void SetPassword(string password)
|
||||||
{
|
{
|
||||||
this.password = Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(password)));
|
if (string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
this.password = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.password = Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(password)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPasswordCorrect(string input, int nonce)
|
public bool IsPasswordCorrect(string input, int nonce)
|
||||||
|
|||||||
Reference in New Issue
Block a user