Added map name support to Launch.Map command line parameter

Fixed code based on feedback

Replaced try/catch block with a null check and exception throw

Fixed code based on feedback

Fixed code based on feedback

Simplified Launch.Map parameter to use map name directly
This commit is contained in:
GeorgeD64
2021-08-23 23:13:48 +10:00
committed by Matthias Mailänder
parent a537346580
commit e00efbf53d

View File

@@ -953,12 +953,9 @@ namespace OpenRA
Order.Command($"state {Session.ClientState.Ready}")
};
var path = Platform.ResolvePath(launchMap);
var map = ModData.MapCache.SingleOrDefault(m => m.Uid == launchMap) ??
ModData.MapCache.SingleOrDefault(m => m.Package.Name == path);
var map = ModData.MapCache.SingleOrDefault(m => m.Uid == launchMap || Path.GetFileName(m.Package.Name) == launchMap);
if (map == null)
throw new InvalidOperationException($"Could not find map '{launchMap}'.");
throw new ArgumentException($"Could not find map '{launchMap}'.");
CreateAndStartLocalServer(map.Uid, orders);
}