Fix issues with game naming and renaming

This commit is contained in:
Matt Nadareski
2016-05-09 09:35:07 -07:00
parent e9ce152653
commit 5ad9a83b63
2 changed files with 5 additions and 4 deletions

View File

@@ -455,7 +455,7 @@ Make a selection:
rom.Game = Style.NormalizeChars(rom.Game); rom.Game = Style.NormalizeChars(rom.Game);
rom.Game = Style.RussianToLatin(rom.Game); rom.Game = Style.RussianToLatin(rom.Game);
rom.Game = Style.SearchPattern(rom.Game); rom.Game = Style.SearchPattern(rom.Game);
rom.Game = rom.Game.Replace("\n", "").Replace("\r", ""); rom.Game = rom.Game.TrimEnd().TrimStart();
if (!norename) if (!norename)
{ {
@@ -467,7 +467,7 @@ Make a selection:
} }
// Then write out the file // Then write out the file
Output.WriteToDatFromDict(name, description, "", date, "SabreTools", "SabreTools", false, old, true, _outroot, roms, _logger); Output.WriteToDatFromDict(name, description, "", date, "SabreTools", "SabreTools", false, old, true, _outroot, roms, _logger, norename);
} }
/// <summary> /// <summary>

View File

@@ -153,9 +153,10 @@ namespace SabreTools.Helper
/// <param name="outDir">Set the output directory</param> /// <param name="outDir">Set the output directory</param>
/// <param name="dict">Dictionary containing all the roms to be written</param> /// <param name="dict">Dictionary containing all the roms to be written</param>
/// <param name="logger">Logger object for console and/or file output</param> /// <param name="logger">Logger object for console and/or file output</param>
/// <param name="norename">True if games should only be compared on game and file name (default), false if system and source are counted</param>
/// <returns>True if the DAT was written correctly, false otherwise</returns> /// <returns>True if the DAT was written correctly, false otherwise</returns>
public static bool WriteToDatFromDict(string name, string description, string version, string date, string category, string author, public static bool WriteToDatFromDict(string name, string description, string version, string date, string category, string author,
bool forceunpack, bool old, bool merge, string outDir, Dictionary<string, List<RomData>> dict, Logger logger) bool forceunpack, bool old, bool merge, string outDir, Dictionary<string, List<RomData>> dict, Logger logger, bool norename = true)
{ {
// Get all values in the dictionary and write out // Get all values in the dictionary and write out
SortedDictionary<string, List<RomData>> sortable = new SortedDictionary<string, List<RomData>>(); SortedDictionary<string, List<RomData>> sortable = new SortedDictionary<string, List<RomData>>();
@@ -171,7 +172,7 @@ namespace SabreTools.Helper
foreach (RomData rom in newroms) foreach (RomData rom in newroms)
{ {
count++; count++;
string key = rom.SystemID + "-" + rom.SourceID + "-" + rom.Game + "-" + rom.Name; string key = (norename ? "" : rom.SystemID + "-" + rom.SourceID + "-" ) + rom.Game + "-" + rom.Name;
if (sortable.ContainsKey(key)) if (sortable.ContainsKey(key))
{ {
sortable[key].Add(rom); sortable[key].Add(rom);