Fix check ready to run not working properly
This commit is contained in:
@@ -17,12 +17,11 @@ namespace Barotrauma
|
|||||||
private bool _isClientPromptActive;
|
private bool _isClientPromptActive;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Returns whether execution should continue
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns whether execution should continue.</returns>
|
|
||||||
public bool CheckReadyToRun()
|
public bool CheckReadyToRun()
|
||||||
{
|
{
|
||||||
// fast exit if enabled or unavailable.
|
// Fast exit if enabled
|
||||||
if (this.IsCsEnabled)
|
if (this.IsCsEnabled)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -32,10 +31,24 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (ContentPackage cp in PackageManagementService.GetLoadedAssemblyPackages())
|
foreach (ContentPackage cp in PackageManagementService.GetLoadedAssemblyPackages())
|
||||||
{
|
{
|
||||||
|
if (cp.NameMatches(PackageId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (cp.UgcId.TryUnwrap(out ContentPackageId id))
|
if (cp.UgcId.TryUnwrap(out ContentPackageId id))
|
||||||
|
{
|
||||||
sb.AppendLine($"- {cp.Name} ({id})");
|
sb.AppendLine($"- {cp.Name} ({id})");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sb.AppendLine($"- {cp.Name} (Not On Workshop)");
|
sb.AppendLine($"- {cp.Name} (Not On Workshop)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(sb.ToString()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_isClientPromptActive)
|
if (!_isClientPromptActive)
|
||||||
@@ -44,16 +57,18 @@ namespace Barotrauma
|
|||||||
if (GameMain.Client == null || GameMain.Client.IsServerOwner)
|
if (GameMain.Client == null || GameMain.Client.IsServerOwner)
|
||||||
{
|
{
|
||||||
DisplayCsModsPromptServer(sb);
|
DisplayCsModsPromptServer(sb);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayCsModsPromptClient(sb);
|
DisplayCsModsPromptClient(sb);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return false;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void DisplayCsModsPromptServer(StringBuilder sb)
|
void DisplayCsModsPromptServer(StringBuilder sb)
|
||||||
{
|
{
|
||||||
@@ -104,6 +119,8 @@ namespace Barotrauma
|
|||||||
// avoid a TOCTOU scenario.
|
// avoid a TOCTOU scenario.
|
||||||
this.IsCsEnabled = false;
|
this.IsCsEnabled = false;
|
||||||
this._isClientPromptActive = false;
|
this._isClientPromptActive = false;
|
||||||
|
SetRunState(RunState.LoadedNoExec);
|
||||||
|
SetRunState(RunState.Running);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ namespace Barotrauma
|
|||||||
partial class LuaCsSetup : IDisposable, IEventScreenSelected, IEventEnabledPackageListChanged,
|
partial class LuaCsSetup : IDisposable, IEventScreenSelected, IEventEnabledPackageListChanged,
|
||||||
IEventReloadAllPackages
|
IEventReloadAllPackages
|
||||||
{
|
{
|
||||||
|
public const string PackageId = "LuaCsForBarotrauma";
|
||||||
|
|
||||||
private static LuaCsSetup _luaCsSetup;
|
private static LuaCsSetup _luaCsSetup;
|
||||||
public static LuaCsSetup Instance => _luaCsSetup ??= new LuaCsSetup();
|
public static LuaCsSetup Instance => _luaCsSetup ??= new LuaCsSetup();
|
||||||
|
|
||||||
@@ -145,9 +147,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
void LoadLuaCsConfig()
|
void LoadLuaCsConfig()
|
||||||
{
|
{
|
||||||
var luaCsPackage = ContentPackageManager.EnabledPackages.Regular.FirstOrDefault(cp => cp.NameMatches("LuaCsForBarotrauma"), null)
|
var luaCsPackage = ContentPackageManager.EnabledPackages.Regular.FirstOrDefault(cp => cp.NameMatches(PackageId), null)
|
||||||
?? ContentPackageManager.LocalPackages.FirstOrDefault(cp => cp.NameMatches("LuaCsForBarotrauma"))
|
?? ContentPackageManager.LocalPackages.FirstOrDefault(cp => cp.NameMatches(PackageId))
|
||||||
?? ContentPackageManager.WorkshopPackages.FirstOrDefault(cp => cp.NameMatches("LuaCsForBarotrauma"));
|
?? ContentPackageManager.WorkshopPackages.FirstOrDefault(cp => cp.NameMatches(PackageId));
|
||||||
|
|
||||||
_isCsEnabled =
|
_isCsEnabled =
|
||||||
ConfigService.TryGetConfig<ISettingBase<bool>>(luaCsPackage, "IsCsEnabled", out var val1)
|
ConfigService.TryGetConfig<ISettingBase<bool>>(luaCsPackage, "IsCsEnabled", out var val1)
|
||||||
|
|||||||
Reference in New Issue
Block a user