From 7c74ff70a3e86ee8d72eb1522d7d80480db16392 Mon Sep 17 00:00:00 2001 From: x1nixmzeng Date: Thu, 4 Jan 2018 22:30:37 +0000 Subject: [PATCH] Workaround for duplicate addresses Fixes hex parsing, but hacks around #832 --- .../DebuggerSymbols/HLECache/HLECacheFile.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/CxbxDebugger/DebuggerSymbols/HLECache/HLECacheFile.cs b/src/CxbxDebugger/DebuggerSymbols/HLECache/HLECacheFile.cs index 189146c1a..e6d6e357a 100644 --- a/src/CxbxDebugger/DebuggerSymbols/HLECache/HLECacheFile.cs +++ b/src/CxbxDebugger/DebuggerSymbols/HLECache/HLECacheFile.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Globalization; namespace CxbxDebugger { @@ -23,14 +24,21 @@ namespace CxbxDebugger AddressMap = new Dictionary(Pairs.Length); // Swap SYMBOL, ADDR to be ADDR -> SYMBOL + uint Addr; foreach (KeyValuePair 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; } } -} +} \ No newline at end of file