Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gamenetwork): online custom rooms are never stats rooms
Olcay Seygandd5e210fb719
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 28aefe161..b68486332 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -555,6 +555,7 @@ public:AsciiString m_onlineJoinGame; ///< -onlinejoin <name>: join the custom game of this name once it is listedAsciiString m_onlineSay; ///< -onlinesay <text>: say this in the lobby and again in the staging roomAsciiString m_onlineMap; ///< -onlinemap <map>: the map -onlinehost sets+ AsciiString m_onlineOptions; ///< -onlineoptions <list>: the staging room controls the -onlinehost host works (prorules,turbo,unitlimit,randommap)Int m_onlineStart; ///< -onlinestart [N]: the -onlinehost host starts the game at N players (0 = never, bare = 2)Bool m_quickMatchOnStart; ///< -quickmatch: go into the Quick Match queue once logged inBool m_onlineLoginOnStart; ///< -onlinelogin: open the online login screen at startup, nothing filled indiff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex 00a00aa2f..9328166ab 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -2631,6 +2631,7 @@ Int parseOnlineSay(char *args[], int num)return used;}Int parseOnlineMap(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineMap ); }+Int parseOnlineOptions(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineOptions ); }/* -onlinestart N: the -onlinehost host starts the game once N players (itself included) sit in the room;bare or below 2 it is 2, the first joiner. */@@ -3193,6 +3194,7 @@ static CommandLineParam params[] ={ "-onlinejoin", parseOnlineJoin },{ "-onlinesay", parseOnlineSay },{ "-onlinemap", parseOnlineMap },+ { "-onlineoptions", parseOnlineOptions },{ "-onlinestart", parseOnlineStart },{ "-onlinelogin", parseOnlineLogin },{ "-quickmatch", parseQuickMatch },diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex b7353079c..00f26ebb2 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -803,6 +803,7 @@ GlobalData::GlobalData()m_onlineJoinGame.clear();m_onlineSay.clear();m_onlineMap.clear();+ m_onlineOptions.clear();m_onlineStart = 0;m_quickMatchOnStart = FALSE;m_onlineLoginOnStart = FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupHostGame.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupHostGame.cppindex c84b24065..bff43c1b3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupHostGame.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupHostGame.cpp@@ -70,6 +70,7 @@#include "GameNetwork/GameSpyOverlay.h"#include "GameNetwork/GameSpy/LadderDefs.h"+#include "GameNetwork/Online/OnlineQueues.h"#include "Common/CustomMatchPreferences.h"#include "Common/LadderPreferences.h"@@ -357,6 +358,14 @@ void PopupHostGameInit( WindowLayout *layout, void *userData )checkBoxUseStatsID = TheNameKeyGenerator->nameToKey(AsciiString("PopupHostGame.wnd:CheckBoxUseStats"));checkBoxUseStats = TheWindowManager->winGetWindowFromId(parentPopup, checkBoxUseStatsID);Bool usingStats = customPref.getUseStats();+ /* -online: a custom game is never rated (only Quick Match is), so there is no stats game to ask for.+ EA's box defaults to ticked, and a stats room locks every option for its host and forces Pro Rules+ (WOLGameSetupMenu's hostMayEdit and its game defaults), which is what an online host met. */+ if (OnlineIsEnabled())+ {+ usingStats = FALSE;+ checkBoxUseStats->winHide( TRUE );+ }GadgetCheckBoxSetChecked( checkBoxUseStats, usingStats );// limit armies is disallowed in "use stats" games@@ -582,7 +591,7 @@ void createGame( void )CustomMatchPreferences customPref;Bool aO = GadgetCheckBoxIsChecked(checkBoxAllowObservers);Bool limitArmies = GadgetCheckBoxIsChecked( checkBoxLimitArmies );- Bool useStats = GadgetCheckBoxIsChecked( checkBoxUseStats );+ Bool useStats = !OnlineIsEnabled() && GadgetCheckBoxIsChecked( checkBoxUseStats );customPref.setAllowsObserver(aO);customPref.setFactionsLimited( limitArmies );customPref.setUseStats( useStats );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cppindex 7b5067dad..b11adbdb2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp@@ -55,6 +55,7 @@#include "GameClient/GadgetPushButton.h"#include "GameClient/GadgetStaticText.h"#include "GameClient/GadgetCheckBox.h"+#include "GameClient/GadgetRadioButton.h"#include "GameClient/MapUtil.h"#include "GameClient/EstablishConnectionsMenu.h"#include "GameClient/GameWindowTransitions.h"@@ -1687,6 +1688,61 @@ static void onlineStagingScript( void )return;}+ /* -onlineoptions prorules,turbo,unitlimit,randommap: once a second seat is taken the host flips each named+ check box and picks a random map through the room's own controls, as clicks would, logging whether each+ control was live; Start waits until that is done. A stats room left them all dead for the host. */+ static Int s_optionStep = 0;+ const char *wanted = TheGlobalData->m_onlineOptions.str();+ if (TheGlobalData->m_onlineOptions.isNotEmpty() && s_optionStep >= 0)+ {+ if (seated < 2)+ return;+ if (s_optionStep == 0)+ {+ const struct { const char *name; GameWindow *box; } boxes[] = {+ { "prorules", checkBoxProRules }, { "turbo", checkBoxTurbo }, { "unitlimit", checkBoxUnitLimit } };+ for (Int i = 0; i < (Int)ARRAY_SIZE(boxes); ++i)+ {+ GameWindow *box = boxes[i].box;+ if (!strstr( wanted, boxes[i].name ) || !box)+ continue;+ const Bool live = box->winGetEnabled() && !box->winIsHidden();+ if (live)+ {+ GadgetCheckBoxSetChecked( box, !GadgetCheckBoxIsChecked( box ) );+ TheWindowManager->winSendSystemMsg( parentWOLGameSetup, GBM_SELECTED, (WindowMsgData)box, box->winGetWindowId() );+ }+ DEBUG_LOG(("ONLINE OPTION %s live=%d on=%d\n", boxes[i].name, (Int)live, (Int)GadgetCheckBoxIsChecked( box )));+ }+ s_optionStep = strstr( wanted, "randommap" ) ? 1 : -1;+ return;+ }+ if (s_optionStep == 1)+ {+ const Bool live = buttonSelectMap && buttonSelectMap->winGetEnabled() && !buttonSelectMap->winIsHidden();+ s_optionStep = live ? 2 : -1;+ if (live)+ TheWindowManager->winSendSystemMsg( parentWOLGameSetup, GBM_SELECTED, (WindowMsgData)buttonSelectMap, buttonSelectMapID );+ else+ DEBUG_LOG(("ONLINE OPTION randommap live=0 (Select Map)\n"));+ return;+ }+ GameWindow *tab = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY( "WOLMapSelectMenu.wnd:RadioButtonRandomMaps" ) );+ GameWindow *ok = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY( "WOLMapSelectMenu.wnd:ButtonOK" ) );+ if (!tab || !ok)+ return; // the map list is still opening+ const Bool live = tab->winGetEnabled() && !tab->winIsHidden();+ if (live)+ {+ GadgetRadioSetSelection( tab, FALSE );+ TheWindowManager->winSendSystemMsg( tab->winGetOwner(), GBM_SELECTED, (WindowMsgData)tab, tab->winGetWindowId() );+ TheWindowManager->winSendSystemMsg( ok->winGetOwner(), GBM_SELECTED, (WindowMsgData)ok, ok->winGetWindowId() );+ }+ DEBUG_LOG(("ONLINE OPTION randommap live=%d map=%s\n", (Int)live, game->getMap().str()));+ s_optionStep = -1;+ return;+ }+static Bool s_started = FALSE;if (s_started || TheGlobalData->m_onlineStart < 2 || TheGlobalData->m_onlineHostGame.isEmpty())return;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cppindex aaa280463..c4418e8bb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp@@ -262,34 +262,27 @@ static void onlineLobbyScript( void )&& (!saying || (s_said && Clock_Milliseconds() - s_saidAt >= 3000))){s_hosted = TRUE;- SetLobbyAttemptHostJoin( TRUE );- TheLobbyQueuedUTMs.clear();- groupRoomToJoin = TheGameSpyInfo->getCurrentGroupRoom();- TheGameSpyInfo->setCurrentGroupRoom(0);-+ /* The Host button, then the host popup's name and Create Game, as a player clicks them, so the room+ is made under the popup's own rules. Building the request here once hid that the popup made+ every online room a stats room, with every option locked for its host. */+ GameWindow *popupName = NULL, *popupCreate = NULL, *popup = NULL;+ if (buttonHost)+ {+ TheWindowManager->winSendSystemMsg( parent, GBM_SELECTED, (WindowMsgData)buttonHost, buttonHostID );+ popup = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY( "PopupHostGame.wnd:ParentHostPopUp" ) );+ popupName = TheWindowManager->winGetWindowFromId( popup, NAMEKEY( "PopupHostGame.wnd:TextEntryGameName" ) );+ popupCreate = TheWindowManager->winGetWindowFromId( popup, NAMEKEY( "PopupHostGame.wnd:ButtonCreateGame" ) );+ }+ if (!popup || !popupName || !popupCreate)+ {+ DEBUG_LOG(("ONLINE HOST fail popup=%d\n", popup != NULL));+ return;+ }UnicodeString gameName;gameName.translate( TheGlobalData->m_onlineHostGame );- PeerRequest req;- req.peerRequestType = PeerRequest::PEERREQUEST_CREATESTAGINGROOM;- req.text = gameName.str();- req.password = "";- req.stagingRoomCreation.allowObservers = FALSE;- req.stagingRoomCreation.useStats = FALSE;- req.stagingRoomCreation.exeCRC = TheGlobalData->m_exeCRC;- req.stagingRoomCreation.iniCRC = TheGlobalData->m_iniCRC;- req.stagingRoomCreation.gameVersion = TheGameSpyInfo->getInternalIP();- req.stagingRoomCreation.restrictGameList = TheGameSpyConfig->restrictGamesToLobby();- req.stagingRoomCreation.ladPort = 0;- req.ladderIP = "localhost";- req.hostPingStr = TheGameSpyInfo->getPingString().str();- TheGameSpyGame->setGameName( gameName );- TheGameSpyGame->setAllowObservers( FALSE );- TheGameSpyGame->setOldFactionsOnly( FALSE );- TheGameSpyGame->setUseStats( FALSE );- TheGameSpyGame->setLadderIP( req.ladderIP.c_str() );- TheGameSpyGame->setLadderPort( 0 );- TheGameSpyPeerMessageQueue->addRequest( req );- DEBUG_LOG(("ONLINE HOST name=%s\n", TheGlobalData->m_onlineHostGame.str()));+ GadgetTextEntrySetText( popupName, gameName );+ TheWindowManager->winSendSystemMsg( popupCreate->winGetOwner(), GBM_SELECTED, (WindowMsgData)popupCreate, popupCreate->winGetWindowId() );+ DEBUG_LOG(("ONLINE HOST name=%s stats=%d\n", TheGlobalData->m_onlineHostGame.str(), (Int)TheGameSpyGame->getUseStats()));return;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cppindex 119c7c156..a3101283b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp@@ -618,6 +618,9 @@ void GameSpyStagingRoom::startGame(Int gameID)DEBUG_LOG(("ONLINE LAUNCH slot=%d vip=%d.%d.%d.%d\n", i, ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff));}}+ // what every seat starts under, for online_check.py to set the host's line beside the guest's+ DEBUG_LOG(("ONLINE OPTIONS prorules=%d turbo=%d unitlimit=%d stats=%d map=%s\n", (Int)getProRules(), (Int)getTurbo(),+ (Int)getUnitLimit(), (Int)getUseStats(), getMap().str()));launchGame();if (TheGameSpyInfo)TheGameSpyInfo->leaveStagingRoom();