Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ static Bool buttonPushed = false;
static const char *nextScreen = NULL;
static Bool raiseMessageBoxes = false;
static Bool launchGameNext = FALSE;
static Bool isHandlingDisconnect = false;

// window ids ------------------------------------------------------------------------------
static NameKeyType parentWOLGameSetupID = NAMEKEY_INVALID;
Expand Down Expand Up @@ -1164,6 +1165,13 @@ Bool initialAcceptEnable = FALSE;
//-------------------------------------------------------------------------------------------------
void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )
{
// Prevent infinite recursion if we're already handling a disconnect
if (isHandlingDisconnect)
{
DEBUG_LOG(("WOLGameSetupMenuInit() - already handling disconnect, returning to prevent recursion"));
return;
}

if (TheGameSpyGame && TheGameSpyGame->isGameInProgress())
{
TheGameSpyGame->setGameInProgress(FALSE);
Expand All @@ -1181,13 +1189,15 @@ void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )
GSMessageBoxOk( title, body );
TheGameSpyInfo->reset();
DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, and we were disconnected, so pop immediate back to main menu"));
isHandlingDisconnect = true;
TheShell->popImmediate();
return;
}

// If we init while the game is in progress, we are really returning to the menu
// after the game. So, we pop the menu and go back to the lobby. Whee!
DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, so pop immediate back to lobby"));
isHandlingDisconnect = true;
TheShell->popImmediate();
if (TheGameSpyPeerMessageQueue && TheGameSpyPeerMessageQueue->isConnected())
{
Expand Down Expand Up @@ -1363,6 +1373,9 @@ static void shutdownComplete( WindowLayout *layout )
//-------------------------------------------------------------------------------------------------
void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData )
{
// Reset the disconnect handling flag to allow the menu to reinitialize properly
isHandlingDisconnect = false;

TheGameSpyInfo->unregisterTextWindow(listboxGameSetupChat);

if( WOLMapSelectLayout )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ static Bool buttonPushed = false;
static const char *nextScreen = NULL;
static Bool raiseMessageBoxes = false;
static Bool launchGameNext = FALSE;
static Bool isHandlingDisconnect = false;

// window ids ------------------------------------------------------------------------------
static NameKeyType parentWOLGameSetupID = NAMEKEY_INVALID;
Expand Down Expand Up @@ -1695,6 +1696,13 @@ Bool initialAcceptEnable = FALSE;
//-------------------------------------------------------------------------------------------------
void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )
{
// Prevent infinite recursion if we're already handling a disconnect
if (isHandlingDisconnect)
{
DEBUG_LOG(("WOLGameSetupMenuInit() - already handling disconnect, returning to prevent recursion"));
return;
}

NGMP_OnlineServices_LobbyInterface* pLobbyInterface = NGMP_OnlineServicesManager::GetInterface<NGMP_OnlineServices_LobbyInterface>();
if (pLobbyInterface == nullptr)
{
Expand Down Expand Up @@ -1879,6 +1887,7 @@ void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )
GSMessageBoxOk( title, body );
TheGameSpyInfo->reset();
DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, and we were disconnected, so pop immediate back to main menu"));
isHandlingDisconnect = true;
TheShell->popImmediate();
return;
}
Expand All @@ -1887,6 +1896,7 @@ void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )
// If we init while the game is in progress, we are really returning to the menu
// after the game. So, we pop the menu and go back to the lobby. Whee!
DEBUG_LOG(("WOLGameSetupMenuInit() - game was in progress, so pop immediate back to lobby"));
isHandlingDisconnect = true;
TheShell->popImmediate();

// TODO_NGMP: Only do this if still connected to service
Expand Down Expand Up @@ -2163,6 +2173,9 @@ static void shutdownComplete( WindowLayout *layout )
//-------------------------------------------------------------------------------------------------
void WOLGameSetupMenuShutdown( WindowLayout *layout, void *userData )
{
// Reset the disconnect handling flag to allow the menu to reinitialize properly
isHandlingDisconnect = false;

NGMP_OnlineServices_LobbyInterface* pLobbyInterface = NGMP_OnlineServicesManager::GetInterface<NGMP_OnlineServices_LobbyInterface>();

if (pLobbyInterface != nullptr)
Expand Down
Loading