PopupHostGame.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: PopupHostGame.cpp /////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2002 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // created: Jul 2002
  34. //
  35. // Filename: PopupHostGame.cpp
  36. //
  37. // author: Chris Huybregts
  38. //
  39. // purpose: Contains the Callbacks for the Host Game Popus
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. //-----------------------------------------------------------------------------
  44. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  45. //-----------------------------------------------------------------------------
  46. //-----------------------------------------------------------------------------
  47. // USER INCLUDES //////////////////////////////////////////////////////////////
  48. //-----------------------------------------------------------------------------
  49. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  50. #include "Common/GlobalData.h"
  51. #include "Common/NameKeyGenerator.h"
  52. #include "Common/Version.h"
  53. #include "GameClient/WindowLayout.h"
  54. #include "GameClient/Gadget.h"
  55. #include "GameClient/GameText.h"
  56. #include "GameClient/KeyDefs.h"
  57. #include "GameClient/GadgetTextEntry.h"
  58. #include "GameClient/GadgetCheckBox.h"
  59. #include "GameClient/GadgetComboBox.h"
  60. #include "GameClient/GadgetListBox.h"
  61. #include "GameNetwork/GameSpy/GSConfig.h"
  62. #include "GameNetwork/GameSpy/Peerdefs.h"
  63. #include "GameNetwork/GameSpy/PeerThread.h"
  64. #include "GameNetwork/GameSpyOverlay.h"
  65. #include "GameNetwork/GameSpy/LadderDefs.h"
  66. #include "Common/CustomMatchPreferences.h"
  67. #include "Common/LadderPreferences.h"
  68. //-----------------------------------------------------------------------------
  69. // DEFINES ////////////////////////////////////////////////////////////////////
  70. //-----------------------------------------------------------------------------
  71. static NameKeyType parentPopupID = NAMEKEY_INVALID;
  72. static NameKeyType textEntryGameNameID = NAMEKEY_INVALID;
  73. static NameKeyType buttonCreateGameID = NAMEKEY_INVALID;
  74. static NameKeyType checkBoxAllowObserversID = NAMEKEY_INVALID;
  75. static NameKeyType textEntryGameDescriptionID = NAMEKEY_INVALID;
  76. static NameKeyType buttonCancelID = NAMEKEY_INVALID;
  77. static NameKeyType textEntryLadderPasswordID = NAMEKEY_INVALID;
  78. static NameKeyType comboBoxLadderNameID = NAMEKEY_INVALID;
  79. static NameKeyType textEntryGamePasswordID = NAMEKEY_INVALID;
  80. static GameWindow *parentPopup = NULL;
  81. static GameWindow *textEntryGameName = NULL;
  82. static GameWindow *buttonCreateGame = NULL;
  83. static GameWindow *checkBoxAllowObservers = NULL;
  84. static GameWindow *textEntryGameDescription = NULL;
  85. static GameWindow *buttonCancel = NULL;
  86. static GameWindow *comboBoxLadderName = NULL;
  87. static GameWindow *textEntryLadderPassword = NULL;
  88. static GameWindow *textEntryGamePassword = NULL;
  89. #ifdef _INTERNAL
  90. // for occasional debugging...
  91. //#pragma optimize("", off)
  92. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  93. #endif
  94. void createGame( void );
  95. //-----------------------------------------------------------------------------
  96. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  97. //-----------------------------------------------------------------------------
  98. // Ladders --------------------------------------------------------------------------------
  99. static bool isPopulatingLadderBox = false;
  100. void CustomMatchHideHostPopup(Bool hide)
  101. {
  102. if (!parentPopup)
  103. return;
  104. parentPopup->winHide( hide );
  105. }
  106. void HandleCustomLadderSelection(Int ladderID)
  107. {
  108. if (!parentPopup)
  109. return;
  110. CustomMatchPreferences pref;
  111. if (ladderID == 0)
  112. {
  113. pref.setLastLadder(AsciiString::TheEmptyString, 0);
  114. pref.write();
  115. return;
  116. }
  117. const LadderInfo *info = TheLadderList->findLadderByIndex(ladderID);
  118. if (!info)
  119. {
  120. pref.setLastLadder(AsciiString::TheEmptyString, 0);
  121. }
  122. else
  123. {
  124. pref.setLastLadder(info->address, info->port);
  125. }
  126. pref.write();
  127. }
  128. void PopulateCustomLadderListBox( GameWindow *win )
  129. {
  130. if (!parentPopup || !win)
  131. return;
  132. isPopulatingLadderBox = true;
  133. CustomMatchPreferences pref;
  134. Color specialColor = GameSpyColor[GSCOLOR_MAP_SELECTED];
  135. Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED];
  136. Color favoriteColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED];
  137. Color localColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED];
  138. Int index;
  139. GadgetListBoxReset( win );
  140. std::set<const LadderInfo *> usedLadders;
  141. // start with "No Ladder"
  142. index = GadgetListBoxAddEntryText( win, TheGameText->fetch("GUI:NoLadder"), normalColor, -1 );
  143. GadgetListBoxSetItemData( win, 0, index );
  144. // add the last ladder
  145. Int selectedPos = 0;
  146. AsciiString lastLadderAddr = pref.getLastLadderAddr();
  147. UnsignedShort lastLadderPort = pref.getLastLadderPort();
  148. const LadderInfo *info = TheLadderList->findLadder( lastLadderAddr, lastLadderPort );
  149. if (info && info->index > 0 && info->validCustom)
  150. {
  151. usedLadders.insert(info);
  152. index = GadgetListBoxAddEntryText( win, info->name, favoriteColor, -1 );
  153. GadgetListBoxSetItemData( win, (void *)(info->index), index );
  154. selectedPos = index;
  155. }
  156. // our recent ladders
  157. LadderPreferences ladPref;
  158. ladPref.loadProfile( TheGameSpyInfo->getLocalProfileID() );
  159. const LadderPrefMap recentLadders = ladPref.getRecentLadders();
  160. for (LadderPrefMap::const_iterator cit = recentLadders.begin(); cit != recentLadders.end(); ++cit)
  161. {
  162. AsciiString addr = cit->second.address;
  163. UnsignedShort port = cit->second.port;
  164. if (addr == lastLadderAddr && port == lastLadderPort)
  165. continue;
  166. const LadderInfo *info = TheLadderList->findLadder( addr, port );
  167. if (info && info->index > 0 && info->validCustom && usedLadders.find(info) == usedLadders.end())
  168. {
  169. usedLadders.insert(info);
  170. index = GadgetListBoxAddEntryText( win, info->name, favoriteColor, -1 );
  171. GadgetListBoxSetItemData( win, (void *)(info->index), index );
  172. }
  173. }
  174. // local ladders
  175. const LadderInfoList *lil = TheLadderList->getLocalLadders();
  176. LadderInfoList::const_iterator lit;
  177. for (lit = lil->begin(); lit != lil->end(); ++lit)
  178. {
  179. const LadderInfo *info = *lit;
  180. if (info && info->index < 0 && info->validCustom && usedLadders.find(info) == usedLadders.end())
  181. {
  182. usedLadders.insert(info);
  183. index = GadgetListBoxAddEntryText( win, info->name, localColor, -1 );
  184. GadgetListBoxSetItemData( win, (void *)(info->index), index );
  185. }
  186. }
  187. // special ladders
  188. lil = TheLadderList->getSpecialLadders();
  189. for (lit = lil->begin(); lit != lil->end(); ++lit)
  190. {
  191. const LadderInfo *info = *lit;
  192. if (info && info->index > 0 && info->validCustom && usedLadders.find(info) == usedLadders.end())
  193. {
  194. usedLadders.insert(info);
  195. index = GadgetListBoxAddEntryText( win, info->name, specialColor, -1 );
  196. GadgetListBoxSetItemData( win, (void *)(info->index), index );
  197. }
  198. }
  199. // standard ladders
  200. lil = TheLadderList->getStandardLadders();
  201. for (lit = lil->begin(); lit != lil->end(); ++lit)
  202. {
  203. const LadderInfo *info = *lit;
  204. if (info && info->index > 0 && info->validCustom && usedLadders.find(info) == usedLadders.end())
  205. {
  206. usedLadders.insert(info);
  207. index = GadgetListBoxAddEntryText( win, info->name, normalColor, -1 );
  208. GadgetListBoxSetItemData( win, (void *)(info->index), index );
  209. }
  210. }
  211. GadgetListBoxSetSelected( win, selectedPos );
  212. isPopulatingLadderBox = false;
  213. }
  214. void PopulateCustomLadderComboBox( void )
  215. {
  216. if (!parentPopup || !comboBoxLadderName)
  217. return;
  218. isPopulatingLadderBox = true;
  219. CustomMatchPreferences pref;
  220. AsciiString userPrefFilename;
  221. Int localProfile = TheGameSpyInfo->getLocalProfileID();
  222. userPrefFilename.format("GeneralsOnline\\CustomPref%d.ini", localProfile);
  223. pref.load(userPrefFilename);
  224. std::set<const LadderInfo *> usedLadders;
  225. Color specialColor = GameSpyColor[GSCOLOR_MAP_SELECTED];
  226. Color normalColor = GameSpyColor[GSCOLOR_MAP_UNSELECTED];
  227. Int index;
  228. GadgetComboBoxReset( comboBoxLadderName );
  229. index = GadgetComboBoxAddEntry( comboBoxLadderName, TheGameText->fetch("GUI:NoLadder"), normalColor );
  230. GadgetComboBoxSetItemData( comboBoxLadderName, index, 0 );
  231. Int selectedPos = 0;
  232. AsciiString lastLadderAddr = pref.getLastLadderAddr();
  233. UnsignedShort lastLadderPort = pref.getLastLadderPort();
  234. const LadderInfo *info = TheLadderList->findLadder( lastLadderAddr, lastLadderPort );
  235. if (info && info->validCustom)
  236. {
  237. usedLadders.insert(info);
  238. index = GadgetComboBoxAddEntry( comboBoxLadderName, info->name, specialColor );
  239. GadgetComboBoxSetItemData( comboBoxLadderName, index, (void *)(info->index) );
  240. selectedPos = index;
  241. }
  242. LadderPreferences ladPref;
  243. ladPref.loadProfile( localProfile );
  244. const LadderPrefMap recentLadders = ladPref.getRecentLadders();
  245. for (LadderPrefMap::const_iterator cit = recentLadders.begin(); cit != recentLadders.end(); ++cit)
  246. {
  247. AsciiString addr = cit->second.address;
  248. UnsignedShort port = cit->second.port;
  249. if (addr == lastLadderAddr && port == lastLadderPort)
  250. continue;
  251. const LadderInfo *info = TheLadderList->findLadder( addr, port );
  252. if (info && info->validCustom && usedLadders.find(info) == usedLadders.end())
  253. {
  254. usedLadders.insert(info);
  255. index = GadgetComboBoxAddEntry( comboBoxLadderName, info->name, normalColor );
  256. GadgetComboBoxSetItemData( comboBoxLadderName, index, (void *)(info->index) );
  257. }
  258. }
  259. index = GadgetComboBoxAddEntry( comboBoxLadderName, TheGameText->fetch("GUI:ChooseLadder"), normalColor );
  260. GadgetComboBoxSetItemData( comboBoxLadderName, index, (void *)-1 );
  261. GadgetComboBoxSetSelectedPos( comboBoxLadderName, selectedPos );
  262. isPopulatingLadderBox = false;
  263. }
  264. // Window Functions -----------------------------------------------------------------------
  265. //-------------------------------------------------------------------------------------------------
  266. /** Initialize the PopupHostGameInit menu */
  267. //-------------------------------------------------------------------------------------------------
  268. void PopupHostGameInit( WindowLayout *layout, void *userData )
  269. {
  270. parentPopupID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:ParentHostPopUp"));
  271. parentPopup = TheWindowManager->winGetWindowFromId(NULL, parentPopupID);
  272. textEntryGameNameID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:TextEntryGameName"));
  273. textEntryGameName = TheWindowManager->winGetWindowFromId(parentPopup, textEntryGameNameID);
  274. UnicodeString name;
  275. name.translate(TheGameSpyInfo->getLocalName());
  276. GadgetTextEntrySetText(textEntryGameName, name);
  277. textEntryGameDescriptionID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:TextEntryGameDescription"));
  278. textEntryGameDescription = TheWindowManager->winGetWindowFromId(parentPopup, textEntryGameDescriptionID);
  279. GadgetTextEntrySetText(textEntryGameDescription, UnicodeString::TheEmptyString);
  280. textEntryLadderPasswordID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:TextEntryLadderPassword"));
  281. textEntryLadderPassword = TheWindowManager->winGetWindowFromId(parentPopup, textEntryLadderPasswordID);
  282. GadgetTextEntrySetText(textEntryLadderPassword, UnicodeString::TheEmptyString);
  283. textEntryGamePasswordID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:TextEntryGamePassword"));
  284. textEntryGamePassword = TheWindowManager->winGetWindowFromId(parentPopup, textEntryGamePasswordID);
  285. GadgetTextEntrySetText(textEntryGamePassword, UnicodeString::TheEmptyString);
  286. buttonCreateGameID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:ButtonCreateGame"));
  287. buttonCreateGame = TheWindowManager->winGetWindowFromId(parentPopup, buttonCreateGameID);
  288. buttonCancelID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:ButtonCancel"));
  289. buttonCancel = TheWindowManager->winGetWindowFromId(parentPopup, buttonCancelID);
  290. checkBoxAllowObserversID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:CheckBoxAllowObservers"));
  291. checkBoxAllowObservers = TheWindowManager->winGetWindowFromId(parentPopup, checkBoxAllowObserversID);
  292. CustomMatchPreferences customPref;
  293. // disabling observers for Multiplayer test
  294. #ifndef _PLAYTEST
  295. GadgetCheckBoxSetChecked(checkBoxAllowObservers, customPref.allowsObservers());
  296. #else
  297. if (checkBoxAllowObservers)
  298. {
  299. GadgetCheckBoxSetChecked(checkBoxAllowObservers, FALSE);
  300. checkBoxAllowObservers->winEnable(FALSE);
  301. }
  302. #endif
  303. comboBoxLadderNameID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:ComboBoxLadderName"));
  304. comboBoxLadderName = TheWindowManager->winGetWindowFromId(parentPopup, comboBoxLadderNameID);
  305. if (comboBoxLadderName)
  306. GadgetComboBoxReset(comboBoxLadderName);
  307. PopulateCustomLadderComboBox();
  308. TheWindowManager->winSetFocus( parentPopup );
  309. TheWindowManager->winSetModal( parentPopup );
  310. }
  311. //-------------------------------------------------------------------------------------------------
  312. /** PopupHostGameInput callback */
  313. //-------------------------------------------------------------------------------------------------
  314. WindowMsgHandledType PopupHostGameInput( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 )
  315. {
  316. switch( msg )
  317. {
  318. // --------------------------------------------------------------------------------------------
  319. case GWM_CHAR:
  320. {
  321. UnsignedByte key = mData1;
  322. UnsignedByte state = mData2;
  323. // if (buttonPushed)
  324. // break;
  325. switch( key )
  326. {
  327. // ----------------------------------------------------------------------------------------
  328. case KEY_ESC:
  329. {
  330. //
  331. // send a simulated selected event to the parent window of the
  332. // back/exit button
  333. //
  334. if( BitTest( state, KEY_STATE_UP ) )
  335. {
  336. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  337. (WindowMsgData)buttonCancel, buttonCancelID );
  338. } // end if
  339. // don't let key fall through anywhere else
  340. return MSG_HANDLED;
  341. } // end escape
  342. } // end switch( key )
  343. } // end char
  344. } // end switch( msg )
  345. return MSG_IGNORED;
  346. }
  347. //-------------------------------------------------------------------------------------------------
  348. /** PopupHostGameSystem callback */
  349. //-------------------------------------------------------------------------------------------------
  350. WindowMsgHandledType PopupHostGameSystem( GameWindow *window, UnsignedInt msg, WindowMsgData mData1, WindowMsgData mData2 )
  351. {
  352. switch( msg )
  353. {
  354. // --------------------------------------------------------------------------------------------
  355. case GWM_CREATE:
  356. {
  357. break;
  358. } // end create
  359. //---------------------------------------------------------------------------------------------
  360. case GWM_DESTROY:
  361. {
  362. parentPopup = NULL;
  363. break;
  364. } // end case
  365. //----------------------------------------------------------------------------------------------
  366. case GWM_INPUT_FOCUS:
  367. {
  368. // if we're givin the opportunity to take the keyboard focus we must say we want it
  369. if( mData1 == TRUE )
  370. *(Bool *)mData2 = TRUE;
  371. break;
  372. } // end input
  373. //----------------------------------------------------------------------------------------------
  374. case GEM_UPDATE_TEXT:
  375. {
  376. GameWindow *control = (GameWindow *)mData1;
  377. Int controlID = control->winGetWindowId();
  378. if ( controlID == textEntryGameNameID )
  379. {
  380. UnicodeString txtInput;
  381. // grab the game's name
  382. txtInput.set(GadgetTextEntryGetText( textEntryGameName ));
  383. // Clean up the text (remove leading/trailing chars, etc)
  384. const WideChar *c = txtInput.str();
  385. while (c && (iswspace(*c)))
  386. c++;
  387. if (c)
  388. txtInput = UnicodeString(c);
  389. else
  390. txtInput = UnicodeString::TheEmptyString;
  391. // Put the whitespace-free version in the box
  392. GadgetTextEntrySetText( textEntryGameName, txtInput );
  393. }// if ( controlID == textEntryPlayerNameID )
  394. break;
  395. }//case GEM_UPDATE_TEXT:
  396. //---------------------------------------------------------------------------------------------
  397. case GCM_SELECTED:
  398. {
  399. GameWindow *control = (GameWindow *)mData1;
  400. Int controlID = control->winGetWindowId();
  401. Int pos = -1;
  402. GadgetComboBoxGetSelectedPos(control, &pos);
  403. if (controlID == comboBoxLadderNameID && !isPopulatingLadderBox)
  404. {
  405. if (pos >= 0)
  406. {
  407. Int ladderID = (Int)GadgetComboBoxGetItemData(control, pos);
  408. if (ladderID < 0)
  409. {
  410. // "Choose a ladder" selected - open overlay
  411. PopulateCustomLadderComboBox(); // this restores the non-"Choose a ladder" selection
  412. GameSpyOpenOverlay( GSOVERLAY_LADDERSELECT );
  413. }
  414. }
  415. }
  416. break;
  417. } // case GCM_SELECTED
  418. //---------------------------------------------------------------------------------------------
  419. case GBM_SELECTED:
  420. {
  421. GameWindow *control = (GameWindow *)mData1;
  422. Int controlID = control->winGetWindowId();
  423. if( controlID == buttonCancelID )
  424. {
  425. parentPopup = NULL;
  426. GameSpyCloseOverlay(GSOVERLAY_GAMEOPTIONS);
  427. SetLobbyAttemptHostJoin( FALSE );
  428. }
  429. else if( controlID == buttonCreateGameID)
  430. {
  431. UnicodeString name;
  432. name = GadgetTextEntryGetText(textEntryGameName);
  433. name.trim();
  434. if(name.getLength() <= 0)
  435. {
  436. name.translate(TheGameSpyInfo->getLocalName());
  437. GadgetTextEntrySetText(textEntryGameName, name);
  438. }
  439. createGame();
  440. parentPopup = NULL;
  441. GameSpyCloseOverlay(GSOVERLAY_GAMEOPTIONS);
  442. }
  443. break;
  444. }
  445. default:
  446. return MSG_IGNORED;
  447. } // end switch
  448. return MSG_HANDLED;
  449. }
  450. //-----------------------------------------------------------------------------
  451. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  452. //-----------------------------------------------------------------------------
  453. void createGame( void )
  454. {
  455. TheGameSpyInfo->setCurrentGroupRoom(0);
  456. PeerRequest req;
  457. UnicodeString gameName = GadgetTextEntryGetText(textEntryGameName);
  458. req.peerRequestType = PeerRequest::PEERREQUEST_CREATESTAGINGROOM;
  459. req.text = gameName.str();
  460. TheGameSpyGame->setGameName(gameName);
  461. AsciiString passwd;
  462. passwd.translate(GadgetTextEntryGetText(textEntryGamePassword));
  463. req.password = passwd.str();
  464. CustomMatchPreferences customPref;
  465. Bool aO = GadgetCheckBoxIsChecked(checkBoxAllowObservers);
  466. customPref.setAllowsObserver(aO);
  467. customPref.write();
  468. req.stagingRoomCreation.allowObservers = aO;
  469. TheGameSpyGame->setAllowObservers(aO);
  470. req.stagingRoomCreation.exeCRC = TheGlobalData->m_exeCRC;
  471. req.stagingRoomCreation.iniCRC = TheGlobalData->m_iniCRC;
  472. req.stagingRoomCreation.gameVersion = TheGameSpyInfo->getInternalIP();
  473. req.stagingRoomCreation.restrictGameList = TheGameSpyConfig->restrictGamesToLobby();
  474. Int ladderSelectPos = -1, ladderID = -1;
  475. GadgetComboBoxGetSelectedPos(comboBoxLadderName, &ladderSelectPos);
  476. req.ladderIP = "localhost";
  477. req.stagingRoomCreation.ladPort = 0;
  478. if (ladderSelectPos >= 0)
  479. {
  480. ladderID = (Int)GadgetComboBoxGetItemData(comboBoxLadderName, ladderSelectPos);
  481. if (ladderID != 0)
  482. {
  483. // actual ladder
  484. const LadderInfo *info = TheLadderList->findLadderByIndex(ladderID);
  485. if (info)
  486. {
  487. req.ladderIP = info->address.str();
  488. req.stagingRoomCreation.ladPort = info->port;
  489. }
  490. }
  491. }
  492. TheGameSpyGame->setLadderIP(req.ladderIP.c_str());
  493. TheGameSpyGame->setLadderPort(req.stagingRoomCreation.ladPort);
  494. req.hostPingStr = TheGameSpyInfo->getPingString().str();
  495. TheGameSpyPeerMessageQueue->addRequest(req);
  496. }