Skip to content

Commit

Permalink
Actually add fixes for 1.3. Also fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Byass committed Jul 20, 2021
1 parent bc1e496 commit 450ffac
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 26 deletions.
Binary file added 1.1-1.2/Assemblies/BetterLoading.dll
Binary file not shown.
Binary file removed 1.1-1.3/Assemblies/BetterLoading.dll
Binary file not shown.
Binary file added 1.3/Assemblies/BetterLoading.dll
Binary file not shown.
10 changes: 5 additions & 5 deletions LoadFolders.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<loadFolders>
<v1.1>
<li>1.1-1.3</li>
<li>1.1-1.2</li>
<li></li>
</v1.1>
<v1.2>
<li>1.1-1.3</li>
<li>1.1-1.2</li>
<li></li>
</v1.2>
<v1.2>
<li>1.1-1.3</li>
<v1.3>
<li>1.3</li>
<li></li>
</v1.2>
</v1.3>
</loadFolders>
13 changes: 5 additions & 8 deletions Source/BetterLoading.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Optimize>true</Optimize>
<OutDir>..\1.1-1.2\Assemblies\</OutDir>
<OutputPath>..\1.1-1.2\Assemblies\</OutputPath>
<OutDir>..\1.3\Assemblies\</OutDir>
<OutputPath>..\1.3\Assemblies\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutDir>..\1.1-1.2\Assemblies\</OutDir>
<OutputPath>..\1.1-1.2\Assemblies\</OutputPath>
<OutDir>..\1.3\Assemblies\</OutDir>
<OutputPath>..\1.3\Assemblies\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp, Culture=neutral, PublicKeyToken=null">
<HintPath Condition="Exists('../../../RimWorldLinux_Data/')">../../../RimWorldLinux_Data/Managed/Assembly-CSharp.dll</HintPath>
<HintPath Condition="Exists('..\..\..\RimWorldWin64_Data\')">..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp, Version=1.3.7871.17490, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath Condition="Exists('../../../RimWorldLinux_Data/')">../../../RimWorldLinux_Data/Managed/UnityEngine.dll</HintPath>
<HintPath Condition="Exists('..\..\..\RimWorldWin64_Data\')">..\..\..\RimWorldWin64_Data\Managed\UnityEngine.dll</HintPath>
Expand All @@ -47,6 +44,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Lib.Harmony" Version="2.0.1" />
<PackageReference Include="Lib.Harmony" Version="2.1.0" />
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions Source/BetterLoadingMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public BetterLoadingMain(ModContentPack content) : base(content)
)
.ToList();

Log.Error($"[BetterLoading] {dllsThatShouldBeLoaded.Count - dllsActuallyLoaded.Count} assemblies for {pack.Name} failed to load! The ones that didn't load are: {didntLoad.ToCommaList()}");
Log.Error($"[BetterLoading] {dllsThatShouldBeLoaded.Count - dllsActuallyLoaded.Count} assemblies for {pack.Name} failed to load! The ones that didn't load are: {string.Join(", ",didntLoad)}");
Log.Error($"[BetterLoading] Got {failures.Count} messages that identify those failures.");

DllPathsThatFailedToLoad[pack] = failures;
Expand Down Expand Up @@ -130,8 +130,7 @@ private void CreateTimingReport()
$"Spent {timeResolvingDatabases.TotalMilliseconds}ms resolving cross-references and running post-load, pre-finalize callbacks.\n" +
$"Spent {timeRunningCctors.TotalMilliseconds}ms running static constructors (initializing mods).\n" +
$"Spent {timeRunningPostFinalize.TotalMilliseconds}ms running post-finalize callbacks.\n" +
$"In total, spent {totalLoadTime.TotalMilliseconds}ms launching the game."
, true);
$"In total, spent {totalLoadTime.TotalMilliseconds}ms launching the game.");
}

public static void DisplayFailedLoadDialog()
Expand Down
16 changes: 12 additions & 4 deletions Source/LoadingScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ public void OnGUI()
if (currentProgress > maxProgress)
{
Log.Error(
$"[BetterLoading] Clamping! The stage of type {_currentStage.GetType().FullName} has returned currentProgress {currentProgress} > maxProgress {maxProgress}. Please report this!",
true);
$"[BetterLoading] Clamping! The stage of type {_currentStage.GetType().FullName} has returned currentProgress {currentProgress} > maxProgress {maxProgress}. Please report this!");
currentProgress = maxProgress;
}

Expand Down Expand Up @@ -332,7 +331,16 @@ public void OnGUI()
if (_currentTip == null || (DateTime.Now.Ticks - _timeLastTipShown) >= _ticksPerTip)
{
//No tip chosen yet, or time for next tip - pick another and reset timer.
_currentTip = _tips.Pop();

if (_tips.NullOrEmpty())
{
_currentTip = "BetterLoading Warning: No tips could be located in your game. This is probably a bug with another mod";
}
else
{
_currentTip = _tips.Pop();
}

_timeLastTipShown = DateTime.Now.Ticks;
}

Expand Down Expand Up @@ -361,7 +369,7 @@ public void OnGUI()
}
catch (Exception e)
{
Log.ErrorOnce($"Encountered exception while rendering loading screen: {e}", 0xBEEF99, true);
Log.ErrorOnce($"Encountered exception while rendering loading screen: {e}", 0xBEEF99);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading;
using HarmonyLib;
using RimWorld;
using Verse;

namespace BetterLoading.Stage.InitialLoad
Expand Down Expand Up @@ -92,9 +93,13 @@ public static bool PreExecToExecWhenFinished(List<Action> ___toExecuteWhenFinish

// Debug.Log($"BL Debug: types declared in PDL: {declaredInPDL.Select(a => a.Method).ToStringSafeEnumerable()}");

var indexOfStaticCtor = ___toExecuteWhenFinished.IndexOf(declaredInPDL.Find(task => task.Method.Name.Contains("b__4_2"))); //The anon class that calls static ctors.
var targetMethodName = VersionControl.CurrentMinor == 3 ? "b__4_3" : "b__4_2";

// Log.Message($"BL Debug: Tasks defined in PDL: {string.Join(", ", declaredInPDL.Select(task => task.Method.FullDescription()))}");

var indexOfStaticCtor = ___toExecuteWhenFinished.IndexOf(declaredInPDL.Find(task => task.Method.Name.Contains(targetMethodName))); //The anon class that calls static ctors.

// Debug.Log($"BL Debug: Identified target index as {indexOfStaticCtor} which maps to the action-method {___toExecuteWhenFinished[indexOfStaticCtor].Method.FullDescription()}");
// Log.Message($"BL Debug: Identified target index as {indexOfStaticCtor} which maps to the action-method {___toExecuteWhenFinished[indexOfStaticCtor].Method.FullDescription()}");

//Ones to execute now are the ones before the ctors
var toExecute = ___toExecuteWhenFinished.Take(indexOfStaticCtor).ToList();
Expand Down Expand Up @@ -144,7 +149,7 @@ public static bool PreExecToExecWhenFinished(List<Action> ___toExecuteWhenFinish
Thread.Sleep(0);

_done = true;
}, null, true, null);
}, null, false, null);

return false;
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Stage/InitialLoad/9StageRunPostFinalizeCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ public static bool PreExecToExecWhenFinished(List<Action> ___toExecuteWhenFinish
}

GlobalTimingData.TicksStartedPostFinalize = DateTime.UtcNow.Ticks;
Log.Message("Started post-finalize at " + GlobalTimingData.TicksStartedPostFinalize);

_hasBeenCalled = true;
ShouldInterceptNext = false;
_numTasksToRun = ___toExecuteWhenFinished.Count;

_finishedExecuting = false;

if (_numTasksToRun == 0)
if (___toExecuteWhenFinished.Count == 0)
{
_numTasksToRun = 1;
_finishedExecuting = true;
return false;
}

_numTasksToRun = ___toExecuteWhenFinished.Count;

var initialNumTasksToRun = _numTasksToRun;
Log.Message($"[BetterLoading] Processing {initialNumTasksToRun} post-finalize tasks.");

Expand Down

0 comments on commit 450ffac

Please sign in to comment.