Added a console command for changing the server password. Closes #325
This commit is contained in:
@@ -197,6 +197,12 @@ namespace Barotrauma
|
||||
NewMessage("***************", Color.Cyan);
|
||||
}));
|
||||
|
||||
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.SetPassword(args[0]);
|
||||
}));
|
||||
|
||||
commands.Add(new Command("createfilelist", "", (string[] args) =>
|
||||
{
|
||||
UpdaterUtil.SaveFileList("filelist.xml");
|
||||
|
||||
@@ -77,9 +77,9 @@ namespace Barotrauma.Networking
|
||||
this.isPublic = isPublic;
|
||||
this.maxPlayers = maxPlayers;
|
||||
this.password = "";
|
||||
if (password.Length>0)
|
||||
if (password.Length > 0)
|
||||
{
|
||||
this.password = Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(password)));
|
||||
SetPassword(password);
|
||||
}
|
||||
|
||||
config = new NetPeerConfiguration("barotrauma");
|
||||
@@ -131,6 +131,11 @@ namespace Barotrauma.Networking
|
||||
CoroutineManager.StartCoroutine(StartServer(isPublic));
|
||||
}
|
||||
|
||||
public void SetPassword(string password)
|
||||
{
|
||||
this.password = Encoding.UTF8.GetString(NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(password)));
|
||||
}
|
||||
|
||||
private IEnumerable<object> StartServer(bool isPublic)
|
||||
{
|
||||
bool error = false;
|
||||
|
||||
Reference in New Issue
Block a user