public static int AddLocalInput(int local_player_handle, ulong inputs) { var result = GGPO.AddLocalInput(ggpo, local_player_handle, inputs); return(result); }
public static int Idle(int time) { var result = GGPO.Idle(ggpo, time); return(result); }
public static int SetDisconnectTimeout(int timeout) { var result = GGPO.SetDisconnectTimeout(ggpo, timeout); return(result); }
public static int SynchronizeInput(ulong[] inputs, int length, out int disconnect_flags) { var result = GGPO.SynchronizeInput(ggpo, inputs, length, out disconnect_flags); return(result); }
public static void Init(LogDelegate log) { GGPO.SetLogDelegate(log); }
public void ggpoutil_perfmon_update(IntPtr ggpo, int[] players, int num_players) { int i; _num_players = num_players; if (_graph_size < MAX_GRAPH_SIZE) { i = _graph_size++; } else { i = _first_graph_index; _first_graph_index = (_first_graph_index + 1) % MAX_GRAPH_SIZE; } for (int j = 0; j < num_players; j++) { var result = GGPO.GetNetworkStats(ggpo, players[j], out int send_queue_len, out int recv_queue_len, out int ping, out int kbps_sent, out int local_frames_behind, out int remote_frames_behind); Debug.Assert(GGPO.SUCCEEDED(result)); /* * Random graphs */ if (j == 0) { _remote_queue_graph[i] = recv_queue_len; _send_queue_graph[i] = send_queue_len; } /* * Ping */ _ping_graph[j, i] = ping; /* * Frame Advantage */ _local_fairness_graph[j, i] = local_frames_behind; _remote_fairness_graph[j, i] = remote_frames_behind; if (local_frames_behind < 0 && remote_frames_behind < 0) { /* * Both think it's unfair (which, ironically, is fair). Scale both and subtrace. */ _fairness_graph[i] = Mathf.Abs(Mathf.Abs(local_frames_behind) - Mathf.Abs(remote_frames_behind)); } else if (local_frames_behind > 0 && remote_frames_behind > 0) { /* * Impossible! Unless the network has negative transmit time. Odd.... */ _fairness_graph[i] = 0; } else { /* * They disagree. Add. */ _fairness_graph[i] = Mathf.Abs(local_frames_behind) + Mathf.Abs(remote_frames_behind); } int now = Helper.TimeGetTime(); if (now > _last_text_update_time + 500) { SetWindowTextA(IDC_NETWORK_LAG, $"{ping} ms"); SetWindowTextA(IDC_FRAME_LAG, $"{((ping != 0) ? ping * 60f / 1000f : 0f)} frames"); SetWindowTextA(IDC_BANDWIDTH, $"{kbps_sent / 8f} kilobytes/sec"); SetWindowTextA(IDC_LOCAL_AHEAD, $"{local_frames_behind} frames"); SetWindowTextA(IDC_REMOTE_AHEAD, $"{remote_frames_behind} frames"); _last_text_update_time = now; } } //InvalidateRect(GetDlgItem(_dialog, IDC_FAIRNESS_GRAPH), NULL, FALSE); // InvalidateRect(GetDlgItem(_dialog, IDC_NETWORK_GRAPH), NULL, FALSE); }
public void IdleTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); GGPO.ErrorCode result = ggpo.Idle(100); Assert.True(GGPO.Succeeded(result), String.Format("Could not idle: {0}", result)); }
public static int AdvanceFrame() { var result = GGPO.AdvanceFrame(ggpo); return(result); }
public void StartSpectatingTest() { GGPO.ErrorCode result = ggpo.StartSpectating(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10601, "127.0.0.1", 10600); Assert.True(GGPO.Succeeded(result), String.Format("Spectating was not started successfully: {0}", result)); }
public void CloseSessionTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); GGPO.ErrorCode result = ggpo.CloseSession(); Assert.True(GGPO.Succeeded(result), String.Format("Session was not properly closed: {0}", result)); }
public void StartSyncTestTest() { GGPO.ErrorCode result = ggpo.StartSyncTest(session.CreateCallbacks(), "GGPOSharp", 2, 8, 1); Assert.True(GGPO.Succeeded(result), String.Format("Sync test was not started successfully: {0}", result)); }
public void SetDisconnectNotifyStartTest() { ggpo.StartSession(session.CreateCallbacks(), "GGPOSharp", 2, 8, 10600); GGPO.ErrorCode result = ggpo.SetDisconnectNotifyStart(5000); Assert.True(GGPO.Succeeded(result), String.Format("Could not set disconnect notify start: {0}", result)); }
public GGPOTests() { session = new Session(); ggpo = new GGPO(); }
public static int DisconnectPlayer(int phandle) { var result = GGPO.DisconnectPlayer(ggpo, phandle); return(result); }
/* * Init -- * * Initialize the vector war game. This initializes the game state and * the video renderer and creates a new network session. */ public static void Init(int localport, int num_players, IList <GGPOPlayer> players, int num_spectators) { // Initialize the game state gs.Init(num_players); #if SYNC_TEST var result = ggpo_start_synctest(cb, "vectorwar", num_players, 1); #else SetFuncPointers(); var result = GGPO.StartSession(out ggpo, vw_begin_game_callback, vw_advance_frame_callback, vw_load_game_state_callback, vw_log_game_state, vw_save_game_state_callback, vw_free_buffer_callback, vw_on_event_callback, "vectorwar", num_players, localport); if (ggpo == IntPtr.Zero) { OnLog?.Invoke("Session Error"); } #endif ReportFailure(result); // automatically disconnect clients after 3000 ms and start our count-down timer for // disconnects after 1000 ms. To completely disable disconnects, simply use a value of 0 // for ggpo_set_disconnect_timeout. ReportFailure(GGPO.SetDisconnectTimeout(ggpo, 3000)); ReportFailure(GGPO.SetDisconnectNotifyStart(ggpo, 1000)); int controllerId = 0; int playerIndex = 0; ngs.players = new PlayerConnectionInfo[num_players]; for (int i = 0; i < players.Count; i++) { ReportFailure(GGPO.AddPlayer(ggpo, (int)players[i].type, players[i].player_num, players[i].ip_address, players[i].port, out int handle)); if (players[i].type == GGPOPlayerType.GGPO_PLAYERTYPE_LOCAL) { var playerInfo = new PlayerConnectionInfo(); playerInfo.handle = handle; playerInfo.type = players[i].type; playerInfo.connect_progress = 100; playerInfo.controllerId = controllerId++; ngs.players[playerIndex++] = playerInfo; ngs.SetConnectState(handle, PlayerConnectState.Connecting); ReportFailure(GGPO.SetFrameDelay(ggpo, handle, FRAME_DELAY)); } else if (players[i].type == GGPOPlayerType.GGPO_PLAYERTYPE_REMOTE) { var playerInfo = new PlayerConnectionInfo(); playerInfo.handle = handle; playerInfo.type = players[i].type; playerInfo.connect_progress = 0; ngs.players[playerIndex++] = playerInfo; } } perf.ggpoutil_perfmon_init(); SetStatusText("Connecting to peers."); }
public static int SetFrameDelay(int phandle, int frame_delay) { var result = GGPO.SetFrameDelay(ggpo, phandle, frame_delay); return(result); }
/* * Idle -- * * Spend our idle time in ggpo so it can use whatever time we have left over * for its internal bookkeeping. */ public static void Idle(int time) { idleWatch.Start(); ReportFailure(GGPO.Idle(ggpo, time)); idleWatch.Stop(); }
public static void Log(string v) { GGPO.Log(ggpo, v); }
public void Shutdown() { Exit(); GGPO.SetLogDelegate(null); }
void Start() { Log(string.Format("Plugin Version: {0} build {1}", GGPO.Version, GGPO.BuildNumber)); GGPO.SetLogDelegate(Log); }
public void RunTest(int testId) { unsafe { ptrBeginGame = Marshal.GetFunctionPointerForDelegate <GGPO.BeginGameDelegate>(OnBeginGame); ptrAdvanceFrame = Marshal.GetFunctionPointerForDelegate <GGPO.AdvanceFrameDelegate>(OnAdvanceFrame); ptrLoadGameState = Marshal.GetFunctionPointerForDelegate <GGPO.LoadGameStateDelegate>(OnLoadGameState); ptrLogGameState = Marshal.GetFunctionPointerForDelegate <GGPO.LogGameStateDelegate>(OnLogGameState); ptrSaveGameState = Marshal.GetFunctionPointerForDelegate <GGPO.SaveGameStateDelegate>(OnSaveGameState); ptrFreeBuffer = Marshal.GetFunctionPointerForDelegate <GGPO.FreeBufferDelegate>(OnFreeBuffer); ptrOnEvent = Marshal.GetFunctionPointerForDelegate <GGPO.OnEventDelegate>(OnEventCallback); } switch (testId) { case 0: GGPO.StartSession(out ggpo, ptrBeginGame, ptrAdvanceFrame, ptrLoadGameState, ptrLogGameState, ptrSaveGameState, ptrFreeBuffer, ptrOnEvent, "Tests", num_players, local_port); Debug.Assert(ggpo != IntPtr.Zero); break; case 1: GGPO.StartSpectating(out ggpo, ptrBeginGame, ptrAdvanceFrame, ptrLoadGameState, ptrLogGameState, ptrSaveGameState, ptrFreeBuffer, ptrOnEvent, "Tests", num_players, local_port, host_ip, host_port); Debug.Assert(ggpo != IntPtr.Zero); break; case 2: result = GGPO.UggTestStartSession(out ggpo, ptrBeginGame, ptrAdvanceFrame, ptrLoadGameState, ptrLogGameState, ptrSaveGameState, ptrFreeBuffer, ptrOnEvent, "Tests", num_players, local_port); Debug.Assert(ggpo != IntPtr.Zero); break; case 3: inputs = GGPO.SynchronizeInput(ggpo, maxPlayers, out int disconnect_flags); Debug.Log($"DllSynchronizeInput{disconnect_flags} {inputs[0]} {inputs[1]}"); break; case 4: result = GGPO.AddLocalInput(ggpo, local_player_handle, input); break; case 5: result = GGPO.CloseSession(ggpo); ggpo = IntPtr.Zero; break; case 6: result = GGPO.Idle(ggpo, time); break; case 7: result = GGPO.AddPlayer(ggpo, player_type, player_num, player_ip_address, player_port, out phandle); break; case 8: result = GGPO.DisconnectPlayer(ggpo, phandle); break; case 9: result = GGPO.SetFrameDelay(ggpo, phandle, frame_delay); break; case 10: result = GGPO.AdvanceFrame(ggpo); break; case 11: result = GGPO.GetNetworkStats(ggpo, phandle, out int send_queue_len, out int recv_queue_len, out int ping, out int kbps_sent, out int local_frames_behind, out int remote_frames_behind); Debug.Log($"DllSynchronizeInput{send_queue_len}, {recv_queue_len}, {ping}, {kbps_sent}, " + $"{ local_frames_behind}, {remote_frames_behind}"); break; case 12: GGPO.Log(ggpo, logText); result = GGPO.OK; break; case 13: result = GGPO.SetDisconnectNotifyStart(ggpo, timeout); break; case 14: result = GGPO.SetDisconnectTimeout(ggpo, timeout); break; } ReportFailure(result); }