From 2b7649bd2b5ede06b32cc3458f380ad2ce7d70ef Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 4 Jun 2019 16:44:10 +0300 Subject: [PATCH] (44694344e) Don't allow deleting vanilla subs in the sub editor --- .../Source/Screens/SubEditorScreen.cs | 23 +++++++++- .../BarotraumaShared/Source/DebugConsole.cs | 44 ------------------- 2 files changed, 22 insertions(+), 45 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index ec29f34d8..a45f872e6 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -847,6 +847,20 @@ namespace Barotrauma GameMain.World.ProcessChanges(); } + private bool IsVanillaSub(Submarine sub) + { + if (sub == null) { return false; } + + var vanilla = GameMain.VanillaContent; + if (vanilla != null) + { + var vanillaSubs = vanilla.GetFilesOfType(ContentType.Submarine); + string pathToCompare = sub.FilePath.Replace(@"\", @"/").ToLowerInvariant(); + return (vanillaSubs.Any(s => s.Replace(@"\", @"/").ToLowerInvariant() == pathToCompare)); + } + return false; + } + private bool SaveSub(GUIButton button, object obj) { if (string.IsNullOrWhiteSpace(nameBox.Text)) @@ -1328,7 +1342,14 @@ namespace Barotrauma ScrollBarVisible = true, OnSelected = (GUIComponent selected, object userData) => { - if (deleteButtonHolder.FindChild("delete") is GUIButton deleteBtn) deleteBtn.Enabled = true; + if (deleteButtonHolder.FindChild("delete") is GUIButton deleteBtn) + { +#if DEBUG + deleteBtn.Enabled = true; +#else + deleteBtn.Enabled = !IsVanillaSub(userData as Submarine); +#endif + } return true; } }; diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index f67922ff8..0235632b7 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -307,50 +307,6 @@ namespace Barotrauma //commands.Add(new Command("togglekarma", "togglekarma: Toggles the karma system.", null)); - commands.Add(new Command("enablecrewai", "enablecrewai: Enable the AI of the NPCs in the crew.", (string[] args) => - { - HumanAIController.DisableCrewAI = false; - NewMessage("Crew AI enabled", Color.Green); - }, isCheat: true)); - - commands.Add(new Command("disableenemyai", "disableenemyai: Disable the AI of the Enemy characters (monsters).", (string[] args) => - { - EnemyAIController.DisableEnemyAI = true; - NewMessage("Enemy AI disabled", Color.Red); - }, isCheat: true)); - - commands.Add(new Command("enableenemyai", "enableenemyai: Enable the AI of the Enemy characters (monsters).", (string[] args) => - { - EnemyAIController.DisableEnemyAI = false; - NewMessage("Enemy AI enabled", Color.Green); - }, isCheat: true)); - - commands.Add(new Command("botcount", "botcount [x]: Set the number of bots in the crew in multiplayer.", null)); - - commands.Add(new Command("botspawnmode", "botspawnmode [fill/normal]: Set how bots are spawned in the multiplayer.", null)); - - commands.Add(new Command("autorestart", "autorestart [true/false]: Enable or disable round auto-restart.", null)); - - commands.Add(new Command("autorestartinterval", "autorestartinterval [seconds]: Set how long the server waits between rounds before automatically starting a new one. If set to 0, autorestart is disabled.", null)); - - commands.Add(new Command("autorestarttimer", "autorestarttimer [seconds]: Set the current autorestart countdown to the specified value.", null)); - - commands.Add(new Command("startwhenclientsready", "startwhenclientsready [true/false]: Enable or disable automatically starting the round when clients are ready to start.", null)); - - commands.Add(new Command("giveperm", "giveperm [id]: Grants administrative permissions to the player with the specified client ID.", null)); - - commands.Add(new Command("revokeperm", "revokeperm [id]: Revokes administrative permissions to the player with the specified client ID.", null)); - - commands.Add(new Command("giverank", "giverank [id]: Assigns a specific rank (= a set of administrative permissions) to the player with the specified client ID.", null)); - - commands.Add(new Command("givecommandperm", "givecommandperm [id]: Gives the player with the specified client ID the permission to use the specified console commands.", null)); - - commands.Add(new Command("revokecommandperm", "revokecommandperm [id]: Revokes permission to use the specified console commands from the player with the specified client ID.", null)); - - commands.Add(new Command("showperm", "showperm [id]: Shows the current administrative permissions of the client with the specified client ID.", null)); - - //commands.Add(new Command("togglekarma", "togglekarma: Toggles the karma system.", null)); - commands.Add(new Command("kick", "kick [name]: Kick a player out of the server.", (string[] args) => { if (GameMain.NetworkMember == null || args.Length == 0) return;