public void CreateLocalPlayerTest() { GGPOPlayer player = GGPO.CreateLocalPlayer(1); Assert.True(player.type == GGPO.PlayerType.GGPO_PLAYERTYPE_LOCAL); Assert.True(player.playerNum == 1); }
public override GGPOErrorCode AddPlayer(GGPOPlayer player, out int playerHandle) { playerHandle = 0; if (player.type == GGPOPlayerType.Spectator) { return(AddSpectator(player.ipAddress, player.port)); } int queue = player.playerId - 1; if (player.playerId < 1 || player.playerId > numPlayers) { return(GGPOErrorCode.PlayerOutOfRange); } playerHandle = QueueToPlayerHandle(queue); if (player.type == GGPOPlayerType.Remote) { AddRemotePlayer(player.ipAddress, player.port, queue); } return(GGPOErrorCode.OK); }
public void Init(IList <Connections> connections, int playerIndex) { var remote_index = -1; var num_spectators = 0; var num_players = 0; for (int i = 0; i < connections.Count; ++i) { if (i != playerIndex && remote_index == -1) { remote_index = i; } if (connections[i].spectator) { ++num_spectators; } else { ++num_players; } } if (connections[playerIndex].spectator) { InitSpectator(connections[playerIndex].port, num_players, connections[remote_index].ip, connections[remote_index].port); } else { var players = new List <GGPOPlayer>(); for (int i = 0; i < connections.Count; ++i) { var player = new GGPOPlayer { player_num = players.Count + 1, }; if (playerIndex == i) { player.type = GGPOPlayerType.GGPO_PLAYERTYPE_LOCAL; player.ip_address = ""; player.port = 0; } else if (connections[i].spectator) { player.type = GGPOPlayerType.GGPO_PLAYERTYPE_SPECTATOR; player.ip_address = connections[remote_index].ip; player.port = connections[remote_index].port; } else { player.type = GGPOPlayerType.GGPO_PLAYERTYPE_REMOTE; player.ip_address = connections[remote_index].ip; player.port = connections[remote_index].port; } players.Add(player); } Init(connections[playerIndex].port, num_players, players, num_spectators); } }
public void CreateRemotePlayerTest() { GGPOPlayer player = GGPO.CreateRemotePlayer(2, "127.0.0.1", 10600); Assert.True(player.type == GGPO.PlayerType.GGPO_PLAYERTYPE_REMOTE); Assert.True(player.playerNum == 2); Assert.Equal("127.0.0.1", player.ipAddress); Assert.True(player.port == 10600); }
public void AddRemotePlayerTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); int handle; GGPOPlayer player = GGPO.CreateRemotePlayer(1, "127.0.0.1", 10600); GGPO.ErrorCode result = ggpo.AddPlayer(ref player, out handle); Assert.True(GGPO.Succeeded(result), String.Format("Could not add remote player: {0}", result)); }
public static int AddPlayer(GGPOPlayer player, out int phandle) { var result = GGPO.AddPlayer(ggpo, (int)player.type, player.player_num, player.ip_address, player.port, out phandle); return(result); }
public override GGPOErrorCode AddPlayer(GGPOPlayer player, out int playerHandle) { playerHandle = Constants.InvalidHandle; if (player.playerId < 1 || player.playerId > numPlayers) { return(GGPOErrorCode.PlayerOutOfRange); } playerHandle = player.playerId - 1; return(GGPOErrorCode.OK); }
public void SetFrameDelayTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); int handle; GGPOPlayer player = GGPO.CreateLocalPlayer(1); ggpo.AddPlayer(ref player, out handle); GGPO.ErrorCode result = ggpo.SetFrameDelay(handle, 3); Assert.True(GGPO.Succeeded(result), String.Format("Could not set frame delay: {0}", result)); }
public void AdvanceFrameTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); int[] handles = new int[2]; GGPOPlayer player1 = GGPO.CreateLocalPlayer(1); ggpo.AddPlayer(ref player1, out handles[0]); GGPOPlayer player2 = GGPO.CreateRemotePlayer(2, "127.0.0.1", 10600); ggpo.AddPlayer(ref player2, out handles[1]); ggpo.Idle(500); GGPO.ErrorCode result = ggpo.AdvanceFrame(); Assert.True(GGPO.Succeeded(result), String.Format("Could not advance frame: {0}", result)); }
public void AddLocalInputTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); int[] handles = new int[2]; GGPOPlayer player1 = GGPO.CreateLocalPlayer(1); ggpo.AddPlayer(ref player1, out handles[0]); GGPOPlayer player2 = GGPO.CreateRemotePlayer(2, "127.0.0.1", 10600); ggpo.AddPlayer(ref player2, out handles[1]); ggpo.Idle(100); byte[] inputs = { 8, 0, 0, 0, 0, 0, 0, 0 }; GGPO.ErrorCode result = ggpo.AddLocalInput(handles[0], inputs); Assert.True(GGPO.Succeeded(result), String.Format("Could not add local input: {0}", result)); }
public void GetNetworkStatsTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); int[] handles = new int[2]; GGPOPlayer player1 = GGPO.CreateLocalPlayer(1); ggpo.AddPlayer(ref player1, out handles[0]); GGPOPlayer player2 = GGPO.CreateRemotePlayer(2, "127.0.0.1", 10600); ggpo.AddPlayer(ref player2, out handles[1]); ggpo.Idle(500); GGPONetworkStats stats; GGPO.ErrorCode result = ggpo.GetNetworkStats(handles[1], out stats); Assert.True(GGPO.Succeeded(result), String.Format("Could not get network stats: {0}", result)); }
public void DisconnectPlayerTest() { Assert.True(false, "TODO: Fix this test"); ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); int[] handles = new int[2]; GGPOPlayer player1 = GGPO.CreateLocalPlayer(1); ggpo.AddPlayer(ref player1, out handles[0]); GGPOPlayer player2 = GGPO.CreateRemotePlayer(2, "127.0.0.1", 10600); ggpo.AddPlayer(ref player2, out handles[1]); ggpo.Idle(500); ggpo.AdvanceFrame(); GGPO.ErrorCode result = ggpo.DisconnectPlayer(handles[1]); Assert.True(GGPO.Succeeded(result), String.Format("Could not disconnect the player: {0}", result)); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var app = new VectorWar(); int offset = 0; int localPlayer = 0; // Window offsets for the different players Point[] windowOffsets = new Point[] { new Point(64, 64), new Point(740, 64), new Point(64, 600), new Point(700, 600), }; if (args.Length < 3) { Syntax(); return; } var localPort = int.Parse(args[offset++]); var numPlayers = int.Parse(args[offset++]); if (numPlayers < 0 || args.Length < offset + numPlayers) { Syntax(); return; } if (args[offset] == "spectate") { string[] hostSplit = GetNetworkInfo(args[offset + 1]); var hostIp = hostSplit[0]; var hostPort = int.Parse(hostSplit[1]); app.InitSpectator(localPort, numPlayers, hostIp, hostPort); } else { GGPOPlayer[] players = new GGPOPlayer[GGPOSharp.Constants.MaxSpectators + GGPOSharp.Constants.MaxPlayers]; int i; for (i = 0; i < numPlayers; i++) { string arg = args[offset++]; players[i].playerId = i + 1; if (arg.Equals("local", StringComparison.InvariantCultureIgnoreCase)) { players[i].type = GGPOPlayerType.Local; localPlayer = i; continue; } players[i].type = GGPOPlayerType.Remote; string[] remoteSplit = GetNetworkInfo(arg); players[i].ipAddress = remoteSplit[0]; players[i].port = int.Parse(remoteSplit[1]); } // Additional arguments past the number of players are spectators int numSpectators = 0; while (offset < args.Length) { players[i].type = GGPOPlayerType.Spectator; string[] remoteSplit = GetNetworkInfo(args[offset++]); players[i].ipAddress = remoteSplit[0]; players[i].playerId = int.Parse(remoteSplit[1]); i++; numSpectators++; } if (localPlayer < windowOffsets.Length) { app.Location = windowOffsets[localPlayer]; } app.Init(localPort, numPlayers, players, numSpectators); } //app.SyncTest = true; Application.Run(app); }
public override GGPOErrorCode AddPlayer(GGPOPlayer player, out int playerHandle) { playerHandle = 0; return(GGPOErrorCode.OK); }