Skip to content

Commit 27507d8

Browse files
committed
- lobby tear down
- http mgr improvements - enable more UI flows
1 parent 91e65cf commit 27507d8

15 files changed

Lines changed: 200 additions & 79 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/HTTP/HTTPManager.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
enum class EHTTPVerb
1313
{
14-
GET,
15-
POST,
16-
PUT
14+
HTTP_VERB_GET,
15+
HTTP_VERB_POST,
16+
HTTP_VERB_PUT,
17+
HTTP_VERB_DELETE
1718
};
1819

1920
enum class EIPProtocolVersion
@@ -34,6 +35,7 @@ class HTTPManager
3435
void SendGETRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, std::function<void(bool bSuccess, int statusCode, std::string strBody)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr);
3536
void SendPOSTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, const char* szPostData, std::function<void(bool bSuccess, int statusCode, std::string strBody)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr);
3637
void SendPUTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, const char* szData, std::function<void(bool bSuccess, int statusCode, std::string strBody)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr);
38+
void SendDELETERequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, const char* szData, std::function<void(bool bSuccess, int statusCode, std::string strBody)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr);
3739

3840
void Shutdown();
3941

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/NetworkMesh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class NetworkMesh
7575
void ConnectToSingleUser(ENetAddress addr, Int64 user_id, bool bIsReconnect = false);
7676
void ConnectToMesh(LobbyEntry& lobby);
7777

78+
void Disconnect();
79+
7880
void Tick();
7981

8082
int64_t m_lastPing = -1;

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_Init.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class WebSocket
3838

3939
void SendData_RoomChatMessage(const char* szMessage);
4040
void SendData_JoinNetworkRoom(int roomID);
41+
void SendData_LeaveNetworkRoom();
4142
void SendData_MarkReady(bool bReady);
4243

4344
void Tick();

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,14 @@ class NGMP_OnlineServices_LobbyInterface
253253

254254
void JoinLobby(int index);
255255

256+
void LeaveCurrentLobby();
257+
256258
LobbyEntry GetLobbyFromIndex(int index);
257259

258260
std::vector<LobbyEntry> m_vecLobbies;
259261

262+
bool m_bPendingHostHasLeft = false;
263+
260264
private:
261265
std::vector<std::function<void(bool)>> m_vecCreateLobby_PendingCallbacks = std::vector<std::function<void(bool)>>();
262266

GeneralsMD/Code/GameEngine/Include/GameNetwork/GeneralsOnline/OnlineServices_RoomsInterface.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ class NGMP_OnlineServices_RoomsInterface
2424
std::function<void()> m_PendingRoomJoinCompleteCallback = nullptr;
2525
void JoinRoom(int roomIndex, std::function<void()> onStartCallback, std::function<void()> onCompleteCallback);
2626

27+
void LeaveRoom()
28+
{
29+
NGMP_OnlineServicesManager::GetInstance()->GetWebSocket()->SendData_LeaveNetworkRoom();
30+
}
31+
2732
std::function<void(UnicodeString strMessage)> m_OnChatCallback = nullptr;
2833
void RegisterForChatCallback(std::function<void(UnicodeString strMessage)> cb)
2934
{

GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -776,39 +776,39 @@ void GameEngine::update( void )
776776
{
777777

778778
// VERIFY CRC needs to be in this code block. Please to not pull TheGameLogic->update() inside this block.
779-
VERIFY_CRC
779+
VERIFY_CRC
780780

781-
TheRadar->UPDATE();
781+
TheRadar->UPDATE();
782782

783-
/// @todo Move audio init, update, etc, into GameClient update
784-
785-
TheAudio->UPDATE();
786-
TheGameClient->UPDATE();
787-
TheMessageStream->propagateMessages();
783+
/// @todo Move audio init, update, etc, into GameClient update
788784

789-
if (g_bTearDownGeneralsOnlineRequested) // delayed tear down
790-
{
791-
g_bTearDownGeneralsOnlineRequested = false;
785+
TheAudio->UPDATE();
786+
TheGameClient->UPDATE();
787+
TheMessageStream->propagateMessages();
792788

793-
if (g_pOnlineServicesMgr != nullptr)
794-
{
795-
g_pOnlineServicesMgr->Shutdown();
796-
delete g_pOnlineServicesMgr;
797-
g_pOnlineServicesMgr = nullptr;
798-
}
789+
if (g_bTearDownGeneralsOnlineRequested) // delayed tear down
790+
{
791+
g_bTearDownGeneralsOnlineRequested = false;
799792

800-
}
801-
if (g_pOnlineServicesMgr != nullptr)
802-
{
803-
g_pOnlineServicesMgr->Tick();
804-
}
793+
if (g_pOnlineServicesMgr != nullptr)
794+
{
795+
g_pOnlineServicesMgr->Shutdown();
796+
delete g_pOnlineServicesMgr;
797+
g_pOnlineServicesMgr = nullptr;
798+
}
805799

806-
if (TheNetwork != NULL)
807-
{
808-
TheNetwork->UPDATE();
809-
}
810-
811-
TheCDManager->UPDATE();
800+
}
801+
if (g_pOnlineServicesMgr != nullptr)
802+
{
803+
g_pOnlineServicesMgr->Tick();
804+
}
805+
806+
if (TheNetwork != NULL)
807+
{
808+
TheNetwork->UPDATE();
809+
}
810+
811+
TheCDManager->UPDATE();
812812
}
813813

814814

@@ -817,7 +817,7 @@ void GameEngine::update( void )
817817
TheGameLogic->UPDATE();
818818
}
819819

820-
820+
821821

822822
} // end perfGather
823823

@@ -828,18 +828,18 @@ extern bool DX8Wrapper_IsWindowed;
828828
extern HWND ApplicationHWnd;
829829

830830
/** -----------------------------------------------------------------------------------------------
831-
* The "main loop" of the game engine. It will not return until the game exits.
831+
* The "main loop" of the game engine. It will not return until the game exits.
832832
*/
833-
void GameEngine::execute( void )
833+
void GameEngine::execute(void)
834834
{
835-
835+
836836
DWORD prevTime = timeGetTime();
837837
#if defined(_DEBUG) || defined(_INTERNAL)
838838
DWORD startTime = timeGetTime() / 1000;
839839
#endif
840840

841841
// pretty basic for now
842-
while( !m_quitting )
842+
while (!m_quitting)
843843
{
844844

845845
//if (TheGlobalData->m_vTune)
@@ -872,34 +872,46 @@ void GameEngine::execute( void )
872872
}
873873
}
874874
#endif
875-
875+
876876
{
877-
try
877+
if (IsDebuggerPresent())
878878
{
879879
// compute a frame
880880
update();
881881
}
882-
catch (INIException e)
882+
else
883883
{
884-
// Release CRASH doesn't return, so don't worry about executing additional code.
885-
if (e.mFailureMessage)
886-
RELEASE_CRASH((e.mFailureMessage));
887-
else
888-
RELEASE_CRASH(("Uncaught Exception in GameEngine::update"));
889-
}
890-
catch (...)
891-
{
892-
// try to save info off
893-
try
884+
try
894885
{
895-
if (TheRecorder && TheRecorder->getMode() == RECORDERMODETYPE_RECORD && TheRecorder->isMultiplayer())
896-
TheRecorder->cleanUpReplayFile();
886+
// compute a frame
887+
update();
897888
}
898-
catch (...)
889+
catch (INIException e)
899890
{
891+
// Release CRASH doesn't return, so don't worry about executing additional code.
892+
if (e.mFailureMessage)
893+
RELEASE_CRASH((e.mFailureMessage));
894+
else
895+
RELEASE_CRASH(("Uncaught Exception in GameEngine::update"));
900896
}
901-
RELEASE_CRASH(("Uncaught Exception in GameEngine::update"));
902-
} // catch
897+
catch (...)
898+
{
899+
// try to save info off
900+
try
901+
{
902+
if (TheRecorder && TheRecorder->getMode() == RECORDERMODETYPE_RECORD && TheRecorder->isMultiplayer())
903+
TheRecorder->cleanUpReplayFile();
904+
}
905+
catch (const std::exception& e) // caught by reference to base
906+
{
907+
NetworkLog("A standard exception was caught, with message: %s", e.what());
908+
}
909+
catch (...)
910+
{
911+
}
912+
RELEASE_CRASH(("Uncaught Exception in GameEngine::update"));
913+
} // catch
914+
}
903915
} // perf
904916

905917
{

GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,11 @@ CustomMatchPreferences::CustomMatchPreferences()
433433
{
434434
AsciiString userPrefFilename;
435435

436-
// TODO_NGMP: Impl again
436+
// NGMP: Just return 0 - the gamespy profile ID is only ever set to 0 anyway
437437
#if defined(GENERALS_ONLINE)
438-
Int localProfile = TheGameSpyInfo->getLocalProfileID();
439-
#else
440438
Int localProfile = 0;
439+
#else
440+
Int localProfile = TheGameSpyInfo->getLocalProfileID();
441441
#endif
442442
userPrefFilename.format("GeneralsOnline\\CustomPref%d.ini", localProfile);
443443
load(userPrefFilename);

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

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -255,23 +255,28 @@ WindowLayout *WOLMapSelectLayout = NULL;
255255
void PopBackToLobby( void )
256256
{
257257
// delete TheNAT, its no good for us anymore.
258-
delete TheNAT;
259-
TheNAT = NULL;
258+
if (TheNAT != nullptr)
259+
{
260+
delete TheNAT;
261+
TheNAT = NULL;
262+
}
260263

261-
if (TheGameSpyInfo) // this can be blown away by a disconnect on the map transfer screen
264+
if (TheNGMPGame) // this can be blown away by a disconnect on the map transfer screen
262265
{
263-
NGMPGame* game = NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetCurrentGame();
266+
TheNGMPGame->reset();
267+
264268

265-
game->reset();
266-
TheGameSpyInfo->leaveStagingRoom();
267-
//TheGameSpyInfo->joinBestGroupRoom();
268269
}
269270

271+
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->LeaveCurrentLobby();
272+
270273
DEBUG_LOG(("PopBackToLobby() - parentWOLGameSetup is %X\n", parentWOLGameSetup));
271274
if (parentWOLGameSetup)
272275
{
273276
nextScreen = "Menus/WOLCustomLobby.wnd";
274277
TheShell->pop();
278+
279+
275280
}
276281
}
277282

@@ -1414,6 +1419,11 @@ Bool initialAcceptEnable = FALSE;
14141419
//-------------------------------------------------------------------------------------------------
14151420
void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )
14161421
{
1422+
// TODO_NGMP: impl this again
1423+
GameWindow* buttonBuddy = TheWindowManager->winGetWindowFromId(NULL, NAMEKEY("GameSpyGameOptionsMenu.wnd:ButtonCommunicator"));
1424+
if (buttonBuddy)
1425+
buttonBuddy->winEnable(FALSE);
1426+
14171427
// register for chat events
14181428
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->RegisterForChatCallback([](UnicodeString strMessage)
14191429
{
@@ -1787,6 +1797,24 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData)
17871797
return;
17881798
}
17891799

1800+
if (NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->m_bPendingHostHasLeft)
1801+
{
1802+
NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->m_bPendingHostHasLeft = false;
1803+
1804+
buttonPushed = true;
1805+
DEBUG_LOG(("Host left lobby\n"));
1806+
if (TheNGMPGame)
1807+
TheNGMPGame->reset();
1808+
1809+
// TODO_NGMP: Impl host migration, less annoying for users
1810+
1811+
GSMessageBoxOk(TheGameText->fetch("GUI:HostLeftTitle"), TheGameText->fetch("GUI:HostLeft"));
1812+
1813+
PopBackToLobby();
1814+
1815+
return;
1816+
}
1817+
17901818
if (raiseMessageBoxes)
17911819
{
17921820
RaiseGSMessageBox();
@@ -1814,6 +1842,7 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData)
18141842
{
18151843
case PeerResponse::PEERRESPONSE_DISCONNECT:
18161844
{
1845+
// TODO_NGMP: hook this up again
18171846
sawImportantMessage = TRUE;
18181847
AsciiString disconMunkee;
18191848
disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason);
@@ -2966,13 +2995,8 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg
29662995
WOLMapSelectLayout = NULL;
29672996
}
29682997

2969-
NGMPGame* game = NGMP_OnlineServicesManager::GetInstance()->GetLobbyInterface()->GetCurrentGame();
2970-
game->reset();
2971-
//peerLeaveRoom(TheGameSpyChat->getPeer(), StagingRoom, NULL);
2972-
TheGameSpyInfo->leaveStagingRoom();
2973-
buttonPushed = true;
2974-
nextScreen = "Menus/WOLCustomLobby.wnd";
2975-
TheShell->pop();
2998+
2999+
PopBackToLobby();
29763000

29773001
} //if ( controlID == buttonBack )
29783002
else if ( controlID == buttonCommunicatorID )

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,11 @@ void NGMP_WOLLobbyMenu_JoinLobbyCallback(bool bSuccess)
743743
//-------------------------------------------------------------------------------------------------
744744
void WOLLobbyMenuInit( WindowLayout *layout, void *userData )
745745
{
746+
// TODO_NGMP: impl this again
747+
GameWindow* buttonBuddy = TheWindowManager->winGetWindowFromId(NULL, NAMEKEY("WOLCustomLobby.wnd:ButtonBuddy"));
748+
if (buttonBuddy)
749+
buttonBuddy->winEnable(FALSE);
750+
746751
nextScreen = NULL;
747752
buttonPushed = false;
748753
isShuttingDown = false;
@@ -1750,7 +1755,7 @@ WindowMsgHandledType WOLLobbyMenuSystem( GameWindow *window, UnsignedInt msg,
17501755
break;
17511756

17521757
// Leave any group room, then pop off the screen
1753-
TheGameSpyInfo->leaveGroupRoom();
1758+
NGMP_OnlineServicesManager::GetInstance()->GetRoomsInterface()->LeaveRoom();
17541759

17551760
SetLobbyAttemptHostJoin( TRUE ); // pretend, since we don't want to queue up another action
17561761
buttonPushed = true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ void WOLWelcomeMenuInit( WindowLayout *layout, void *userData )
623623
buttonQuickMatch->winEnable(false);
624624
buttonMyInfo->winEnable(false);
625625
buttonBuddies->winEnable(false);
626-
buttonbuttonOptions->winEnable(false);
626+
//buttonbuttonOptions->winEnable(false);
627627
#else
628628
enableControls(TheGameSpyInfo->gotGroupRoomList());
629629
#endif

0 commit comments

Comments
 (0)