From 55cb594991f0f3a9c051c5d7f2ff366cfac3eb08 Mon Sep 17 00:00:00 2001 From: Jamie Meyer <45072324+HeatXD@users.noreply.github.com> Date: Sun, 4 Jun 2023 18:25:30 +0200 Subject: [PATCH] GGPO: fixed having to reset when a spectator leaves. --- dep/ggpo-x/src/network/udp_proto.cpp | 8 ++++++++ dep/ggpo-x/src/network/udp_proto.h | 4 +++- src/core/netplay.cpp | 4 ---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dep/ggpo-x/src/network/udp_proto.cpp b/dep/ggpo-x/src/network/udp_proto.cpp index 5b8d4543c..1334ca8d2 100644 --- a/dep/ggpo-x/src/network/udp_proto.cpp +++ b/dep/ggpo-x/src/network/udp_proto.cpp @@ -90,6 +90,14 @@ UdpProtocol::SendInput(GameInput &input) * (better, but still ug). For the meantime, make this queue really big to decrease * the odds of this happening... */ + + // disconnect peer when threshold is reached. + if (_pending_output.size() == RINGBUFFSIZE - 1) + { + Disconnect(); + return; + } + _pending_output.push(input); } SendPendingOutput(); diff --git a/dep/ggpo-x/src/network/udp_proto.h b/dep/ggpo-x/src/network/udp_proto.h index e04719485..6126743c9 100644 --- a/dep/ggpo-x/src/network/udp_proto.h +++ b/dep/ggpo-x/src/network/udp_proto.h @@ -8,6 +8,8 @@ #ifndef _UDP_PROTO_H_ #define _UDP_PROTO_H_ +#define RINGBUFFSIZE 64 + #include "enet/enet.h" #include "udp_msg.h" #include "game_input.h" @@ -167,7 +169,7 @@ protected: /* * Packet loss... */ - RingBuffer _pending_output; + RingBuffer _pending_output; GameInput _last_received_input; GameInput _last_sent_input; GameInput _last_acked_input; diff --git a/src/core/netplay.cpp b/src/core/netplay.cpp index 10c554b25..5ef8797a9 100644 --- a/src/core/netplay.cpp +++ b/src/core/netplay.cpp @@ -1072,10 +1072,6 @@ void Netplay::DropSpectator(s32 slot_id, DropPlayerReason reason) enet_peer_disconnect_now(s_spectators[slot_id].peer, 0); s_spectators[slot_id] = {}; s_num_spectators--; - // sadly we have to reset here. this really sucks for the active players since you dont really want to halt for a spectator. - // not resetting seems to be creating index out of bounds errors in the ringbuffer. - // TODO ? - Reset(); } void Netplay::UpdateConnectingState()