Skip to content

Commit

Permalink
Fix stock SaveUpgradePipeline bug where it blows up if a script doesn…
Browse files Browse the repository at this point in the history
…'t support both sfs and craft contexts. Bump version.
  • Loading branch information
NathanKell authored and gotmachine committed Dec 7, 2022
1 parent f695087 commit ac8dbda
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 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": 22, "PATCH": 1, "BUILD": 0},
"VERSION": {"MAJOR": 1, "MINOR": 22, "PATCH": 2, "BUILD": 0},
"KSP_VERSION": {"MAJOR": 1, "MINOR": 12, "PATCH": 3},
"KSP_VERSION_MIN": {"MAJOR": 1, "MINOR": 8, "PATCH": 0},
"KSP_VERSION_MAX": {"MAJOR": 1, "MINOR": 12, "PATCH": 3}
Expand Down
19 changes: 13 additions & 6 deletions KSPCommunityFixes/Modding/ModUpgradePipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,11 @@ private static bool SaveUpgradePipeline_RunIteration_Prefix(SaveUpgradePipeline.
ConfigNode curNode = node ?? srcNode;
for(int i = scripts.Count; i-- > 0;)
{
// Change: set assembly so VersionTest will use the right version
// Change: skip if doesn't apply in this context.
var uSc = scripts[i];
if (!uSc.AppliesInContext(ctx))
continue;
// Change: set assembly so VersionTest will use the right version
SetAssembly(uSc);
var testResult = __instance.RunTest(uSc, curNode, ctx);
_currentAsm = null;
Expand Down Expand Up @@ -317,17 +320,21 @@ private static bool SaveUpgradePipeline_RunIteration_Prefix(SaveUpgradePipeline.
}
for(int i = scripts.Count; i-- > 0;)
{
if (row[scripts[i]].testResult == TestResult.Upgradeable)
// Change: skip if doesn't apply in this context.
var uSc = scripts[i];
if (!uSc.AppliesInContext(ctx))
continue;

if (row[uSc].testResult == TestResult.Upgradeable)
{
if (lastRow != null && lastRow[scripts[i]].upgraded)
if (lastRow != null && lastRow[uSc].upgraded)
{
row[scripts[i]].testResult = TestResult.Pass;
row[scripts[i]].upgraded = true;
row[uSc].testResult = TestResult.Pass;
row[uSc].upgraded = true;
}
else
{
// Change: Set assembly just in case (not used yet)
var uSc = scripts[i];
SetAssembly(uSc);
node = __instance.RunUpgrade(uSc, node, ctx);
_currentAsm = null;
Expand Down
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.22.1.0")]
[assembly: AssemblyFileVersion("1.22.2.0")]

[assembly: KSPAssembly("KSPCommunityFixes", 1, 22, 1)]
[assembly: KSPAssembly("KSPCommunityFixes", 1, 22, 2)]
[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 @@ -153,6 +153,9 @@ If doing so in the `Debug` configuration and if your KSP install is modified to

### Changelog

##### 1.22.1
- Fix stock bug in SaveUpgradePipeline exposed by ModUpgradePipeline: the stock SaveUpgradePipeline blows up if an UpgradeScript does not apply to both sfs and craft contexts.

##### 1.22.1
- Add KSPAssembly attribute to MultipleModulePartAPI as well, and add the KSPAssemblyDependency to KSPCommunityFixes just in case.
- Set AssemblyVersion to 1.0 and only increment AssemblyFileVersion and KSPAssembly
Expand Down

0 comments on commit ac8dbda

Please sign in to comment.