Merge branch 'master' of https://github.com/Regalis11/Barotrauma.git
This commit is contained in:
@@ -28,11 +28,11 @@ namespace Barotrauma
|
||||
if (!CheatsEnabled && IsCheat)
|
||||
{
|
||||
NewMessage("Client \"" + client.Name + "\" attempted to use the command \"" + names[0] + "\". Cheats must be enabled using \"enablecheats\" before the command can be used.", Color.Red);
|
||||
GameMain.Server.SendConsoleMessage("You need to enable cheats using the command \"enablecheats\" before you can use the command \"" + names[0] + "\".", client);
|
||||
GameMain.Server.SendConsoleMessage("You need to enable cheats using the command \"enablecheats\" before you can use the command \"" + names[0] + "\".", client, Color.Red);
|
||||
|
||||
#if USE_STEAM
|
||||
NewMessage("Enabling cheats will disable Steam achievements during this play session.", Color.Red);
|
||||
GameMain.Server.SendConsoleMessage("Enabling cheats will disable Steam achievements during this play session.", client);
|
||||
GameMain.Server.SendConsoleMessage("Enabling cheats will disable Steam achievements during this play session.", client, Color.Red);
|
||||
#endif
|
||||
|
||||
return;
|
||||
@@ -367,7 +367,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[0] + "\" is not a valid bot spawn mode. (Valid modes are Fill and Normal)", client);
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[0] + "\" is not a valid bot spawn mode. (Valid modes are Fill and Normal)", client, Color.Red);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1046,12 +1046,12 @@ namespace Barotrauma
|
||||
}));
|
||||
AssignOnClientRequestExecute("clientlist", (Client client, Vector2 cursorWorldPos, string[] args) =>
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("***************", client);
|
||||
GameMain.Server.SendConsoleMessage("***************", client, Color.Cyan);
|
||||
foreach (Client c in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("- " + c.ID.ToString() + ": " + c.Name + ", " + c.Connection.EndPointString + $", ping {c.Ping} ms", client);
|
||||
GameMain.Server.SendConsoleMessage("- " + c.ID.ToString() + ": " + c.Name + ", " + c.Connection.EndPointString + $", ping {c.Ping} ms", client, Color.Cyan);
|
||||
}
|
||||
GameMain.Server.SendConsoleMessage("***************", client);
|
||||
GameMain.Server.SendConsoleMessage("***************", client, Color.Cyan);
|
||||
});
|
||||
|
||||
commands.Add(new Command("enablecheats", "enablecheats: Enables cheat commands and disables Steam achievements during this play session.", (string[] args) =>
|
||||
@@ -1164,13 +1164,13 @@ namespace Barotrauma
|
||||
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);
|
||||
GameMain.Server.SendConsoleMessage(args[0] + " is not a valid player count.", client, Color.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (maxPlayers > NetConfig.MaxPlayers)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage($"Setting the maximum amount of players to {maxPlayers} failed due to exceeding the limit of {NetConfig.MaxPlayers} players per server. Using the maximum of {NetConfig.MaxPlayers} instead.", client);
|
||||
GameMain.Server.SendConsoleMessage($"Setting the maximum amount of players to {maxPlayers} failed due to exceeding the limit of {NetConfig.MaxPlayers} players per server. Using the maximum of {NetConfig.MaxPlayers} instead.", client, Color.Red);
|
||||
maxPlayers = NetConfig.MaxPlayers;
|
||||
}
|
||||
|
||||
@@ -1471,7 +1471,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[1] + "\" is not a valid ban duration.", client);
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[1] + "\" is not a valid ban duration.", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1591,7 +1591,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[0] + "\" is not a valid bot spawn mode. (Valid modes are Fill and Normal)", client);
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[0] + "\" is not a valid bot spawn mode. (Valid modes are Fill and Normal)", client, Color.Red);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1615,7 +1615,7 @@ namespace Barotrauma
|
||||
if (Submarine.MainSub == null || Level.Loaded == null) return;
|
||||
if (Level.Loaded.Type == LevelData.LevelType.Outpost)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("The teleportsub command is unavailable in outpost levels!", client);
|
||||
GameMain.Server.SendConsoleMessage("The teleportsub command is unavailable in outpost levels!", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1639,7 +1639,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!(GameMain.GameSession?.Campaign is MultiPlayerCampaign mpCampaign))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("No campaign active.", client);
|
||||
GameMain.Server.SendConsoleMessage("No campaign active.", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
mpCampaign.LastUpdateID++;
|
||||
@@ -1687,13 +1687,13 @@ namespace Barotrauma
|
||||
a.Identifier.Equals(args[0], StringComparison.OrdinalIgnoreCase));
|
||||
if (afflictionPrefab == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Affliction \"" + args[0] + "\" not found.", client);
|
||||
GameMain.Server.SendConsoleMessage("Affliction \"" + args[0] + "\" not found.", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!float.TryParse(args[1], out float afflictionStrength))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[1] + "\" is not a valid affliction strength.", client);
|
||||
GameMain.Server.SendConsoleMessage("\"" + args[1] + "\" is not a valid affliction strength.", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1776,7 +1776,7 @@ namespace Barotrauma
|
||||
c.DisplayName.Equals(args[0], StringComparison.OrdinalIgnoreCase));
|
||||
if (talentPrefab == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Couldn't find the talent \"" + args[0] + "\".", client);
|
||||
GameMain.Server.SendConsoleMessage("Couldn't find the talent \"" + args[0] + "\".", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
targetCharacter.GiveTalent(talentPrefab);
|
||||
@@ -1802,12 +1802,12 @@ namespace Barotrauma
|
||||
var job = JobPrefab.Prefabs.Find(jp => jp.Name != null && jp.Name.Equals(args[0], StringComparison.OrdinalIgnoreCase));
|
||||
if (job == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage($"Failed to find the job \"{args[0]}\".", client);
|
||||
GameMain.Server.SendConsoleMessage($"Failed to find the job \"{args[0]}\".", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
if (!TalentTree.JobTalentTrees.TryGetValue(job.Identifier, out TalentTree talentTree))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage($"No talents configured for the job \"{args[0]}\".", client);
|
||||
GameMain.Server.SendConsoleMessage($"No talents configured for the job \"{args[0]}\".", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
talentTrees.Add(talentTree);
|
||||
@@ -1857,7 +1857,7 @@ namespace Barotrauma
|
||||
(Client client, Vector2 cursorWorldPos, string[] args) =>
|
||||
{
|
||||
Vector2 explosionPos = cursorWorldPos;
|
||||
float range = 500, force = 10, damage = 50, structureDamage = 10, itemDamage = 100, empStrength = 0.0f, ballastFloraStrength = 50f;
|
||||
float range = 500, force = 10, damage = 50, structureDamage = 20, itemDamage = 100, empStrength = 0.0f, ballastFloraStrength = 50f;
|
||||
if (args.Length > 0) float.TryParse(args[0], out range);
|
||||
if (args.Length > 1) float.TryParse(args[1], out force);
|
||||
if (args.Length > 2) float.TryParse(args[2], out damage);
|
||||
@@ -1874,6 +1874,10 @@ namespace Barotrauma
|
||||
(Client client, Vector2 cursorWorldPos, string[] args) =>
|
||||
{
|
||||
Character killedCharacter = (args.Length == 0) ? client.Character : FindMatchingCharacter(args);
|
||||
if (killedCharacter == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Could not find the specified character.", client, Color.Red);
|
||||
}
|
||||
killedCharacter?.SetAllDamage(200.0f, 0.0f, 0.0f);
|
||||
}
|
||||
);
|
||||
@@ -1889,6 +1893,10 @@ namespace Barotrauma
|
||||
GameMain.Server.SetClientCharacter(client, character);
|
||||
client.SpectateOnly = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Could not find the specified character.", client, Color.Red);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1915,7 +1923,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage(args[0] + " is not a valid difficulty setting (enter a value between 0-100)", client);
|
||||
GameMain.Server.SendConsoleMessage(args[0] + " is not a valid difficulty setting (enter a value between 0-100)", client, Color.Red);
|
||||
NewMessage(args[0] + " is not a valid difficulty setting (enter a value between 0-100)", Color.Red);
|
||||
}
|
||||
}
|
||||
@@ -1939,7 +1947,7 @@ namespace Barotrauma
|
||||
ClientPermissions permission = ClientPermissions.None;
|
||||
if (!Enum.TryParse(perm, true, out permission))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage(perm + " is not a valid permission!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage(perm + " is not a valid permission!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1971,7 +1979,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (client.Connection == GameMain.Server.OwnerConnection)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Cannot revoke permissions from the server owner!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Cannot revoke permissions from the server owner!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1980,7 +1988,7 @@ namespace Barotrauma
|
||||
ClientPermissions permission = ClientPermissions.None;
|
||||
if (!Enum.TryParse(perm, true, out permission))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage(perm + " is not a valid permission!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage(perm + " is not a valid permission!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
client.RemovePermission(permission);
|
||||
@@ -2004,7 +2012,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (client.Connection == GameMain.Server.OwnerConnection)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Cannot modify the rank of the server owner!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Cannot modify the rank of the server owner!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2012,7 +2020,7 @@ namespace Barotrauma
|
||||
PermissionPreset preset = PermissionPreset.List.Find(p => p.Name.Equals(rank, StringComparison.OrdinalIgnoreCase));
|
||||
if (preset == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Rank \"" + rank + "\" not found.", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Rank \"" + rank + "\" not found.", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2032,12 +2040,12 @@ namespace Barotrauma
|
||||
var client = FindClient(args[0]);
|
||||
if (client == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Client \"" + args[0] + "\" not found.", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Client \"" + args[0] + "\" not found.", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
if (client.Connection == GameMain.Server.OwnerConnection)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Cannot modify the command permissions of the server owner!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Cannot modify the command permissions of the server owner!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2056,7 +2064,7 @@ namespace Barotrauma
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommands[i]));
|
||||
if (matchingCommand == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + splitCommands[i] + "\"!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + splitCommands[i] + "\"!", senderClient, Color.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2094,7 +2102,7 @@ namespace Barotrauma
|
||||
}
|
||||
if (client.Connection == GameMain.Server.OwnerConnection)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Cannot revoke command permissions from the server owner!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Cannot revoke command permissions from the server owner!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
List<Command> revokedCommands = new List<Command>();
|
||||
@@ -2112,7 +2120,7 @@ namespace Barotrauma
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommands[i]));
|
||||
if (matchingCommand == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + splitCommands[i] + "\"!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Could not find the command \"" + splitCommands[i] + "\"!", senderClient, Color.Red);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2192,7 +2200,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Invalid parameters. The command should be formatted as \"setclientcharacter [client] [character]\". If the names consist of multiple words, you should surround them with quotation marks.", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Invalid parameters. The command should be formatted as \"setclientcharacter [client] [character]\". If the names consist of multiple words, you should surround them with quotation marks.", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2205,7 +2213,7 @@ namespace Barotrauma
|
||||
var client = GameMain.Server.ConnectedClients.Find(c => c.Name == args[0]);
|
||||
if (client == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Client \"" + args[0] + "\" not found.", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Client \"" + args[0] + "\" not found.", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2222,17 +2230,18 @@ namespace Barotrauma
|
||||
if (args.Length == 0) { return; }
|
||||
if (!(GameMain.GameSession?.GameMode is MultiPlayerCampaign campaign))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("No campaign active!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("No campaign active!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
if (int.TryParse(args[0], out int money))
|
||||
{
|
||||
campaign.Money += money;
|
||||
GameAnalyticsManager.AddMoneyGainedEvent(money, GameAnalyticsManager.MoneySource.Cheat, "console");
|
||||
campaign.LastUpdateID++;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage($"\"{args[0]}\" is not a valid numeric value.", senderClient);
|
||||
GameMain.Server.SendConsoleMessage($"\"{args[0]}\" is not a valid numeric value.", senderClient, Color.Red);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -2242,7 +2251,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (!(GameMain.GameSession?.GameMode is CampaignMode campaign))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("No campaign active!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("No campaign active!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2250,7 +2259,7 @@ namespace Barotrauma
|
||||
if (args.Length < 1 || !int.TryParse(args[0], out destinationIndex)) return;
|
||||
if (destinationIndex < 0 || destinationIndex >= campaign.Map.CurrentLocation.Connections.Count)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Index out of bounds!", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Index out of bounds!", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
Location location = campaign.Map.CurrentLocation.Connections[destinationIndex].OtherLocation(campaign.Map.CurrentLocation);
|
||||
@@ -2267,14 +2276,41 @@ namespace Barotrauma
|
||||
NewMessage(tag, Color.Yellow);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
commands.Add(new Command("sendchatmessage", "Sends a chat message with specified type and color.", (string[] args) =>
|
||||
{
|
||||
if (args.Length < 2) { return; }
|
||||
|
||||
ChatMessageType chatMessageType = ChatMessageType.Default;
|
||||
Color? chatMessageColor = null;
|
||||
|
||||
if (args.Length >= 3 && int.TryParse(args[2], out int result))
|
||||
{
|
||||
chatMessageType = (ChatMessageType)result;
|
||||
}
|
||||
|
||||
if (args.Length >= 7 &&
|
||||
int.TryParse(args[3], out int r) &&
|
||||
int.TryParse(args[4], out int g) &&
|
||||
int.TryParse(args[5], out int b) &&
|
||||
int.TryParse(args[6], out int a))
|
||||
{
|
||||
chatMessageColor = new Color(r, g, b, a);
|
||||
}
|
||||
|
||||
foreach (var client in GameMain.Server.ConnectedClients)
|
||||
{
|
||||
GameMain.Server.SendDirectChatMessage(ChatMessage.Create(args[0], args[1], chatMessageType, null, null, textColor: chatMessageColor), client);
|
||||
}
|
||||
}));
|
||||
|
||||
AssignOnClientRequestExecute(
|
||||
"setskill",
|
||||
(senderClient, cursorWorldPos, args) =>
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage($"Missing arguments. Expected at least 2 but got {args.Length} (skill, level, name)", senderClient);
|
||||
GameMain.Server.SendConsoleMessage($"Missing arguments. Expected at least 2 but got {args.Length} (skill, level, name)", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2284,7 +2320,7 @@ namespace Barotrauma
|
||||
|
||||
if (character?.Info?.Job == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Character is not valid.", senderClient);
|
||||
GameMain.Server.SendConsoleMessage("Character is not valid.", senderClient, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2311,7 +2347,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage($"{levelString} is not a valid level. Expected number or \"max\".", senderClient);
|
||||
GameMain.Server.SendConsoleMessage($"{levelString} is not a valid level. Expected number or \"max\".", senderClient, Color.Red);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -2405,7 +2441,7 @@ namespace Barotrauma
|
||||
if (string.IsNullOrWhiteSpace(command)) return;
|
||||
if (!client.HasPermission(ClientPermissions.ConsoleCommands) && client.Connection != GameMain.Server.OwnerConnection)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("You are not permitted to use console commands!", client);
|
||||
GameMain.Server.SendConsoleMessage("You are not permitted to use console commands!", client, Color.Red);
|
||||
GameServer.Log(GameServer.ClientLogName(client) + " attempted to execute the console command \"" + command + "\" without a permission to use console commands.", ServerLog.MessageType.ConsoleUsage);
|
||||
return;
|
||||
}
|
||||
@@ -2414,19 +2450,19 @@ namespace Barotrauma
|
||||
Command matchingCommand = commands.Find(c => c.names.Contains(splitCommand[0].ToLowerInvariant()));
|
||||
if (matchingCommand != null && !client.PermittedConsoleCommands.Contains(matchingCommand) && client.Connection != GameMain.Server.OwnerConnection)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("You are not permitted to use the command\"" + matchingCommand.names[0] + "\"!", client);
|
||||
GameMain.Server.SendConsoleMessage("You are not permitted to use the command\"" + matchingCommand.names[0] + "\"!", client, Color.Red);
|
||||
GameServer.Log(GameServer.ClientLogName(client) + " attempted to execute the console command \"" + command + "\" without a permission to use the command.", ServerLog.MessageType.ConsoleUsage);
|
||||
return;
|
||||
}
|
||||
else if (matchingCommand == null)
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Command \"" + splitCommand[0] + "\" not found.", client);
|
||||
GameMain.Server.SendConsoleMessage("Command \"" + splitCommand[0] + "\" not found.", client, Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MathUtils.IsValid(cursorWorldPos))
|
||||
{
|
||||
GameMain.Server.SendConsoleMessage("Could not execute command \"" + command + "\" - invalid cursor position.", client);
|
||||
GameMain.Server.SendConsoleMessage("Could not execute command \"" + command + "\" - invalid cursor position.", client, Color.Red);
|
||||
NewMessage(GameServer.ClientLogName(client) + " attempted to execute the console command \"" + command + "\" with invalid cursor position.", Color.White);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user