added protocol versioning. AssignPlayer order is dead.
This commit is contained in:
@@ -87,7 +87,6 @@ namespace OpenRa
|
||||
|
||||
internal static void Initialize(string mapName, Renderer renderer, int2 clientSize, int localPlayer, Controller controller)
|
||||
{
|
||||
//localPlayerIndex = localPlayer;
|
||||
Game.renderer = renderer;
|
||||
Game.clientSize = clientSize;
|
||||
|
||||
@@ -102,7 +101,6 @@ namespace OpenRa
|
||||
ChangeMap(mapName);
|
||||
|
||||
if (Settings.Replay != "")
|
||||
//orderManager = new OrderManager(new IOrderSource[] { new ReplayOrderSource(Settings.Replay) });
|
||||
throw new NotImplementedException();
|
||||
else
|
||||
{
|
||||
@@ -197,6 +195,9 @@ namespace OpenRa
|
||||
|
||||
LobbyInfo = session;
|
||||
|
||||
if (Game.orderManager.Connection.ConnectionState == ConnectionState.Connected)
|
||||
world.SetLocalPlayer(Game.orderManager.Connection.LocalClientId);
|
||||
|
||||
if (Game.orderManager.FramesAhead != LobbyInfo.GlobalSettings.OrderLatency
|
||||
&& !Game.orderManager.GameStarted)
|
||||
{
|
||||
@@ -277,14 +278,6 @@ namespace OpenRa
|
||||
new Order( "ToggleReady", Game.world.LocalPlayer.PlayerActor, "" ) { IsImmediate = true } );
|
||||
}
|
||||
|
||||
/* temporary hack: DO NOT LEAVE IN */
|
||||
if( e.KeyCode == Keys.F2 )
|
||||
Game.world.LocalPlayer = Game.world.players[ ( Game.world.LocalPlayer.Index + 1 ) % 4 ];
|
||||
if( e.KeyCode == Keys.F3 )
|
||||
Game.controller.orderGenerator = new SellOrderGenerator();
|
||||
if( e.KeyCode == Keys.F4 )
|
||||
Game.controller.orderGenerator = new RepairOrderGenerator();
|
||||
|
||||
if( !Game.chat.isChatting )
|
||||
if( e.KeyCode >= Keys.D0 && e.KeyCode <= Keys.D9 )
|
||||
Game.controller.DoControlGroup( world, (int)e.KeyCode - (int)Keys.D0, (Modifiers)(int)e.Modifiers );
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using OpenRa.FileFormats;
|
||||
|
||||
namespace OpenRa.Network
|
||||
{
|
||||
@@ -78,6 +79,13 @@ namespace OpenRa.Network
|
||||
{
|
||||
socket = new TcpClient( host, port );
|
||||
var reader = new BinaryReader( socket.GetStream() );
|
||||
var serverProtocol = reader.ReadInt32();
|
||||
|
||||
if (ProtocolVersion.Version != serverProtocol)
|
||||
throw new InvalidOperationException(
|
||||
"Protocol version mismatch. Server={0} Client={1}"
|
||||
.F(serverProtocol, ProtocolVersion.Version));
|
||||
|
||||
clientId = reader.ReadInt32();
|
||||
connectionState = ConnectionState.Connected;
|
||||
|
||||
|
||||
@@ -18,12 +18,6 @@ namespace OpenRa.Network
|
||||
Game.chat.AddLine(order.Player, order.TargetString);
|
||||
break;
|
||||
}
|
||||
case "AssignPlayer":
|
||||
{
|
||||
order.Player.World.LocalPlayer = order.Player;
|
||||
Game.chat.AddLine(order.Player, "is now YOU.");
|
||||
break;
|
||||
}
|
||||
case "StartGame":
|
||||
{
|
||||
Game.chat.AddLine(Color.White, "Server", "The game has started.");
|
||||
|
||||
@@ -21,10 +21,15 @@ namespace OpenRa
|
||||
public Player LocalPlayer
|
||||
{
|
||||
get { return players[localPlayerIndex]; }
|
||||
set
|
||||
}
|
||||
|
||||
public void SetLocalPlayer(int index)
|
||||
{
|
||||
if (index != localPlayerIndex)
|
||||
{
|
||||
localPlayerIndex = value.Index;
|
||||
Game.viewport.GoToStartLocation( value );
|
||||
localPlayerIndex = index;
|
||||
Game.viewport.GoToStartLocation(LocalPlayer);
|
||||
Game.chat.AddLine(LocalPlayer, "is now YOU");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user