Skip to content

Commit

Permalink
- Fixed [issue #134](#133) : fix for [issue #133](#133) was overly co…
Browse files Browse the repository at this point in the history
…nservative, causing loading to stop on exceptions that don't cause a fatal error in stock.
  • Loading branch information
gotmachine committed Mar 29, 2023
1 parent 409a960 commit d34b6b7
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion GameData/KSPCommunityFixes/KSPCommunityFixes.version
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"NAME": "KSPCommunityFixes",
"URL": "https://raw.githubusercontent.com/KSPModdingLibs/KSPCommunityFixes/master/GameData/KSPCommunityFixes/KSPCommunityFixes.version",
"DOWNLOAD": "https://github.com/KSPModdingLibs/KSPCommunityFixes/releases",
"VERSION": {"MAJOR": 1, "MINOR": 25, "PATCH": 4, "BUILD": 0},
"VERSION": {"MAJOR": 1, "MINOR": 25, "PATCH": 5, "BUILD": 0},
"KSP_VERSION": {"MAJOR": 1, "MINOR": 12, "PATCH": 5},
"KSP_VERSION_MIN": {"MAJOR": 1, "MINOR": 8, "PATCH": 0},
"KSP_VERSION_MAX": {"MAJOR": 1, "MINOR": 12, "PATCH": 5}
Expand Down
57 changes: 46 additions & 11 deletions KSPCommunityFixes/Performance/FastLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using UnityEngine.Experimental.Rendering;
using KSP.Localization;
using TMPro;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace KSPCommunityFixes.Performance
Expand Down Expand Up @@ -1661,8 +1660,18 @@ static IEnumerator FrameUnlockedCoroutine(IEnumerator coroutine)
catch (Exception e)
{
Debug.LogException(e);
moveNext = false;
exceptionInfo = new LoaderExceptionInfo(e, coroutine);

if (currentEnumerator == coroutine)
{
exceptionInfo = new LoaderExceptionInfo(e, coroutine);
moveNext = false;
}
else
{
enumerators.Clear();
enumerators.Push(coroutine);
continue;
}
}

while (moveNext)
Expand All @@ -1687,10 +1696,18 @@ static IEnumerator FrameUnlockedCoroutine(IEnumerator coroutine)
}
catch (Exception e)
{
object currentObject = currentEnumerator.Current;
Debug.LogException(e);
moveNext = false;
exceptionInfo = new LoaderExceptionInfo(e, coroutine);

if (currentEnumerator == coroutine)
{
exceptionInfo = new LoaderExceptionInfo(e, coroutine);
moveNext = false;
}
else
{
enumerators.Clear();
enumerators.Push(coroutine);
}
}
}
}
Expand Down Expand Up @@ -2209,11 +2226,29 @@ public void Show()
#endregion
}

public class GetInfoThrowModule : PartModule
{
public override string GetInfo()
#if DEBUG
public class GetInfoThrowModule : PartModule
{
throw new Exception("ExceptionFromGetInfo");
public override string GetInfo()
{
// this should be fatal an stop the loading process
throw new Exception("Exception from GetInfo");
}
}
}

public class AssumeDragCubePositionThrowModule : PartModule, IMultipleDragCube
{
public string[] GetDragCubeNames() => new[] { "A", "B" };

// this shouldn't be fatal and shouldn't stop the loading process
public void AssumeDragCubePosition(string name)
{
throw new Exception("Exception from AssumeDragCubePosition");
}

public bool UsesProceduralDragCubes() => false;

public bool IsMultipleCubesActive => true;
}
#endif
}
4 changes: 2 additions & 2 deletions KSPCommunityFixes/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.25.4.0")]
[assembly: AssemblyFileVersion("1.25.5.0")]

[assembly: KSPAssembly("KSPCommunityFixes", 1, 25, 4)]
[assembly: KSPAssembly("KSPCommunityFixes", 1, 25, 5)]
[assembly: KSPAssemblyDependency("MultipleModulePartAPI", 1, 0, 0)]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ If doing so in the `Debug` configuration and if your KSP install is modified to

### Changelog

##### 1.25.5
- Fixed [issue #134](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/133) : fix for [issue #133](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/133) was overly conservative, causing loading to stop on exceptions that don't cause a fatal error in stock.

##### 1.25.4
- Fixed [issue #133](https://github.com/KSPModdingLibs/KSPCommunityFixes/issues/133) : FastLoader allow the game to launch even when unrecoverable errors happen during loading.

Expand Down

0 comments on commit d34b6b7

Please sign in to comment.