pond3r/ggpo

GGPO Session with Local Players Only -- What's the Intended Behavior?

Eoin-ONeill-Yokai opened this issue · 3 comments

I've been testing GGPO on my current game project and ran into a roadblock. Specifically, in regard to a session with only local players, it seems like GGPO will always return GGPO_ERRORCODE_NOT_SYNCHRONIZED when trying to add inputs or synchronize inputs.

After spending some time trying to find the source of my issues, I caught this code and comment:

p2p.cpp

void
Peer2PeerBackend::AddRemotePlayer(char *ip,
                                  int port,
                                  int queue)
{
   /*
    * Start the state machine (xxx: no)
    */
   _synchronizing = true;
   
   _endpoints[queue].Init(&_udp, _poll, queue, ip, port, _local_connect_status);
   _endpoints[queue].SetDisconnectTimeout(_disconnect_timeout);
   _endpoints[queue].SetDisconnectNotifyStart(_disconnect_notify_start);
   _endpoints[queue].Synchronize();
}

So it seems to me that GGPO only enters its internal synchronization state machine when at least one remote player is added to the game session. Is this correct? So if I wanted to simulate an online game for local play (I.E. uses the GGPO synchronize_inputs to respect frame delay settings) how would this be achieved?

One easy way might be to loop through all the player in AddLocalInput and see if they're all local. If so, set _synchronzing to false. If that doesn't work I can try to dig into it and look for other solutions, but it might take me a few days.

Maybe a better fix would be to call CheckInitialSync in DoPoll if the current frame is 0.

Ok, this is a good start for me. Currently, I'm just wrapping around the GGPO interface and keeping track of the remote players. If there are no remote players, I just use my own delay-emulation using the client settings.

Thanks for taking the time to respond @pond3r !