Workaround for duplicate addresses

Fixes hex parsing, but hacks around #832
This commit is contained in:
x1nixmzeng 2018-01-04 22:30:37 +00:00
parent 7f7714059b
commit 7c74ff70a3
1 changed files with 11 additions and 3 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
namespace CxbxDebugger
{
@ -23,14 +24,21 @@ namespace CxbxDebugger
AddressMap = new Dictionary<uint, string>(Pairs.Length);
// Swap SYMBOL, ADDR to be ADDR -> SYMBOL
uint Addr;
foreach (KeyValuePair<string, string> Symbol in Pairs)
{
uint Address = Convert.ToUInt32(Symbol.Value);
AddressMap.Add(Address, Symbol.Key);
if (!uint.TryParse(Symbol.Value, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out Addr))
continue;
// See https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/issues/832
if (!AddressMap.ContainsKey(Addr))
{
AddressMap.Add(Addr, Symbol.Key);
}
}
return true;
}
}
}
}