mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
RCON Broadcast Mode
- Added RCON broadcast mode selection to ASM global settings. - Added new Mode selection method to ServerApp, so the correct command is used.
This commit is contained in:
parent
35d8153236
commit
dc830c602c
9 changed files with 149 additions and 107 deletions
|
|
@ -2205,6 +2205,23 @@ namespace ServerManagerTool.Lib
|
|||
return ModUtils.ValidateModList(modIdList);
|
||||
}
|
||||
|
||||
public static string GetMutexName(string directory)
|
||||
{
|
||||
using (var hashAlgo = MD5.Create())
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
var hashStr = Encoding.UTF8.GetBytes(directory ?? Assembly.GetExecutingAssembly().Location);
|
||||
var hash = hashAlgo.ComputeHash(hashStr);
|
||||
foreach (var b in hash)
|
||||
{
|
||||
builder.Append(b.ToString("x2"));
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetProfileBackupFolder(ServerProfileSnapshot profile)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Config.Default.BackupPath))
|
||||
|
|
@ -2221,20 +2238,18 @@ namespace ServerManagerTool.Lib
|
|||
|
||||
public static string GetProfileServerConfigDir(ServerProfileSnapshot profile) => Path.Combine(profile.InstallDirectory, Config.Default.ServerConfigRelativePath);
|
||||
|
||||
public static string GetMutexName(string directory)
|
||||
private static string GetRconMessageCommand(string commandValue)
|
||||
{
|
||||
using (var hashAlgo = MD5.Create())
|
||||
switch (commandValue.ToLower())
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
case "alert":
|
||||
return ServerRcon.RCON_COMMAND_ALERT;
|
||||
|
||||
var hashStr = Encoding.UTF8.GetBytes(directory ?? Assembly.GetExecutingAssembly().Location);
|
||||
var hash = hashAlgo.ComputeHash(hashStr);
|
||||
foreach (var b in hash)
|
||||
{
|
||||
builder.Append(b.ToString("x2"));
|
||||
}
|
||||
case "server":
|
||||
return ServerRcon.RCON_COMMAND_SERVER;
|
||||
|
||||
return builder.ToString();
|
||||
default:
|
||||
return ServerRcon.RCON_COMMAND_BROADCAST;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2563,7 +2578,7 @@ namespace ServerManagerTool.Lib
|
|||
if (string.IsNullOrWhiteSpace(message) || !SendMessages)
|
||||
return false;
|
||||
|
||||
var sent = await SendCommandAsync($"{Config.Default.RCON_MessageCommand.ToLower()} {message}", false);
|
||||
var sent = await SendCommandAsync($"{GetRconMessageCommand(Config.Default.RCON_MessageCommand)} {message}", false);
|
||||
|
||||
if (sent)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue