Load console commands after executing and possible fix for the not console command permitted

This commit is contained in:
Evil Factory
2026-04-11 21:49:12 -03:00
parent 1703b5a103
commit f3535e242c
2 changed files with 14 additions and 6 deletions
@@ -29,7 +29,12 @@ namespace Barotrauma
private static LuaCsSetup _luaCsSetup; private static LuaCsSetup _luaCsSetup;
public static LuaCsSetup Instance => _luaCsSetup ??= new LuaCsSetup(); public static LuaCsSetup Instance => _luaCsSetup ??= new LuaCsSetup();
/// <summary>
/// The index of the last Vanilla command.
/// </summary>
public static int DebugConsoleCommandVanillaIndex { get; private set; }
private LuaCsSetup() private LuaCsSetup()
{ {
if (_luaCsSetup != null) if (_luaCsSetup != null)
@@ -37,6 +42,8 @@ namespace Barotrauma
throw new Exception("Tried to create another LuaCsSetup instance"); throw new Exception("Tried to create another LuaCsSetup instance");
} }
DebugConsoleCommandVanillaIndex = DebugConsole.Commands.Count;
// == startup // == startup
_servicesProvider = SetupServicesProvider(); _servicesProvider = SetupServicesProvider();
_runStateMachine = SetupStateMachine(); _runStateMachine = SetupStateMachine();
@@ -395,6 +402,11 @@ namespace Barotrauma
EventService.PublishEvent<IEventServerConnected>(static p => p.OnServerConnected()); EventService.PublishEvent<IEventServerConnected>(static p => p.OnServerConnected());
} }
#endif #endif
#if SERVER
GameMain.Server.ServerSettings.LoadClientPermissions();
#endif
CurrentRunState = RunState.Running; CurrentRunState = RunState.Running;
} }
@@ -28,16 +28,12 @@ internal class HarmonyEventPatchesService : ISystem
private static ILoggerService _loggerService; private static ILoggerService _loggerService;
private readonly Harmony Harmony; private readonly Harmony Harmony;
private static int debugConsoleCommandVanillaIndex;
public HarmonyEventPatchesService(IEventService eventService, ILoggerService loggerService) public HarmonyEventPatchesService(IEventService eventService, ILoggerService loggerService)
{ {
_eventService = eventService; _eventService = eventService;
_loggerService = loggerService; _loggerService = loggerService;
Harmony = new Harmony("LuaCsForBarotrauma.Events"); Harmony = new Harmony("LuaCsForBarotrauma.Events");
Patch(); Patch();
debugConsoleCommandVanillaIndex = DebugConsole.Commands.Count;
} }
private void Patch() private void Patch()
@@ -169,7 +165,7 @@ internal class HarmonyEventPatchesService : ISystem
{ {
DebugConsole.Command c = DebugConsole.FindCommand(command.Value); DebugConsole.Command c = DebugConsole.FindCommand(command.Value);
if (DebugConsole.Commands.IndexOf(c) >= debugConsoleCommandVanillaIndex) if (DebugConsole.Commands.IndexOf(c) >= LuaCsSetup.DebugConsoleCommandVanillaIndex)
{ {
__result = true; __result = true;
return false; return false;