From ccf6960aff98299aad72d43edb5bdc7cf9290859 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 25 Oct 2019 09:43:58 +0200 Subject: SCUMM HE: Implement joinSession() for Moonbase Commander --- engines/scumm/he/moonbase/net_main.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/scumm/he/moonbase/net_main.cpp b/engines/scumm/he/moonbase/net_main.cpp index 96654c35cf..77d0e9c99a 100644 --- a/engines/scumm/he/moonbase/net_main.cpp +++ b/engines/scumm/he/moonbase/net_main.cpp @@ -166,9 +166,25 @@ void Net::createSessionErrorCallback(Networking::ErrorResponse error) { } int Net::joinSession(int sessionIndex) { - warning("STUB: Net::joinSession(%d)", sessionIndex); // PN_JoinSession + debug(1, "Net::joinSession(%d)", sessionIndex); // PN_JoinSession + + if (!_sessions) { + warning("Net::joinSession(): no sessions"); + return 0; + } + + if (sessionIndex >= _sessions->countChildren()) { + warning("Net::joinSession(): session number too big: %d >= %lu", sessionIndex, _sessions->countChildren()); + return 0; + } + + if (!_sessions->child(sessionIndex)->hasChild("sessionid")) { + warning("Net::joinSession(): no sessionid in session"); + return 0; + } + + _sessionid = _sessions->child(sessionIndex)->child("sessionid")->asIntegerNumber(); - // FAKE successful join. FIXME return 1; } @@ -376,17 +392,17 @@ int Net::getSessionPlayerCount(int sessionNumber) { debug(1, "Net::getSessionPlayerCount(%d)", sessionNumber); // case GET_SESSION_PLAYER_COUNT_KLUDGE: if (!_sessions) { - warning("Net::getSessionName(): no sessions"); + warning("Net::getSessionPlayerCount(): no sessions"); return 0; } if (sessionNumber >= _sessions->countChildren()) { - warning("Net::getSessionName(): session number too big: %d >= %lu", sessionNumber, _sessions->countChildren()); + warning("Net::getSessionPlayerCount(): session number too big: %d >= %lu", sessionNumber, _sessions->countChildren()); return 0; } if (!_sessions->child(sessionNumber)->hasChild("players")) { - warning("Net::getSessionName(): no players in session"); + warning("Net::getSessionPlayerCount(): no players in session"); return 0; } -- cgit v1.2.3