Skip to content

Commit

Permalink
Fix Map BaseFilePath parsing (CnCNet#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rans4ckeR authored Sep 23, 2022
1 parent 75ffd05 commit 6ade1e4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions DXMainClient/Domain/Multiplayer/MapLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -155,7 +156,7 @@ private void LoadCustomMaps()
return;
}

IEnumerable<FileInfo> mapFiles = customMapsDirectory.EnumerateFiles($"*{MapLoader.MAP_FILE_EXTENSION}");
IEnumerable<FileInfo> mapFiles = customMapsDirectory.EnumerateFiles($"*{MAP_FILE_EXTENSION}");
ConcurrentDictionary<string, Map> customMapCache = LoadCustomMapCache();
var localMapSHAs = new List<string>();

Expand All @@ -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())
Expand Down

0 comments on commit 6ade1e4

Please sign in to comment.