diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp index 2e5c1857a10..12c65c41613 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp @@ -857,9 +857,7 @@ void StartPatchCheck( void ) NGMP_OnlineServicesManager::GetInstance()->StartVersionCheck([](bool bSuccess, bool bNeedsUpdate) { -#if defined(USE_TEST_ENV) || defined(USE_DEBUG_ON_LIVE_SERVER) bNeedsUpdate = false; -#endif cantConnectBeforeOnline = !bSuccess; diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h index 1e525e58e1f..92c6239ea9d 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h +++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h @@ -99,6 +99,7 @@ class NGMP_OnlineServices_LobbyInterface { public: NGMP_OnlineServices_LobbyInterface(); + void StopMatchStartCountdownIfRunning(); void SearchForLobbies(std::function onStartCallback, std::function)> onCompleteCallback); void DeregisterForSearchForLobbiesCallback() @@ -407,6 +408,13 @@ class NGMP_OnlineServices_LobbyInterface void ClearAutoReadyCountdown() { m_timeStartAutoReadyCountdown = -1; + +#if defined(GENERALS_ONLINE_ENABLE_MATCH_START_COUNTDOWN) + if (TheNGMPGame != nullptr && TheNGMPGame->IsCountdownStarted()) + { + TheNGMPGame->StopCountdown(); + } +#endif } bool HasAutoReadyCountdown() diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp index ef91fdb2836..fedf1dd9a9b 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp @@ -201,6 +201,9 @@ static NameKeyType buttonEmoteID = NAMEKEY_INVALID; static NameKeyType buttonSelectMapID = NAMEKEY_INVALID; static NameKeyType windowMapID = NAMEKEY_INVALID; +#if defined(GENERALS_ONLINE_ENABLE_MATCH_START_COUNTDOWN) +static bool s_matchStartCountdownWasRunning = false; +#endif static NameKeyType windowMapSelectMapID = NAMEKEY_INVALID; static NameKeyType checkBoxUseStatsID = NAMEKEY_INVALID; static NameKeyType checkBoxLimitSuperweaponsID = NAMEKEY_INVALID; @@ -2346,8 +2349,6 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) TheNGMPGame->UpdateSlotsFromCurrentLobby(); - WOLDisplaySlotList(); - // Force a refresh to get latest lobby data NGMP_OnlineServices_LobbyInterface* pLobbyInterface = NGMP_OnlineServicesManager::GetInterface(); if (pLobbyInterface != nullptr) @@ -2385,6 +2386,9 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) { if (TheNGMPGame->IsCountdownStarted()) { + // mark that countdown is currently running + s_matchStartCountdownWasRunning = true; + const int64_t timeBetweenChecks = 1000; int64_t currTime = std::chrono::duration_cast(std::chrono::utc_clock::now().time_since_epoch()).count(); @@ -2407,7 +2411,6 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) { pLobbyInterface->SendAnnouncementMessageToCurrentLobby(strInform, true); } - // are we done? if (secondsRemaining <= 0) @@ -2423,7 +2426,26 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData) } } } + } + else + { + // countdown is currently NOT running. + // If it was running before, it just got cancelled or finished. + if (s_matchStartCountdownWasRunning) + { + s_matchStartCountdownWasRunning = false; + // Re-enable Back and Start buttons when countdown stops + if (buttonBack != nullptr) + { + buttonBack->winEnable(TRUE); + } + + if (buttonStart != nullptr) + { + buttonStart->winEnable(TRUE); + } + } } } #endif @@ -3753,6 +3775,7 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg if (i == myGame->getLocalSlotNum()) break; // Get + Int pos = -1; GadgetComboBoxGetSelectedPos(comboBoxPlayer[i], &pos); if (pos != SLOT_PLAYER && pos >= 0) @@ -3760,17 +3783,17 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg if (myGame->getSlot(i)->getState() == SLOT_PLAYER) { // TODO_NGMP: Support kick again - /* - PeerRequest req; - req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; - req.UTM.isStagingRoom = TRUE; - AsciiString aName; - aName.translate(myGame->getSlot(i)->getName()); - req.nick = aName.str(); - req.id = "KICK/"; - req.options = "true"; - TheGameSpyPeerMessageQueue->addRequest(req); - */ + /* + PeerRequest req; + req.peerRequestType = PeerRequest::PEERREQUEST_UTMPLAYER; + req.UTM.isStagingRoom = TRUE; + AsciiString aName; + aName.translate(myGame->getSlot(i)->getName()); + req.nick = aName.str(); + req.id = "KICK/"; + req.options = "true"; + TheGameSpyPeerMessageQueue->addRequest(req); + */ UnicodeString name = myGame->getSlot(i)->getName(); @@ -3778,19 +3801,15 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg NGMPGameSlot* pSlot = (NGMPGameSlot*)myGame->getSlot(i); int64_t userBeingKicked = pSlot->m_userID; - NGMP_OnlineServices_LobbyInterface* pLobbyInterface = NGMP_OnlineServicesManager::GetInterface(); - if (pLobbyInterface != nullptr) - { - pLobbyInterface->UpdateCurrentLobby_KickUser(userBeingKicked, name); - } + pLobbyInterface->UpdateCurrentLobby_KickUser(userBeingKicked, name); myGame->getSlot(i)->setState(SlotState(pos)); myGame->resetAccepted(); - // // TODO_NGMP - //TheGameSpyInfo->setGameOptions(); + // any slot change -> reset auto-ready & countdown + pLobbyInterface->ClearAutoReadyCountdown(); + WOLDisplaySlotList(); - //TheLAN->OnPlayerLeave(name); } else if (myGame->getSlot(i)->getState() != pos) { @@ -3798,17 +3817,20 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg myGame->getSlot(i)->setState(SlotState(pos)); Bool isAI = (myGame->getSlot(i)->isAI()); myGame->resetAccepted(); + + // // TODO_NGMP + //TheGameSpyInfo->setGameOptions(); + // any slot change -> reset auto-ready & countdown + pLobbyInterface->ClearAutoReadyCountdown(); + if (wasAI ^ isAI) PopulatePlayerTemplateComboBox(i, comboBoxPlayerTemplate, myGame, wasAI && myGame->getAllowObservers()); - // inform service - NGMP_OnlineServices_LobbyInterface* pLobbyInterface = NGMP_OnlineServicesManager::GetInterface(); - if (pLobbyInterface != nullptr) - { - pLobbyInterface->UpdateCurrentLobby_SetSlotState(i, pos); - } + // inform service about new slot state + pLobbyInterface->UpdateCurrentLobby_SetSlotState(i, pos); WOLDisplaySlotList(); + //TheLAN->OnPlayerLeave(name); } } break; diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp index ff4e94da9d2..391a2e6dbc0 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp @@ -724,6 +724,7 @@ std::vector m_vecUsersProcessed; void PopulateLobbyPlayerListbox(void) { + NGMP_OnlineServices_RoomsInterface* pRoomsInterface = NGMP_OnlineServicesManager::GetInterface(); NGMP_OnlineServices_StatsInterface* pStatsInterface = NGMP_OnlineServicesManager::GetInterface(); NGMP_OnlineServices_AuthInterface* pAuthInterface = NGMP_OnlineServicesManager::GetInterface(); diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.cpp index 09085ee5720..2cc78d54f4d 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.cpp @@ -468,6 +468,16 @@ NGMP_OnlineServices_LobbyInterface::NGMP_OnlineServices_LobbyInterface() } +void NGMP_OnlineServices_LobbyInterface::StopMatchStartCountdownIfRunning() +{ +#if defined(GENERALS_ONLINE_ENABLE_MATCH_START_COUNTDOWN) + if (TheNGMPGame != nullptr && TheNGMPGame->IsCountdownStarted()) + { + TheNGMPGame->StopCountdown(); + } +#endif +} + void NGMP_OnlineServices_LobbyInterface::SearchForLobbies(std::function onStartCallback, std::function)> onCompleteCallback) { if (m_bSearchInProgress) @@ -933,6 +943,15 @@ void NGMP_OnlineServices_LobbyInterface::UpdateRoomDataCache(std::functionIsCountdownStarted() + && lobbyEntry.current_players < m_CurrentLobby.current_players) + { + TheNGMPGame->StopCountdown(); + } + // store m_CurrentLobby = lobbyEntry;