Client/server handshake. Only checks that the correct mods are active.

This commit is contained in:
Paul Chote
2010-12-31 11:41:25 +13:00
parent dc012c0faf
commit 8f9e32dcc0
5 changed files with 145 additions and 24 deletions

View File

@@ -11,6 +11,7 @@
using System.Drawing;
using System.Linq;
using OpenRA.Traits;
using System;
namespace OpenRA.Network
{
@@ -96,8 +97,37 @@ namespace OpenRA.Network
Game.StartGame(orderManager.LobbyInfo.GlobalSettings.Map);
break;
}
case "HandshakeRequest":
{
Console.WriteLine("Client: Recieved HandshakeRequest");
// Check valid mods/versions
var serverInfo = Session.Deserialize(order.TargetString);
var serverMods = serverInfo.GlobalSettings.Mods;
var localMods = orderManager.LobbyInfo.GlobalSettings.Mods;
// TODO: Check that the map exists on the client
// Todo: Display a friendly dialog
if (serverMods.SymmetricDifference(localMods).Count() > 0)
throw new InvalidOperationException("Version mismatch. Client: `{0}`, Server: `{1}`"
.F(string.Join(",",localMods), string.Join(",",serverMods)));
var response = new HandshakeResponse()
{
Name = "Test Player",
Color1 = Color.PaleGreen,
Color2 = Color.PeachPuff,
Mods = localMods,
Password = "Foo"
};
orderManager.IssueOrder(Order.HandshakeResponse(response.Serialize()));
break;
}
case "SyncInfo":
{
Console.WriteLine("Client: Recieved SyncInfo");
orderManager.LobbyInfo = Session.Deserialize(order.TargetString);
if (orderManager.FramesAhead != orderManager.LobbyInfo.GlobalSettings.OrderLatency