Skip to content

Commit

Permalink
fix modloader i hope
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmherokiller committed Nov 11, 2018
1 parent 7ee4c50 commit 48fc8b1
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions DOOMModLoader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void Main(string[] args)
var modDirs = Directory.GetDirectories(modDir);

var zips = new List<string>();
foreach(var file in modFiles)
foreach (var file in modFiles)
{
hasMods = true;

Expand Down Expand Up @@ -143,7 +143,7 @@ static void Main(string[] args)
File.WriteAllText(fileIdsPath, fileIds);

// mod patch creation
var patchFilter = $"{resourcePrefix}gameresources_*.pindex";
var patchFilter = $"{resourcePrefix}gameresources*.pindex";
var patches = Directory.GetFiles("base", patchFilter);
var latestPatch = String.Empty;
var latestPfi = 0;
Expand All @@ -153,11 +153,21 @@ static void Main(string[] args)
continue; // patch is one made by us

var namesp = Path.GetFileNameWithoutExtension(patch).Split('_');
var pnum = int.Parse(namesp[namesp.Length - 1]);
if (pnum > latestPfi)
var NumberString = namesp[namesp.Length - 1];
var pnum = 0;
var NumberFound = int.TryParse(NumberString, out pnum);
if (!NumberFound)
{
latestPatch = patch;
latestPfi = pnum;
latestPfi = 1;
}
else
{
if (pnum > latestPfi)
{
latestPatch = patch;
latestPfi = pnum;
}
}
}
if (string.IsNullOrEmpty(latestPatch))
Expand All @@ -177,10 +187,14 @@ static void Main(string[] args)

// delete existing custom patch
if (File.Exists(destPath))
{
File.Delete(destPath);

}

if (File.Exists(resPath))
{
File.Delete(resPath);
}

// if we have mods, create a custom patch out of them
if (hasMods)
Expand Down

0 comments on commit 48fc8b1

Please sign in to comment.