public static void SetServerName(string newName, bool save = true) { if (string.IsNullOrWhiteSpace(newName)) { return; } int byteCount = Encoding.UTF8.GetByteCount(newName); if (byteCount > byte.MaxValue) { Logger.LogError("Server name is too long! Max 255 bytes. Has " + byteCount); return; } serverName = newName; TCPListener.UpdateStatusInfo(); Console.Title = serverName; if (save) { Save(); } Logger.Log("Server name is set to '{0}'", serverName); }
static void SetPassword(byte[] newHash, bool save) { if (newHash == null || newHash.Length != 16) { password = null; Password = null; Network.GameServer.ServerInterface.SetIncomingPassword(default(string), 0); Logger.Log("Password removed."); } else { password = newHash; Password = new ReadOnlyCollection <byte>(password); string pwStr = Convert.ToBase64String(password); Network.GameServer.ServerInterface.SetIncomingPassword(pwStr, pwStr.Length); Logger.Log("Password is set."); } TCPListener.UpdateStatusInfo(); if (save) { Save(); } }