Skip to content
Closed
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
2 changes: 0 additions & 2 deletions Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class NGMP_OnlineServices_LobbyInterface
{
public:
NGMP_OnlineServices_LobbyInterface();
void StopMatchStartCountdownIfRunning();

void SearchForLobbies(std::function<void()> onStartCallback, std::function<void(std::vector<LobbyEntry>)> onCompleteCallback);
void DeregisterForSearchForLobbiesCallback()
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<NGMP_OnlineServices_LobbyInterface>();
if (pLobbyInterface != nullptr)
Expand Down Expand Up @@ -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::milliseconds>(std::chrono::utc_clock::now().time_since_epoch()).count();

Expand All @@ -2407,7 +2411,6 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData)
{
pLobbyInterface->SendAnnouncementMessageToCurrentLobby(strInform, true);
}


// are we done?
if (secondsRemaining <= 0)
Expand All @@ -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
Expand Down Expand Up @@ -3753,62 +3775,62 @@ 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)
{
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();

// NOTE: No host check here, service enforces it
NGMPGameSlot* pSlot = (NGMPGameSlot*)myGame->getSlot(i);
int64_t userBeingKicked = pSlot->m_userID;

NGMP_OnlineServices_LobbyInterface* pLobbyInterface = NGMP_OnlineServicesManager::GetInterface<NGMP_OnlineServices_LobbyInterface>();
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)
{
Bool wasAI = (myGame->getSlot(i)->isAI());
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<NGMP_OnlineServices_LobbyInterface>();
if (pLobbyInterface != nullptr)
{
pLobbyInterface->UpdateCurrentLobby_SetSlotState(i, pos);
}
// inform service about new slot state
pLobbyInterface->UpdateCurrentLobby_SetSlotState(i, pos);

WOLDisplaySlotList();
//TheLAN->OnPlayerLeave(name);
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ std::vector<int64_t> m_vecUsersProcessed;

void PopulateLobbyPlayerListbox(void)
{

NGMP_OnlineServices_RoomsInterface* pRoomsInterface = NGMP_OnlineServicesManager::GetInterface<NGMP_OnlineServices_RoomsInterface>();
NGMP_OnlineServices_StatsInterface* pStatsInterface = NGMP_OnlineServicesManager::GetInterface<NGMP_OnlineServices_StatsInterface>();
NGMP_OnlineServices_AuthInterface* pAuthInterface = NGMP_OnlineServicesManager::GetInterface<NGMP_OnlineServices_AuthInterface>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void()> onStartCallback, std::function<void(std::vector<LobbyEntry>)> onCompleteCallback)
{
if (m_bSearchInProgress)
Expand Down Expand Up @@ -933,6 +943,15 @@ void NGMP_OnlineServices_LobbyInterface::UpdateRoomDataCache(std::function<void(
}
}

// stop countdown if player count actually decreased and we're the host
if (IsHost()
&& TheNGMPGame != nullptr
&& TheNGMPGame->IsCountdownStarted()
&& lobbyEntry.current_players < m_CurrentLobby.current_players)
{
TheNGMPGame->StopCountdown();
}

// store
m_CurrentLobby = lobbyEntry;

Expand Down
Loading