fix Game.RoundStarted and improve error handling

This commit is contained in:
Evil Factory
2022-05-07 15:36:47 -03:00
parent 0d560a688c
commit e7510cad76
3 changed files with 6 additions and 7 deletions
@@ -119,9 +119,9 @@ namespace Barotrauma
get get
{ {
#if SERVER #if SERVER
return GameMain.Server.GameStarted; return GameMain.Server?.GameStarted == true;
#else #else
return GameMain.Client.GameStarted; return GameMain.Client?.GameStarted == true;
#endif #endif
} }
} }
@@ -216,7 +216,7 @@ namespace Barotrauma
if (methodInfo == null) if (methodInfo == null)
{ {
string parameterNamesStr = parameterNames == null ? "" : string.Join(", ", parameterNames == null); string parameterNamesStr = parameterNames == null ? "" : string.Join(", ", parameterNames);
GameMain.LuaCs.HandleException(new Exception($"Method '{methodName}' with parameters '{parameterNamesStr}' not found in class '{className}'")); GameMain.LuaCs.HandleException(new Exception($"Method '{methodName}' with parameters '{parameterNamesStr}' not found in class '{className}'"));
} }
@@ -89,7 +89,7 @@ namespace Barotrauma
} }
else else
{ {
GameMain.LuaCs.HandleException(new Exception("File access to \"" + path + "\" not allowed.")); throw new Exception("File access to \"" + path + "\" not allowed.");
} }
} }
else else
@@ -100,12 +100,11 @@ namespace Barotrauma
} }
else else
{ {
GameMain.LuaCs.HandleException(new Exception("File access to \"" + path + "\" not allowed.")); throw new Exception("File access to \"" + path + "\" not allowed.");
} }
} }
return false;
} }
public static bool IsPathAllowedLuaException(string path, bool write = true) => public static bool IsPathAllowedLuaException(string path, bool write = true) =>
IsPathAllowedException(path, write, LuaCsSetup.ExceptionType.Lua); IsPathAllowedException(path, write, LuaCsSetup.ExceptionType.Lua);
public static bool IsPathAllowedCsException(string path, bool write = true) => public static bool IsPathAllowedCsException(string path, bool write = true) =>