Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
* Fixed crash when module id was not present
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Dec 24, 2022
1 parent 604434c commit 4a50537
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<!--Development Variables-->
<PropertyGroup>
<Version>1.14.6</Version>
<Version>1.14.7</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<BUTRSharedVersion>3.0.0.126</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.163</BUTRModuleManagerVersion>
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 1.14.7
Game Versions: v1.0.0,v1.0.1,v1.0.2
* Fixed crash when module id was not present
---------------------------------------------------------------------------------------------------
Version: 1.14.6
Game Versions: v1.0.0,v1.0.1,v1.0.2
* Added export of the Load Order to a Novus Preset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,12 @@ public void Initialize(bool isMultiplayer)
}

// Tries to order the modules list with the relations described in the ordered list
public IEnumerable<string> OrderBy(IReadOnlyList<string> ordered)
public IEnumerable<string> OrderBy(IReadOnlyList<string> orderedIds)
{
var loadOrderValidationIssues = IsLoadOrderCorrect(ordered.Select(x => Modules2Lookup[x].ModuleInfoExtended).ToList()).ToList();
// Ignore missing modules
var currentOrderedIds = orderedIds.Intersect(Modules2.Select(x => x.ModuleInfoExtended.Id).ToHashSet()).ToList();

var loadOrderValidationIssues = IsLoadOrderCorrect(currentOrderedIds.Select(x => Modules2Lookup[x].ModuleInfoExtended).ToList()).ToList();
if (loadOrderValidationIssues.Count != 0)
return loadOrderValidationIssues.Select(x => x.Reason);

Expand All @@ -208,15 +211,15 @@ public IEnumerable<string> OrderBy(IReadOnlyList<string> ordered)
// ChangeModulePosition should move any nested dependencies higher?
var hasInvalid = true;
var retryCount = 0;
var retryCountMax = ordered.Count + 1;
var retryCountMax = currentOrderedIds.Count + 1;
while (hasInvalid && retryCount < retryCountMax)
{
hasInvalid = false;
retryCount++;
for (var i = 0; i < ordered.Count - 1; i++)
for (var i = 0; i < currentOrderedIds.Count - 1; i++)
{
var xId = ordered[i];
var yId = ordered[i + 1];
var xId = currentOrderedIds[i];
var yId = currentOrderedIds[i + 1];

var xIdx = Modules2.IndexOf(z => z.ModuleInfoExtended.Id == xId);
var yIdx = Modules2.IndexOf(z => z.ModuleInfoExtended.Id == yId);
Expand Down

0 comments on commit 4a50537

Please sign in to comment.