Skip to content

Commit 4231d02

Browse files
authored
Merge pull request #20 from x64-dev/main
Fixed sentry issue 53905448
2 parents 15593ff + dfe761c commit 4231d02

1 file changed

Lines changed: 48 additions & 37 deletions

File tree

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -950,14 +950,17 @@ static void StartPressed(void)
950950
pMesh->ProcessGameStart(startGamePacket2);
951951
}
952952
#else
953-
if (!TheNGMPGame->IsCountdownStarted())
953+
if (TheNGMPGame != nullptr)
954954
{
955-
// remote msg
956-
UnicodeString strInform;
957-
strInform.format(TheGameText->fetch("LAN:GameStartTimerPlural"), TheNGMPGame->GetTotalCountdownDuration());
958-
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->SendAnnouncementMessageToCurrentLobby(strInform, true);
955+
if (!TheNGMPGame->IsCountdownStarted())
956+
{
957+
// remote msg
958+
UnicodeString strInform;
959+
strInform.format(TheGameText->fetch("LAN:GameStartTimerPlural"), TheNGMPGame->GetTotalCountdownDuration());
960+
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->SendAnnouncementMessageToCurrentLobby(strInform, true);
959961

960-
TheNGMPGame->StartCountdown();
962+
TheNGMPGame->StartCountdown();
963+
}
961964
}
962965
#endif
963966

@@ -2060,46 +2063,49 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData)
20602063

20612064
#if defined(GENERALS_ONLINE_ENABLE_MATCH_START_COUNTDOWN)
20622065
// is there a countdown in progress?
2063-
if (TheNGMPGame->IsCountdownStarted())
2066+
if (TheNGMPGame != nullptr)
20642067
{
2065-
const int64_t timeBetweenChecks = 1000;
2066-
int64_t currTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::utc_clock::now().time_since_epoch()).count();
2067-
2068-
if (currTime - TheNGMPGame->GetCountdownLastCheckTime() >= timeBetweenChecks)
2068+
if (TheNGMPGame->IsCountdownStarted())
20692069
{
2070-
int secondsSinceCountdownStart = (currTime - TheNGMPGame->GetCountdownStartTime()) / 1000;
2071-
int secondsRemaining = TheNGMPGame->GetTotalCountdownDuration() - secondsSinceCountdownStart;
2072-
2073-
TheNGMPGame->UpdateCountdownLastCheckTime();
2070+
const int64_t timeBetweenChecks = 1000;
2071+
int64_t currTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::utc_clock::now().time_since_epoch()).count();
20742072

2075-
// remote msg
2076-
UnicodeString strInform;
2077-
if (secondsRemaining == 1)
2078-
strInform.format(TheGameText->fetch("LAN:GameStartTimerSingular"), secondsRemaining);
2079-
else
2080-
strInform.format(TheGameText->fetch("LAN:GameStartTimerPlural"), secondsRemaining);
2081-
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->SendAnnouncementMessageToCurrentLobby(strInform, true);
2082-
2083-
// are we done?
2084-
if (secondsRemaining <= 0)
2073+
if (currTime - TheNGMPGame->GetCountdownLastCheckTime() >= timeBetweenChecks)
20852074
{
2086-
// stop countdown
2087-
TheNGMPGame->StopCountdown();
2075+
int secondsSinceCountdownStart = (currTime - TheNGMPGame->GetCountdownStartTime()) / 1000;
2076+
int secondsRemaining = TheNGMPGame->GetTotalCountdownDuration() - secondsSinceCountdownStart;
20882077

2089-
// send start game packet
2090-
Lobby_StartGamePacket startGamePacket;
2091-
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->SendToMesh(startGamePacket);
2078+
TheNGMPGame->UpdateCountdownLastCheckTime();
20922079

2093-
// process locally too
2094-
NetworkMesh* pMesh = NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetNetworkMesh();
2095-
if (pMesh != nullptr)
2080+
// remote msg
2081+
UnicodeString strInform;
2082+
if (secondsRemaining == 1)
2083+
strInform.format(TheGameText->fetch("LAN:GameStartTimerSingular"), secondsRemaining);
2084+
else
2085+
strInform.format(TheGameText->fetch("LAN:GameStartTimerPlural"), secondsRemaining);
2086+
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->SendAnnouncementMessageToCurrentLobby(strInform, true);
2087+
2088+
// are we done?
2089+
if (secondsRemaining <= 0)
20962090
{
2097-
Lobby_StartGamePacket startGamePacket2;
2098-
pMesh->ProcessGameStart(startGamePacket2);
2091+
// stop countdown
2092+
TheNGMPGame->StopCountdown();
2093+
2094+
// send start game packet
2095+
Lobby_StartGamePacket startGamePacket;
2096+
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->SendToMesh(startGamePacket);
2097+
2098+
// process locally too
2099+
NetworkMesh* pMesh = NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetNetworkMesh();
2100+
if (pMesh != nullptr)
2101+
{
2102+
Lobby_StartGamePacket startGamePacket2;
2103+
pMesh->ProcessGameStart(startGamePacket2);
2104+
}
20992105
}
21002106
}
2101-
}
21022107

2108+
}
21032109
}
21042110
#endif
21052111

@@ -3598,7 +3604,12 @@ void OnKickedFromLobby()
35983604
{
35993605
// can't see ourselves
36003606
buttonPushed = true;
3601-
TheNGMPGame->reset();
3607+
3608+
if (TheNGMPGame != nullptr)
3609+
{
3610+
TheNGMPGame->reset();
3611+
}
3612+
36023613
GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSKicked"));
36033614
nextScreen = "Menus/WOLCustomLobby.wnd";
36043615
TheShell->pop();

0 commit comments

Comments
 (0)