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: result = GGPO.SynchronizeInput(ggpo, inputs, 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); }
public static void Log(string v) { GGPO.Log(ggpo, v); }