From 6ade1e410add3f50d0d9e55f4c5a32d0482cdb73 Mon Sep 17 00:00:00 2001 From: Rans4ckeR Date: Fri, 23 Sep 2022 16:43:05 +0200 Subject: [PATCH] Fix Map BaseFilePath parsing (#376) --- DXMainClient/Domain/Multiplayer/MapLoader.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/DXMainClient/Domain/Multiplayer/MapLoader.cs b/DXMainClient/Domain/Multiplayer/MapLoader.cs index 67020840f..429c7a945 100644 --- a/DXMainClient/Domain/Multiplayer/MapLoader.cs +++ b/DXMainClient/Domain/Multiplayer/MapLoader.cs @@ -91,7 +91,8 @@ private void LoadMultiMaps(IniFile mpMapsIni) foreach (string key in keys) { - string mapFilePath = SafePath.CombineFilePath(mpMapsIni.GetStringValue(MultiMapsSection, key, string.Empty)); + string mapFilePathValue = mpMapsIni.GetStringValue(MultiMapsSection, key, string.Empty); + string mapFilePath = SafePath.CombineFilePath(mapFilePathValue); FileInfo mapFile = SafePath.GetFile(ProgramConstants.GamePath, FormattableString.Invariant($"{mapFilePath}{MAP_FILE_EXTENSION}")); if (!mapFile.Exists) @@ -100,7 +101,7 @@ private void LoadMultiMaps(IniFile mpMapsIni) continue; } - Map map = new Map(mapFilePath); + Map map = new Map(mapFilePathValue); if (!map.SetInfoFromMpMapsINI(mpMapsIni)) continue; @@ -155,7 +156,7 @@ private void LoadCustomMaps() return; } - IEnumerable mapFiles = customMapsDirectory.EnumerateFiles($"*{MapLoader.MAP_FILE_EXTENSION}"); + IEnumerable mapFiles = customMapsDirectory.EnumerateFiles($"*{MAP_FILE_EXTENSION}"); ConcurrentDictionary customMapCache = LoadCustomMapCache(); var localMapSHAs = new List(); @@ -169,7 +170,9 @@ private void LoadCustomMaps() string baseFilePath = mapFile.FullName.Substring(ProgramConstants.GamePath.Length); baseFilePath = baseFilePath.Substring(0, baseFilePath.Length - 4); - Map map = new Map(baseFilePath, mapFile.FullName); + Map map = new Map(baseFilePath + .Replace(Path.DirectorySeparatorChar, '/') + .Replace(Path.AltDirectorySeparatorChar, '/'), mapFile.FullName); map.CalculateSHA(); localMapSHAs.Add(map.SHA1); if (!customMapCache.ContainsKey(map.SHA1) && map.SetInfoFromCustomMap())