Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix modloader i hope #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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