Potential fix for the wrong publicized folder being loaded

This commit is contained in:
EvilFactory
2023-11-02 19:40:36 -03:00
parent 759f66cf9f
commit 46a841b5c1
2 changed files with 16 additions and 2 deletions
@@ -53,6 +53,18 @@ namespace Barotrauma
public const bool IsClient = true; public const bool IsClient = true;
#endif #endif
public static bool IsRunningInsideWorkshop
{
get
{
#if SERVER
return Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) == Directory.GetCurrentDirectory();
#else
return false; // unnecessary but just keeps things clear that this is NOT for client stuff
#endif
}
}
private static int executionNumber = 0; private static int executionNumber = 0;
@@ -334,10 +334,12 @@ public sealed class CsPackageManager : IDisposable
void GetFiles(List<string> list, string searchQuery) void GetFiles(List<string> list, string searchQuery)
{ {
bool workshopFirst = _luaCsSetup.Config.PreferToUseWorkshopLuaSetup || LuaCsSetup.IsRunningInsideWorkshop;
var publicizedDir = Path.Combine(Environment.CurrentDirectory, "Publicized"); var publicizedDir = Path.Combine(Environment.CurrentDirectory, "Publicized");
// if using workshop lua setup is checked, try to use the publicized assemblies in the content package there instead. // if using workshop lua setup is checked, try to use the publicized assemblies in the content package there instead.
if (_luaCsSetup.Config.PreferToUseWorkshopLuaSetup) if (workshopFirst)
{ {
var pck = LuaCsSetup.GetPackage(LuaCsSetup.LuaForBarotraumaId); var pck = LuaCsSetup.GetPackage(LuaCsSetup.LuaForBarotraumaId);
if (pck is not null) if (pck is not null)
@@ -353,7 +355,7 @@ public sealed class CsPackageManager : IDisposable
// no directory found, use the other one // no directory found, use the other one
catch (DirectoryNotFoundException) catch (DirectoryNotFoundException)
{ {
if (_luaCsSetup.Config.PreferToUseWorkshopLuaSetup) if (workshopFirst)
{ {
ModUtils.Logging.PrintError($"Unable to find <LuaCsPackage>/Binary/Publicized/ . Using Game folder instead."); ModUtils.Logging.PrintError($"Unable to find <LuaCsPackage>/Binary/Publicized/ . Using Game folder instead.");
publicizedDir = Path.Combine(Environment.CurrentDirectory, "Publicized"); publicizedDir = Path.Combine(Environment.CurrentDirectory, "Publicized");