Skip to content

Commit 66c30ff

Browse files
committed
- More matchmaking work
1 parent 88dbf11 commit 66c30ff

7 files changed

Lines changed: 154 additions & 10 deletions

File tree

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ set(GAMEENGINE_SRC
11501150
Include/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h
11511151
Include/GameNetwork/GeneralsOnline/OnlineServices_RoomsInterface.h
11521152
Include/GameNetwork/GeneralsOnline/OnlineServices_StatsInterface.h
1153+
Include/GameNetwork/GeneralsOnline/OnlineServices_MatchmakingInterface.h
11531154
Include/GameNetwork/GeneralsOnline/PortMapper.h
11541155
Include/GameNetwork/GeneralsOnline/GeneralsOnline_Settings.h
11551156
Include/GameNetwork/GeneralsOnline/HTTP/HTTPManager.h
@@ -1349,6 +1350,7 @@ Source/GameNetwork/GeneralsOnline/Vendor/libplum/util.cpp
13491350
Source/GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.cpp
13501351
Source/GameNetwork/GeneralsOnline/OnlineServices_RoomsInterface.cpp
13511352
Source/GameNetwork/GeneralsOnline/OnlineServices_StatsInterface.cpp
1353+
Source/GameNetwork/GeneralsOnline/OnlineServices_MatchmakingInterface.cpp
13521354
Source/GameNetwork/GeneralsOnline/NextGenTransport.cpp
13531355
Source/GameNetwork/GeneralsOnline/NetworkBitstream.cpp
13541356
)
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#pragma once
2-
3-
#include "NGMP_include.h"
4-
5-
#include "GameNetwork/GeneralsOnline/OnlineServices_Init.h"
6-
#include "GameNetwork/GeneralsOnline/OnlineServices_Auth.h"
7-
#include "GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h"
8-
#include "GameNetwork/GeneralsOnline/OnlineServices_RoomsInterface.h"
9-
#include "GameNetwork/GeneralsOnline/OnlineServices_StatsInterface.h"
1+
#pragma once
2+
3+
#include "NGMP_include.h"
4+
5+
#include "GameNetwork/GeneralsOnline/OnlineServices_Init.h"
6+
#include "GameNetwork/GeneralsOnline/OnlineServices_Auth.h"
7+
#include "GameNetwork/GeneralsOnline/OnlineServices_LobbyInterface.h"
8+
#include "GameNetwork/GeneralsOnline/OnlineServices_RoomsInterface.h"
9+
#include "GameNetwork/GeneralsOnline/OnlineServices_StatsInterface.h"
10+
#include "GameNetwork/GeneralsOnline/OnlineServices_MatchmakingInterface.h"
1011
#include "GameNetwork/GeneralsOnline/PortMapper.h"

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class NGMP_OnlineServices_AuthInterface;
99
class NGMP_OnlineServices_LobbyInterface;
1010
class NGMP_OnlineServices_RoomsInterface;
1111
class NGMP_OnlineServices_StatsInterface;
12+
class NGMP_OnlineServices_MatchmakingInterface;
1213

1314
#pragma comment(lib, "libcurl/libcurl.lib")
1415
#pragma comment(lib, "sentry/sentry.lib")
@@ -310,6 +311,7 @@ class NGMP_OnlineServicesManager
310311
NGMP_OnlineServices_LobbyInterface* GetLobbyInterface() const { return m_pLobbyInterface; }
311312
NGMP_OnlineServices_RoomsInterface* GetRoomsInterface() const { return m_pRoomInterface; }
312313
NGMP_OnlineServices_StatsInterface* GetStatsInterface() const { return m_pStatsInterface; }
314+
NGMP_OnlineServices_MatchmakingInterface* GetMatchmakingInterface() const { return m_pMatchmakingInterface; }
313315
QoSManager& GetQoSManager() { return m_qosMgr; }
314316
QoSManager m_qosMgr;
315317

@@ -350,6 +352,7 @@ class NGMP_OnlineServicesManager
350352
NGMP_OnlineServices_LobbyInterface* m_pLobbyInterface = nullptr;
351353
NGMP_OnlineServices_RoomsInterface* m_pRoomInterface = nullptr;
352354
NGMP_OnlineServices_StatsInterface* m_pStatsInterface = nullptr;
355+
NGMP_OnlineServices_MatchmakingInterface* m_pMatchmakingInterface = nullptr;
353356
PortMapper m_PortMapper;
354357

355358
HTTPManager* m_pHTTPManager = nullptr;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#include "NGMP_include.h"
4+
5+
class NGMP_OnlineServices_MatchmakingInterface
6+
{
7+
public:
8+
NGMP_OnlineServices_MatchmakingInterface();
9+
10+
11+
void StartMatchmaking(int playlistID, std::function<void(bool)> fnCallback);
12+
13+
void CancelMatchmaking();
14+
private:
15+
16+
};

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ static Bool s_inQM = FALSE;
8383
#include "../NGMPGame.h"
8484
extern NGMPGame* TheNGMPGame;
8585
#endif
86+
#include "../OnlineServices_MatchmakingInterface.h"
8687

8788
// PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
8889
// window ids ------------------------------------------------------------------------------
@@ -572,6 +573,7 @@ void PopulateQMLadderComboBox( void )
572573

573574
static void populateQuickMatchMapSelectListbox( QuickMatchPreferences& pref )
574575
{
576+
// TODO_QUICKMATCH
575577
//std::list<AsciiString> maps = TheGameSpyConfig->getQMMaps();
576578
std::list<AsciiString> maps;
577579
maps.push_back(AsciiString("Maps\\Homeland Alliance\\Homeland Alliance.map"));
@@ -1645,6 +1647,19 @@ WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt ms
16451647

16461648
if ( controlID == buttonStopID )
16471649
{
1650+
#if defined(GENERALS_ONLINE)
1651+
buttonWiden->winEnable(FALSE);
1652+
buttonStart->winEnable(TRUE);
1653+
buttonStart->winHide(FALSE);
1654+
buttonStop->winHide(TRUE);
1655+
enableOptionsGadgets(TRUE);
1656+
1657+
Int index = GadgetListBoxAddEntryText(quickmatchTextWindow, TheGameText->fetch("GUI:QMAborted"), GameSpyColor[GSCOLOR_DEFAULT], -1, -1);
1658+
GadgetListBoxSetItemData(quickmatchTextWindow, (void*)-1, index);
1659+
1660+
NGMP_OnlineServices_MatchmakingInterface* pMatchmakingInterface = NGMP_OnlineServicesManager::GetInstance()->GetMatchmakingInterface();
1661+
pMatchmakingInterface->CancelMatchmaking();
1662+
#else
16481663
PeerRequest req;
16491664
req.peerRequestType = PeerRequest::PEERREQUEST_STOPQUICKMATCH;
16501665
TheGameSpyPeerMessageQueue->addRequest(req);
@@ -1653,6 +1668,7 @@ WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt ms
16531668
buttonStop->winHide( TRUE );
16541669
enableOptionsGadgets(TRUE);
16551670
TheGameSpyInfo->addText(TheGameText->fetch("GUI:QMAborted"), GameSpyColor[GSCOLOR_DEFAULT], quickmatchTextWindow);
1671+
#endif
16561672
}
16571673
else if ( controlID == buttonOptionsID )
16581674
{
@@ -1679,6 +1695,56 @@ WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt ms
16791695
}
16801696
else if ( controlID == buttonStartID )
16811697
{
1698+
#if defined(GENERALS_ONLINE)
1699+
1700+
// TODO_QUICKMATCH: Support map list
1701+
/*
1702+
Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect);
1703+
for ( Int i=0; i<numMaps; ++i )
1704+
{
1705+
req.qmMaps.push_back(GadgetListBoxGetItemData(listboxMapSelect, i, 0));
1706+
}
1707+
*/
1708+
1709+
int numPlayersIndex = 0;
1710+
GadgetComboBoxGetSelectedPos(comboBoxNumPlayers, &numPlayersIndex);
1711+
if (numPlayersIndex < 0)
1712+
{
1713+
numPlayersIndex = 0;
1714+
}
1715+
1716+
// buttons
1717+
buttonWiden->winEnable(FALSE);
1718+
buttonStart->winEnable(FALSE);
1719+
buttonStop->winHide(TRUE);
1720+
1721+
NGMP_OnlineServices_MatchmakingInterface* pMatchmakingInterface = NGMP_OnlineServicesManager::GetInstance()->GetMatchmakingInterface();
1722+
pMatchmakingInterface->StartMatchmaking(numPlayersIndex, [](bool bSuccess)
1723+
{
1724+
// TODO_QUICKMATCH: Chat has a sound effect in TheGameSpyInfo, re-eanble it
1725+
if (bSuccess)
1726+
{
1727+
Int index = GadgetListBoxAddEntryText(quickmatchTextWindow, UnicodeString(L"Started matchmaking... searching for players"), GameSpyColor[GSCOLOR_DEFAULT], -1, -1);
1728+
GadgetListBoxSetItemData(quickmatchTextWindow, (void*)-1, index);
1729+
1730+
// buttons
1731+
buttonWiden->winEnable(FALSE);
1732+
buttonStart->winHide(TRUE);
1733+
buttonStop->winHide(FALSE);
1734+
}
1735+
else
1736+
{
1737+
Int index = GadgetListBoxAddEntryText(quickmatchTextWindow, UnicodeString(L"Failed to start matchmaking."), GameSpyColor[GSCOLOR_DEFAULT], -1, -1);
1738+
GadgetListBoxSetItemData(quickmatchTextWindow, (void*)-1, index);
1739+
1740+
// buttons
1741+
buttonWiden->winEnable(FALSE);
1742+
buttonStart->winHide(FALSE);
1743+
buttonStart->winEnable(TRUE);
1744+
buttonStop->winHide(TRUE);
1745+
}
1746+
});
1747+
#else
16821748
PeerRequest req;
16831749
req.peerRequestType = PeerRequest::PEERREQUEST_STARTQUICKMATCH;
16841750
req.qmMaps.clear();
@@ -1853,6 +1919,7 @@ WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt ms
18531919
ladPref.addRecentLadder( p );
18541920
ladPref.write();
18551921
}
1922+
#endif
18561923
}
18571924
else if ( controlID == buttonBuddiesID )
18581925
{

GeneralsMD/Code/GameEngine/Source/GameNetwork/GeneralsOnline/HTTP/HTTPRequest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void HTTPRequest::PlatformStartRequest()
178178

179179
if (m_protover == EIPProtocolVersion::DONT_CARE)
180180
{
181-
curl_easy_setopt(m_pCURL, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
181+
curl_easy_setopt(m_pCURL, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
182182
}
183183
else if (m_protover == EIPProtocolVersion::FORCE_IPV4)
184184
{
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "GameNetwork/GeneralsOnline/NGMP_interfaces.h"
2+
#include "GameNetwork/GeneralsOnline/json.hpp"
3+
#include "GameNetwork/GeneralsOnline/HTTP/HTTPManager.h"
4+
#include "GameNetwork/GeneralsOnline/OnlineServices_Init.h"
5+
6+
NGMP_OnlineServices_MatchmakingInterface::NGMP_OnlineServices_MatchmakingInterface()
7+
{
8+
9+
}
10+
11+
void NGMP_OnlineServices_MatchmakingInterface::StartMatchmaking(int playlistID, std::function<void(bool)> fnCallback)
12+
{
13+
nlohmann::json j;
14+
j["playlist"] = playlistID;
15+
16+
std::map<std::string, std::string> mapHeaders;
17+
std::string strPostData = j.dump();
18+
std::string strURI = NGMP_OnlineServicesManager::GetAPIEndpoint("Matchmaking", true);
19+
NGMP_OnlineServicesManager::GetInstance()->GetHTTPManager()->SendPUTRequest(strURI.c_str(), EIPProtocolVersion::DONT_CARE, mapHeaders, strPostData.c_str(), [=](bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)
20+
{
21+
try
22+
{
23+
if (bSuccess && statusCode == 201)
24+
{
25+
26+
}
27+
else
28+
{
29+
// TODO_QUICKMATCH
30+
}
31+
32+
if (fnCallback != nullptr)
33+
{
34+
fnCallback(bSuccess);
35+
}
36+
}
37+
catch (...)
38+
{
39+
40+
}
41+
});
42+
}
43+
44+
void NGMP_OnlineServices_MatchmakingInterface::CancelMatchmaking()
45+
{
46+
nlohmann::json j;
47+
48+
std::map<std::string, std::string> mapHeaders;
49+
std::string strPostData = j.dump();
50+
std::string strURI = NGMP_OnlineServicesManager::GetAPIEndpoint("Matchmaking", true);
51+
NGMP_OnlineServicesManager::GetInstance()->GetHTTPManager()->SendDELETERequest(strURI.c_str(), EIPProtocolVersion::DONT_CARE, mapHeaders, strPostData.c_str(), [=](bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)
52+
{
53+
54+
});
55+
}

0 commit comments

Comments
 (0)