Good Game, Peace Out Rollback Network SDK

Overview

  Appveyor build status

(日本語ドキュメントはこちら)

What's GGPO?

Traditional techniques account for network transmission time by adding delay to a players input, resulting in a sluggish, laggy game-feel. Rollback networking uses input prediction and speculative execution to send player inputs to the game immediately, providing the illusion of a zero-latency network. Using rollback, the same timings, reactions, visual and audio queues, and muscle memory your players build up playing offline will translate directly online. The GGPO networking SDK is designed to make incorporating rollback networking into new and existing games as easy as possible.

For more information about the history of GGPO, check out http://ggpo.net/

This repository contains the code, documentation, and sample applications for the SDK.

Building

Building GGPO is currently only available on Windows, however efforts are being made to port it to other platforms.

Windows

Windows builds requires both Visual Studio 2019 and CMake. Make sure you've installed both before starting. Make sure to add CMake to your path when installing.

  • Run the build_windows.cmd in the root directory of the SDK to generate the Visual Studio 2019 solution files.
  • Open build/GGPO.sln solution for Visual Studio 2019 to compile.

You can also run the cmake-gui tool if you prefer.

Sample Application

The Vector War application in the source directory contains a simple application which uses GGPO to synchronize the two clients. The command line arguments are:

vectorwar.exe  <localport>  <num players> ('local' | <remote ip>:<remote port>) for each player

See the .cmd files in the bin directory for examples on how to start 2, 3, and 4 player games.

Licensing

GGPO is available under The MIT License. This means GGPO is free for commercial and non-commercial use. Attribution is not required, but appreciated.

Issues
  • Connection manager abstraction layer

    Connection manager abstraction layer

    This pull request is to propose an abstraction layer for the network connection to sit between the upd class and the actual socket calls. The idea is to add dependency injection to the library to both enable easy mocking of the socket calls and to allow easier swapping of other network apis (like steam or console api calls) into GGPO. The change as is doesn't work because it assumes the user will pass a ConnectionManager derived object into the ggposession. I had a change that basically broke the C style bindings for the library and was able to build run and test the program, and everything worked fine. I reverted those changes and this version shows how I thought it could be used. But, I don't have a clear vision for how to provide this functionality to the user while maintaining the C support and current DLL style wrapping for the lib. I'm looking for input on what the best way to provide this as an external interface would be.

    It may be that we add explicit struct typing or c style function to the supported networking apis and anyone who wants to fork and add their own support will need to create their own functions that know what parameters the apis require for creating a ConnectionManager.

    Hoping for feedback. I tried to match style as much as possible. VS defaulted to tabs and I forgot to change that so I know in the new files I need to swap to spaces. But if I missed some other style or formatting stuff I'll make sure to fix that before submitting a CL that I'm hoping to get in. I'm looking to start a design conversation with this.

    opened by erebuswolf 13
  • Add Japanese documentation

    Add Japanese documentation

    There is no Japanese documentation yet which would be good to have.

    I would like to start the translation of the current documentation into Japanese.

    Should we add a subdirectory in the doc/ folder (i. e. doc/ja/) or just add a suffix to the markdown documents (i. e. DevelopmentGuide.ja.md)?

    opened by Shugyousha 11
  • Is there a maximum size in bytes for an input when creating a GGPOSession?

    Is there a maximum size in bytes for an input when creating a GGPOSession?

    So I've been testing GGPO on Linux, which I know isn't a supported plaform yet, and I've run into a small problem. I've noticed that GGPO crashes when the input size is anything larger than 18 bytes. Is 18 bytes the maximum input size that GGPO supports? Or is this simply a bug? I'm using a branch based on PR #52 .

    opened by Eoin-ONeill-Yokai 3
  • WIP osx support

    WIP osx support

    I just messed with things until it built successfully. These changes might not actually work, because I haven't tried running any games with them, but I wanted to put this out there to see what kind of non-correctness-related changes it needs.

    Note that to actually build on OSX you will need these changes plus the changes in #16. I did not include the changes in #16 because that would be annoying to read.

    opened by sharpobject 3
  • GGPO_ERRORCODE_PREDICTION_THRESHOLD after every ggpo_add_local_input

    GGPO_ERRORCODE_PREDICTION_THRESHOLD after every ggpo_add_local_input

    I apologize if this might be a stupid question, but I am having troubles in implementing this library in a sample project of mine. While running the vectorwar demo, everything seems to work fine, without issues. I can compile and execute the game without troubles and the synchronization via GGPO works flawlessly. However, when I try to implement GGPO in my own project, after the connection between the players has been established (GGPO_EVENTCODE_RUNNING has been issued), whenever I call a ggpo_add_local_input command, it always fails with the above return value (GGPO_ERRORCODE_PREDICTION_THRESHOLD). Is there any step I have to perform between the first time I receive a GGPO_EVENTCODE_RUNNING and the first ggpo_add_local_input / ggpo_synchronize_input that I am missing? If not, what could be the cause of this error?

    To summarize:

    • I start the session with ggpo_start_session (result = GGPO_ERRORCODE_SUCCESS)
    • add the two players with ggpo_add_player (result = GGPO_ERRORCODE_SUCCESS)
    • call for ggpo_advance_frame (result = GGPO_ERRORCODE_SUCCESS) at 60fps. Otherwise, call ggpo_idle
    • the two players connect and I get the events GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER, then GGPO_EVENTCODE_RUNNING
    • after this, whenever I call ggpo_add_local_input, it fails with result GGPO_ERRORCODE_PREDICTION_THRESHOLD, thus preventing synchronization between the clients.

    The above issue happens even when running two instances of the game on the same machine, on different ports.

    opened by AndreaJens 1
  • Translate the developer guide to Japanese

    Translate the developer guide to Japanese

    This translation was done by a professional translator (not me) and was generously donated by JakeTheJake74[0]. I just proof-read and added it.

    [0] https://github.com/pond3r/ggpo/issues/2#issuecomment-546357632

    opened by Shugyousha 1
  • Return correct value in UdpMsg::PayloadSize for SyncRequest type packets

    Return correct value in UdpMsg::PayloadSize for SyncRequest type packets

    I believe this to be in error, as it would be requesting the size of the SyncReply's union. I don't know if this has actual issues, aside from telling the user to make room for a few extra bytes on udp SendTo callback. Nonetheless, it is incorrectly written.

    It looks like another case of the Last Line Effect (as noted in https://www.viva64.com/en/b/0260/)

    opened by mrjnumber1 1
  • WIP Clang/LLVM support, fix warnings

    WIP Clang/LLVM support, fix warnings

    Includes some changes from other recent PRs (#12, #17, #21). I will remove those as I work on this some more.

    Main purpose of this PR is to fix all compilation warnings for the main library (vectorwar should be mostly untouched as its a bigger task to fix) and use the *.hpp file extension for C++ header files, as this is actually C++ code.

    Formatting changes made it in by mistake, will remove before suggesting this gets merged; otherwise I'd propose introducing a .clang-format file and settling on a style that can be applied automatically.

    With these changes one can build the library on windows with a full llvm toolchain including linker (lld-link.exe) on top of the Microsoft provided standard library. I'd like to get libc++ support done as well, but am having some trouble building it.

    Brings in WS2tcpip.h to replace deprecated functions.

    opened by tyler274 1
  • Added cross platform dll export

    Added cross platform dll export

    Added cross-platform dll export. When compiling the SDK, GGPO_SDK_EXPORT should be defined otherwise, the ggponet header will import rather than export.

    opened by ksmit799 1
  • Feature: Enhanced CMake Build Script

    Feature: Enhanced CMake Build Script

    This extends and refactors the original CMake script to make it nicer. The structure of it is loosely based on that used in bs::framework project.

    • Separate the Main SDK build definitions to its own CMakeLists.txt. Source file lists for each project were also moved to file CMakeSources.cmake, cataloged based on a folder they're in and the filter definitions for VS were added.
    • During build the executable/library artifacts are now stored in <BUILD_DIR>/<BIN_OR_LIB>/<ARCHITECTURE>/<BUILD_TYPE>. The scripts were modified to reflect that change.
    • Added most of the build flags from the original VS project with some new ones.
    • Added some properties to explicitly configure the build environment.
    • Add ability to install the libraries for distribution.
    • Other small renaming, cleanups and things that I've forgotten.
    opened by guestnone 1
  • CMake Support

    CMake Support

    This PR adds initial CMake build support and removes the old VS2019 solution under the build folder. The SDK still won't compile under anything other than windows (due to dependencies on several windows libs) but a proper cross-platform build system is the first step. This also allows for easier building of shared/static libs.

    opened by ksmit799 1
  • fix issue of winsocks not being initialized

    fix issue of winsocks not being initialized

    Fixes the following issue when you try to run ggpo separately from vectorwars (e.g. building your own ggpo.lib and ggpo.dll files):

    image

    Proposed Fix

    • Before ggpo_start_session() function is called make sure to call gpo_initialize_winsock() first.
    opened by hlimbo 1
  • WSANOTINITIALISED 10093 Error Code

    WSANOTINITIALISED 10093 Error Code

    Dependencies Used

    • Visual Studio 2019
    • Windows 10
    • ggpo.lib
    • ggpo.dll
    • SDL2

    Summary

    When I attempt to build ggpo as a .dll and .lib file to use as a dependency for my own project, I end up receiving the following error below:

    image

    Looking at the code snippet below (udp.cpp):

    void
    Udp::SendTo(char *buffer, int len, int flags, struct sockaddr *dst, int destlen)
    {
       struct sockaddr_in *to = (struct sockaddr_in *)dst;
    
       int res = sendto(_socket, buffer, len, flags, dst, destlen);
       if (res == SOCKET_ERROR) {
          DWORD err = WSAGetLastError();
          Log("unknown error in sendto (erro: %d  wsaerr: %d).\n", res, err);
          ASSERT(FALSE && "Unknown error in sendto");
       }
       char dst_ip[1024];
       Log("sent packet length %d to %s:%d (ret:%d).\n", len, inet_ntop(AF_INET, (void *)&to->sin_addr, dst_ip, ARRAY_SIZE(dst_ip)), ntohs(to->sin_port), res);
    }
    

    I end up getting a SOCKET_ERROR when the sendto(...) function is called. It turns out the error I get back is error code: 10093. Based on Microsoft's documentation, error code https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2, error code 10093 means that Win Sockets dependency hasn't been initialized yet.

    Steps to Reproduce:

    • The following simplified code will reproduce the issue:
    // assume callbacks, game state, non game state,  and port numbers are already defined somewhere else
    
    const int NUM_PLAYERS = 2;
    GGPOSession *ggpo = NULL;
    
    GGPOSessionCallbacks cb = { 0 };
    cb.begin_game      = vw_begin_game_callback;
    cb.advance_frame	 = vw_advance_frame_callback;
    cb.load_game_state = vw_load_game_state_callback;
    cb.save_game_state = vw_save_game_state_callback;
    cb.free_buffer     = vw_free_buffer;
    cb.on_event        = vw_on_event_callback;
    cb.log_game_state  = vw_log_game_state;
    
    ggpo_start_session(&ggpo, &cb, "rollback_tech_demo", NUM_PLAYERS, sizeof(int), localPort);
    
    ggpo_set_disconnect_timeout(ggpo, 3000);
    ggpo_set_disconnect_notify_start(ggpo, 1000);
    
    // Calls to ggpo_add_player() made but omitted to keep simple
    
    int maxTimeIdleMillis = 6;
    ggpo_idle(ggpo, maxTimeIdleMillis);
    
    // sends input request over the network using UDP protocol internally
    // Looks like this fails because Winsockets hasn't been initialized yet.
    ggpo_add_local_input(ggpo, ngs.local_player_handle, &localInputsThisFrame, sizeof(localInputsThisFrame));
    
    ggpo_synchronize_input(ggpo, (void *)allInputs, sizeof(int) * NUM_PLAYERS, &disconnectFlags);
    
    ggpo_advance_frame(ggpo);
    
    opened by hlimbo 1
  • Player's game crashes when spectator stops spectating them

    Player's game crashes when spectator stops spectating them

    This happens 100% of the time for me in both the latest version (commit 7ddadef) and the initial GitHub commit (commit 02b9eff), both in my own game and in the VectorWar sample app.

    Repro steps

    • Download the GGPO repository (commit 7ddadef)
    • Run configure_windows.cmd, open GGPO.sln, rebuild solution in Release/x64 (Windows 10, Visual Studio 2019 version 16.8.5)
    • Run start_vectorwar_2p_4s.cmd
    • Close one of the spectator windows
    • Roughly one second later, player one (who was connected to that spectator) will get an error window with the following text:
    GGPO Assertion Failed
    Assertion: _size != (N-1) @ C:\Dev\ggpobugtest\ggpo-master\src\lib\ggpo\ring_buffer.h:39 (pid:16416)
    
    • Clicking 'OK' on that error window causes the game to close

    Here's the call stack I get when running player one in a Debug build:

     	VectorWar.exe!Platform::AssertFailed(char * msg) Line 23	C++
    >	VectorWar.exe!RingBuffer<GameInput,64>::push(const GameInput & t) Line 39	C++
     	VectorWar.exe!UdpProtocol::SendInput(GameInput & input) Line 106	C++
     	VectorWar.exe!Peer2PeerBackend::DoPoll(int timeout) Line 139	C++
     	VectorWar.exe!Peer2PeerBackend::IncrementFrame() Line 335	C++
     	VectorWar.exe!ggpo_advance_frame(GGPOSession * ggpo) Line 139	C++
     	VectorWar.exe!VectorWar_AdvanceFrame(int * inputs, int disconnect_flags) Line 351	C++
     	VectorWar.exe!VectorWar_RunFrame(HWND__ * hwnd) Line 426	C++
     	VectorWar.exe!RunMainLoop(HWND__ * hwnd) Line 84	C++
     	VectorWar.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * __formal, wchar_t * __formal, int __formal) Line 181	C++
    

    And here's a video of it:

    https://user-images.githubusercontent.com/2348496/144055204-1fa83a06-aa50-4c58-8edf-bb68ee1512cd.mp4

    opened by ctmatthews 0
  • [fix] Use parameter config instead of private _config

    [fix] Use parameter config instead of private _config

    I apologize if this PR doesn't follow any contribution guide (I couldn't seem to find one). As detailed in #59, I figured this was a relatively low hanging fruit / easy fix to implement, so just went ahead and did it 😅

    opened by nakkamarra 0
  • Fix local frame advantage estimation

    Fix local frame advantage estimation

    UdpProtocol::_local_frame_advantage estimation was previously using the full packet round trip time instead of an estimation of the one-way packet trip time, so I edited the line of code to match the behavior described in the comment on the line above. This theoretically wasn't causing any issues in the first place, as all players would have similar errors in their local estimations and they would cancel each other out.

    opened by ctmatthews 0
Owner
Tony Cannon
Tony Cannon
Backroll is a pure Rust implementation of GGPO rollback networking library.

backroll-rs Backroll is a pure Rust implementation of GGPO rollback networking library. Development Status This is still in an early beta stage. At ti

Hourai Teahouse 232 Aug 1, 2022
This repo contains Direct3D 9, Direct3D 10, a few Direct3D 11, and DirectSound C++ samples from the legacy DirectX SDK updated to build using the Windows 10 SDK and the Microsoft.DXSDK.D3DX NuGet package

DirectX SDK Legacy Samples This repo contains Direct3D 9, Direct3D 10, a few Direct3D 11, and DirectSound samples that originally shipped in the legac

Chuck Walbourn 36 Jul 24, 2022
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.

evpp Introduction 中文说明 evpp is a modern C++ network library for developing high performance network services using TCP/UDP/HTTP protocols. evpp provid

Qihoo 360 3k Aug 12, 2022
XMap is a fast network scanner designed for performing Internet-wide IPv6 & IPv4 network research scanning.

XMap is reimplemented and improved thoroughly from ZMap and is fully compatible with ZMap, armed with the "5 minutes" probing speed and novel scanning techniques. XMap is capable of scanning the 32-bits address space in under 45 minutes.

idealeer 175 Jul 17, 2022
Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD

NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file

GMLC-TDC 9 Aug 2, 2022
Netif - Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD

NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file

GMLC-TDC 9 Aug 2, 2022
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

Welcome! The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design

Microsoft 7k Aug 6, 2022
A modding SDK that allows you to interact with a modified version of Cocos 2DX v2.2.3 utilized by Geometry Dash

What is CappuccinoSDK CappucinoSDK is a modding utility that allows you to interact with a modified version of the game engine Cocos-2DX v2.2.3, which

null 17 Jul 5, 2022
grey sdk

grey是龙游天下公司的产品"汉末霸业"的一个附属产品。开始是为了解决产品的扩展性,自由度,热更新,视频流播放,用户DIY,3d扩展,人工智能等功能而开发。后来把这些功能集成整理后,从而形成了一个完整的应用级解决方案。 grey是一套应用开发解决方案,使用类似c++的语言(cplus)进行开发。 让

grey-platform 51 Jun 18, 2022
MCUXpresso SDK

Overview MCUXpresso SDK is a comprehensive software enablement package designed to simplify and accelerate application development with Arm® Cortex®-M

NXP Micro 182 Aug 4, 2022
A modding SDK for Hitman 3

ZHM Mod SDK A modding SDK and mod loader for HITMAN 3. Description This is a community-made modding SDK and mod loader for HITMAN 3. Its purpose is to

Orfeas Zafeiris 38 Jul 3, 2022
Tuya IoTOS Embeded SDK WiFi & BLE for BK7231T

Tuya IoTOS Embedded Wi-Fi and BLE SDK for BK7231T 中文版 | English Overview Developed independently by Tuya Smart, Tuya IoTOS is the world's only IoT ope

Tuya 34 Jul 31, 2022
C++ Kite Connect API library / SDK

Kite Connect API C++ client Overview Dependencies Getting dependencies Linux Others & uWS v0.14 Building & installation Examples REST API Ticker Docum

Zerodha Technology 26 Aug 5, 2022
Android and iOS SDK to display maps and geodata of swisstopo. Owner: simonroesch, Deputy: gjn

Open Swiss Maps SDK Android and iOS SDK to display maps and geodata of swisstopo Free map layers and geo data by swisstopo in your app Offer your mobi

geo.admin.ch 22 Aug 7, 2022
Firmware and SDK for the ER-301

ER-301 Sound Computer Table of Contents Introduction Emulator Compiling the emulator Running the emulator Configuring the emulator Installing packages

Orthogonal Devices 101 Jun 28, 2022
Tuya MCU SDK Arduino Library is developed based on the Tuya Wi-Fi general integration solution

Tuya MCU SDK Arduino Library is developed based on the Tuya Wi-Fi general integration solution. The device's MCU is connected to a Wi-Fi module through a serial port to implement a network connection. The development is based on general firmware, which supports the adaptative 9600 and115200 baud rate

Tuya 73 Jun 28, 2022
Teamspeak FriendSystem Plugin written in C/C++ (Teamspeak SDK)

Teamspeak-FriendSystem Teamspeak FriendSystem Plugin written in C/C++ (Teamspeak SDK) Install it into AppData / Roaming / Ts3Client / plugins Its only

null 2 Sep 24, 2021
Minecraft Windows 10 Bedrock SDK (1.17.30)

MCBE SDK Minecraft Windows 10 Bedrock SDK (1.17.30) Simple usage: cmake_minimum_required(VERSION 3.20) project(DummieProj VERSION 0.1.0) SET(CMAKE_CX

null 20 Jun 8, 2022
A cross-platform SDK enabling developers to integrate real-time chat technology into their projects

4Players ODIN SDK ODIN is a cross-platform software development kit (SDK) that enables developers to integrate real-time chat technology into multipla

4Players 4 Feb 20, 2022