NetPlayClient: Split out OnData()

Over time OnData() has become a huge function-long case statement that
attempts to manage numerous packet-related behaviors, which makes it a
little difficult to reliably ensure certain handling doesn't interfere
with another case's. It's also mildly annoying to navigate due to its
size.

To make it a little easier to read and find the specific behavior, we
can break the relevant pieces of code out into their own functions.
This commit is contained in:
Lioncash 2021-09-15 10:26:01 -04:00
parent 94cfbfc49d
commit ae714b25ba
2 changed files with 1106 additions and 945 deletions

File diff suppressed because it is too large Load Diff

View File

@ -232,7 +232,6 @@ private:
void UpdateDevices();
void AddPadStateToPacket(int in_game_pad, const GCPadStatus& np, sf::Packet& packet);
void SendWiimoteState(int in_game_pad, const WiimoteInput& nw);
unsigned int OnData(sf::Packet& packet);
void Send(const sf::Packet& packet, u8 channel_id = DEFAULT_CHANNEL);
void Disconnect();
bool Connect();
@ -241,6 +240,51 @@ private:
void DisplayPlayersPing();
u32 GetPlayersMaxPing() const;
u32 OnData(sf::Packet& packet);
void OnPlayerJoin(sf::Packet& packet);
void OnPlayerLeave(sf::Packet& packet);
void OnChatMessage(sf::Packet& packet);
void OnChunkedDataStart(sf::Packet& packet);
void OnChunkedDataEnd(sf::Packet& packet);
void OnChunkedDataPayload(sf::Packet& packet);
void OnChunkedDataAbort(sf::Packet& packet);
void OnPadMapping(sf::Packet& packet);
void OnWiimoteMapping(sf::Packet& packet);
void OnGBAConfig(sf::Packet& packet);
void OnPadData(sf::Packet& packet);
void OnPadHostData(sf::Packet& packet);
void OnWiimoteData(sf::Packet& packet);
void OnPadBuffer(sf::Packet& packet);
void OnHostInputAuthority(sf::Packet& packet);
void OnGolfSwitch(sf::Packet& packet);
void OnGolfPrepare(sf::Packet& packet);
void OnChangeGame(sf::Packet& packet);
void OnGameStatus(sf::Packet& packet);
void OnStartGame(sf::Packet& packet);
void OnStopGame(sf::Packet& packet);
void OnPowerButton();
void OnPing(sf::Packet& packet);
void OnPlayerPingData(sf::Packet& packet);
void OnDesyncDetected(sf::Packet& packet);
void OnSyncGCSRAM(sf::Packet& packet);
void OnSyncSaveData(sf::Packet& packet);
void OnSyncSaveDataNotify(sf::Packet& packet);
void OnSyncSaveDataRaw(sf::Packet& packet);
void OnSyncSaveDataGCI(sf::Packet& packet);
void OnSyncSaveDataWii(sf::Packet& packet);
void OnSyncSaveDataGBA(sf::Packet& packet);
void OnSyncCodes(sf::Packet& packet);
void OnSyncCodesNotify();
void OnSyncCodesNotifyGecko(sf::Packet& packet);
void OnSyncCodesDataGecko(sf::Packet& packet);
void OnSyncCodesNotifyAR(sf::Packet& packet);
void OnSyncCodesDataAR(sf::Packet& packet);
void OnComputeMD5(sf::Packet& packet);
void OnMD5Progress(sf::Packet& packet);
void OnMD5Result(sf::Packet& packet);
void OnMD5Error(sf::Packet& packet);
void OnMD5Abort();
bool m_is_connected = false;
ConnectionState m_connection_state = ConnectionState::Failure;