pond3r / ggpo

Good Game, Peace Out Rollback Network SDK
MIT License
3.11k stars 360 forks source link

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

Open Eoin-ONeill-Yokai opened 4 years ago

Eoin-ONeill-Yokai commented 4 years ago

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?

pond3r commented 4 years ago

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.

pond3r commented 4 years ago

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

Eoin-ONeill-Yokai commented 4 years ago

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 !