Skip to content

Commit

Permalink
added proper load order correction for game master files for skyrim a…
Browse files Browse the repository at this point in the history
…nd fallout 4
  • Loading branch information
matortheeternal committed Sep 27, 2016
1 parent 1f991eb commit 87fe2e1
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions frontend/mpLoader.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface
procedure RemoveCommentsAndEmpty(var sl: TStringList);
procedure RemoveMissingFiles(var sl: TStringList);
procedure RemoveMergedPlugins(var sl: TStringList);
procedure FixLoadOrder(var sl: TStringList; filename: String; index: Integer);
procedure AddMissingFiles(var sl: TStringList);
procedure GetPluginDates(var sl: TStringList);
function PluginListCompare(List: TStringList; Index1, Index2: Integer): Integer;
Expand Down Expand Up @@ -167,9 +168,9 @@ function InitBase: boolean;
RemoveMissingFiles(slLoadOrder);
AddMissingFiles(slLoadOrder);

// if GameMode is not Skyrim and user isn't using MO,
// sort by date modified else add Update.esm and
// Skyrim.esm to load order if they're missing
// if GameMode is not Skyrim or Fallout 4 and user isn't
// using MO, sort by date modified else add base masters
// to load order if missing
if (wbGameMode <> gmTES5) and (wbGameMode <> gmFO4) then begin
if not settings.usingMO then begin
GetPluginDates(slPlugins);
Expand All @@ -179,14 +180,11 @@ function InitBase: boolean;
end;
end
else if (wbGameMode = gmTES5) then begin
if slLoadOrder.IndexOf('Update.esm') = -1 then
slLoadOrder.Insert(0, 'Update.esm');
if slLoadOrder.IndexOf('Skyrim.esm') = -1 then
slLoadOrder.Insert(0, 'Skyrim.esm');
FixLoadOrder(slLoadOrder, 'Skyrim.esm', 0);
FixLoadOrder(slLoadOrder, 'Update.esm', 1);
end
else if (wbGameMode = gmFO4) then begin
if slLoadOrder.IndexOf('Fallout4.esm') = -1 then
slLoadOrder.Insert(0, 'Fallout4.esm');
FixLoadOrder(slLoadOrder, 'Fallout4.esm', 0);
end;

// DISPLAY PLUGIN SELECTION FORM
Expand Down Expand Up @@ -425,6 +423,18 @@ procedure RemoveMergedPlugins(var sl: TStringList);
sl.Delete(i);
end;

{ Forces a plugin to load at a specific position }
procedure FixLoadOrder(var sl: TStringList; filename: String; index: Integer);
var
oldIndex: Integer;
begin
oldIndex := sl.IndexOf(filename);
if oldIndex <> index then begin
sl.Delete(oldIndex);
sl.Insert(index, filename);
end;
end;

{ Add missing *.esp and *.esm files to list }
procedure AddMissingFiles(var sl: TStringList);
var
Expand Down

0 comments on commit 87fe2e1

Please sign in to comment.