[DatTools, RomTools] Fix hash case matching causing merge issues

This commit is contained in:
Matt Nadareski
2016-07-12 11:39:47 -07:00
parent 306572dc9e
commit cbd30727f4
2 changed files with 10 additions and 9 deletions

View File

@@ -1395,27 +1395,27 @@ namespace SabreTools.Helper
} }
// Process each all of the roms // Process each all of the roms
foreach (List<Rom> roms in dict.Values) foreach (string key in dict.Keys)
{ {
List<Rom> newroms = roms; List<Rom> roms = dict[key];
if (mergeroms) if (mergeroms)
{ {
newroms = RomTools.Merge(newroms, logger); roms = RomTools.Merge(roms, logger);
} }
foreach (Rom rom in newroms) foreach (Rom rom in roms)
{ {
count++; count++;
string key = (norename ? "" : rom.Metadata.SystemID.ToString().PadLeft(10, '0') + "-" + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + rom.Game.ToLowerInvariant(); string newkey = (norename ? "" : rom.Metadata.SystemID.ToString().PadLeft(10, '0') + "-" + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + rom.Game.ToLowerInvariant();
if (sortable.ContainsKey(key)) if (sortable.ContainsKey(newkey))
{ {
sortable[key].Add(rom); sortable[newkey].Add(rom);
} }
else else
{ {
List<Rom> temp = new List<Rom>(); List<Rom> temp = new List<Rom>();
temp.Add(rom); temp.Add(rom);
sortable.Add(key, temp); sortable.Add(newkey, temp);
} }
} }
} }

View File

@@ -356,9 +356,10 @@ namespace SabreTools.Helper
hash = (hash.StartsWith("0x") ? hash.Remove(0, 2) : hash); hash = (hash.StartsWith("0x") ? hash.Remove(0, 2) : hash);
hash = (hash == "-" ? "" : hash); hash = (hash == "-" ? "" : hash);
hash = (String.IsNullOrEmpty(hash) ? "" : hash.PadLeft(padding, '0')); hash = (String.IsNullOrEmpty(hash) ? "" : hash.PadLeft(padding, '0'));
hash = hash.ToLowerInvariant();
// Then make sure that it has the correct characters // Then make sure that it has the correct characters
if (!Regex.IsMatch(hash.ToLowerInvariant(), "[0-9a-f]{" + padding + "}")) if (!Regex.IsMatch(hash, "[0-9a-f]{" + padding + "}"))
{ {
hash = ""; hash = "";
} }