fix #2480; Direct Connect to different mod causes crash (saying 'missing map')

This commit is contained in:
Igor Popov
2013-01-07 00:27:45 +04:00
parent 88959b2e6c
commit ad2dbffe75

View File

@@ -111,7 +111,11 @@ namespace OpenRA.Network
case "HandshakeRequest": case "HandshakeRequest":
{ {
var request = HandshakeRequest.Deserialize(order.TargetString); var request = HandshakeRequest.Deserialize(order.TargetString);
var localMods = orderManager.LobbyInfo.GlobalSettings.Mods.Select(m => "{0}@{1}".F(m,Mod.AllMods[m].Version)).ToArray();
// Check if mods match
if (localMods.FirstOrDefault().ToString().Split('@')[0] != request.Mods.FirstOrDefault().ToString().Split('@')[0])
throw new InvalidOperationException("Server's mod ({0}) and yours ({1}) don't match".F(localMods.FirstOrDefault().ToString().Split('@')[0], request.Mods.FirstOrDefault().ToString().Split('@')[0]));
// Check that the map exists on the client // Check that the map exists on the client
if (!Game.modData.AvailableMaps.ContainsKey(request.Map)) if (!Game.modData.AvailableMaps.ContainsKey(request.Map))
throw new InvalidOperationException("Missing map {0}".F(request.Map)); throw new InvalidOperationException("Missing map {0}".F(request.Map));
@@ -126,7 +130,6 @@ namespace OpenRA.Network
State = Session.ClientState.NotReady State = Session.ClientState.NotReady
}; };
var localMods = orderManager.LobbyInfo.GlobalSettings.Mods.Select(m => "{0}@{1}".F(m,Mod.AllMods[m].Version)).ToArray();
var response = new HandshakeResponse() var response = new HandshakeResponse()
{ {
Client = info, Client = info,