Fix client-side commands working when they shouldn't

This commit is contained in:
EvilFactory
2022-10-28 15:14:43 -03:00
parent d88a6b5ef0
commit 09979cb4c9
4 changed files with 30 additions and 9 deletions
@@ -1956,8 +1956,8 @@ namespace Barotrauma
#if DEBUG
AddWarning($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\". Executing the command anyway because this is a debug build.");
#else
//ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!");
//return;
ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!");
return;
#endif
}
}
@@ -388,6 +388,27 @@ namespace Barotrauma
}
private List<DebugConsole.Command> luaAddedCommand = new List<DebugConsole.Command>();
public IEnumerable<DebugConsole.Command> LuaAddedCommand { get { return luaAddedCommand; } }
public bool IsCustomCommandPermitted(string command)
{
DebugConsole.Command[] permitted = new DebugConsole.Command[]
{
DebugConsole.FindCommand("cl_reloadluacs"),
DebugConsole.FindCommand("cl_lua"),
DebugConsole.FindCommand("cl_cs"),
};
foreach (var consoleCommand in LuaAddedCommand.Concat(permitted.AsEnumerable()))
{
if (consoleCommand.names.Contains(command))
{
return true;
}
}
return false;
}
public void RemoveCommand(string name)
{