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
feat(gamenetwork): EA online screens on our server, -online switches
Olcay Seygan797073af0ae3
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 826be54f2..dba02d973 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -556,7 +556,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- Bool m_onlineStart; ///< -onlinestart: the -onlinehost host starts the game once someone has joined+ 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_lanLobbyOnStart; ///< -lanlobby: open the LAN lobby instead of stopping at the main menuBool m_skirmishLobbyOnStart; ///< -skirmishlobby: open the skirmish staging room instead of stopping at the main menudiff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.hindex e7cd2bd4e..fa42d09cb 100644--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h@@ -140,6 +140,7 @@ public:AsciiString generateGameSpyGameResultsPacket( void );AsciiString generateLadderGameResultsPacket( void );+ void sendOnlineReport( const char *from ); ///< -online: the ladder packet's fields to OnlineSendReportvoid markGameAsQM( void ) { m_isQM = TRUE; }Bool isQMGame( void ) { return m_isQM; }diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Transport.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/Transport.hindex 3d14829ea..068fdff33 100644--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Transport.h+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/Transport.h@@ -70,6 +70,13 @@ public:/// -relay: the virtual address the relay gave this machine, 0 before the first init() reached itstatic UnsignedInt getRelayIP( void );+ /// -online: HELLO_AUTH with the login's ticket against OnlineGetRelayEndpoint (blocks up to five seconds)+ static Bool openOnlineRelay( void );+ /// -online: pump the relay socket (keepalive) while no Transport is attached; once a frame+ static void keepOnlineRelay( void );+ /// -online: drop the session unless a Transport still uses it+ static void closeOnlineRelay( void );+#if !defined(_WIN32)/* Port defect 29 (udp.h): shareAddress(TRUE) before init lets this socket share its port with anothercopy's broadcast listener; initBroadcastListener binds the wildcard address to take only the@@ -128,6 +135,7 @@ private:void resetQueues( UnsignedShort port );void receivePacket( TransportMessage &msg, Int len, UnsignedInt addr, UnsignedShort port, UnsignedInt now );Bool initRelayed( UnsignedInt ip, UnsignedShort port );+ static Bool connectRelay( const AsciiString &host, UnsignedShort relayPort );void detachRelay( void );Int writeRelayed( TransportMessage &msg );static void pumpRelay( void );diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex ec7642584..e6b92dac0 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -2600,7 +2600,14 @@ static Int parseOnlineText( char *args[], int num, AsciiString GlobalData::*fiel}Int parseOnlineCA(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineCAFile ); }-Int parseOnlineUser(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineUser ); }+/* -onlineuser also opens the online screens at startup (Shell::showShell), on top of a main menu, so it+ turns the shell map off the way -lanlobby does */+Int parseOnlineUser(char *args[], int num)+{+ if (TheWritableGlobalData)+ TheWritableGlobalData->m_shellMapOn = FALSE;+ return parseOnlineText( args, num, &GlobalData::m_onlineUser );+}Int parseOnlinePass(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlinePass ); }Int parseOnlineRegister(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineRegisterNick ); }Int parseOnlineHostGame(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineHostGame ); }@@ -2608,11 +2615,16 @@ Int parseOnlineJoin(char *args[], int num) { return parseOnlineText( args, numInt parseOnlineSay(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineSay ); }Int parseOnlineMap(char *args[], int num) { return parseOnlineText( args, num, &GlobalData::m_onlineMap ); }+/* -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. */Int parseOnlineStart(char *args[], int num){- if (TheWritableGlobalData)- TheWritableGlobalData->m_onlineStart = TRUE;- return 1;+ if (!TheWritableGlobalData)+ return 1;+ const Bool hasNumber = num > 1 && args[1][0] >= '0' && args[1][0] <= '9';+ const Int players = hasNumber ? atoi( args[1] ) : 2;+ TheWritableGlobalData->m_onlineStart = players < 2 ? 2 : (players > MAX_SLOTS ? MAX_SLOTS : players);+ return hasNumber ? 2 : 1;}Int parseQuickMatch(char *args[], int num)diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex adb2a35c6..04e735698 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -140,6 +140,7 @@#include "GameNetwork/LANAPICallbacks.h"#include "GameNetwork/NetworkUtil.h"#include "GameNetwork/GameSpy/GameResultsThread.h"+#include "GameNetwork/Online/OnlineQueues.h"#include "Common/version.h"@@ -1336,7 +1337,9 @@ void GameEngine::init( int argc, char *argv[] )initSubsystem(TheGameState,"TheGameState", MSGNEW("GameEngineSubsystem") GameState, NULL, NULL, NULL );// Create the interface for sending game results- initSubsystem(TheGameResultsQueue,"TheGameResultsQueue", GameResultsInterface::createNewGameResultsInterface(), NULL, NULL, NULL, NULL);+ // -online rates from OnlineSendReport, so its queue drops EA's results+ initSubsystem(TheGameResultsQueue,"TheGameResultsQueue",+ OnlineIsEnabled() ? OnlineCreateGameResults() : GameResultsInterface::createNewGameResultsInterface(), NULL, NULL, NULL, NULL);#ifdef DUMP_PERF_STATS///////////////////////////////////////////////////////////////////////////diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex 26b3e50d2..595950cf1 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -804,7 +804,7 @@ GlobalData::GlobalData()m_onlineJoinGame.clear();m_onlineSay.clear();m_onlineMap.clear();- m_onlineStart = FALSE;+ m_onlineStart = 0;m_quickMatchOnStart = FALSE;m_lanLobbyOnStart = FALSE;m_skirmishLobbyOnStart = FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cppindex db1ba0066..97bbfead5 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp@@ -99,6 +99,7 @@#include "GameNetwork/NetworkDefs.h"#include "GameNetwork/LANAPICallbacks.h"#include "GameNetwork/GameSpyOverlay.h"+#include "GameNetwork/Online/OnlineQueues.h"#include "GameNetwork/GameSpy/BuddyThread.h"#include "GameNetwork/GameSpy/PersistentStorageThread.h"#include "GameClient/InGameUI.h"@@ -1579,8 +1580,13 @@ void populatePlayerInfo( Player *player, Int pos)return;}- // send ladder results (even if we end the game in the first N seconds)- if (TheGameSpyGame->getLadderPort() && TheGameSpyGame->getLadderIP().isNotEmpty())+ // send ladder results (even if we end the game in the first N seconds). -online has no+ // ladder address: the service takes every match's report and decides what is rated.+ if (OnlineIsEnabled())+ {+ TheGameSpyGame->sendOnlineReport( "score" );+ }+ else if (TheGameSpyGame->getLadderPort() && TheGameSpyGame->getLadderIP().isNotEmpty()){GameResultsRequest gameResReq;gameResReq.hostname = TheGameSpyGame->getLadderIP().str();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cppindex 700488319..1496151cc 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp@@ -66,6 +66,8 @@#include "GameNetwork/GameSpy/PersistentStorageDefs.h"#include "GameNetwork/GameSpy/PersistentStorageThread.h"#include "GameNetwork/GameSpyOverlay.h"+#include "GameNetwork/Online/OnlineQueues.h"+#include "Lib/WideCharFns.h"#include "GameNetwork/NAT.h"#include "GameNetwork/GUIUtil.h"#include "GameNetwork/GameSpy/GSConfig.h"@@ -1624,6 +1626,82 @@ static Bool initDone = false;UnsignedInt lastSlotlistTime = 0;UnsignedInt enterTime = 0;Bool initialAcceptEnable = FALSE;++/// -onlinemap: the map the -onlinehost host opens its room on, a cache path or a folder name under Maps+static AsciiString onlineScriptMap( const AsciiString &otherwise )+{+ if (!OnlineIsEnabled() || TheGlobalData->m_onlineMap.isEmpty() || TheGlobalData->m_onlineHostGame.isEmpty())+ return otherwise;+ AsciiString name = TheGlobalData->m_onlineMap;+ if (!TheMapCache->findMap( name ))+ name.format( "maps\\%s\\%s.map", TheGlobalData->m_onlineMap.str(), TheGlobalData->m_onlineMap.str() );+ if (!TheMapCache->findMap( name ))+ {+ DEBUG_LOG(("ONLINE MAP missing name=%s\n", TheGlobalData->m_onlineMap.str()));+ return otherwise;+ }+ DEBUG_LOG(("ONLINE MAP name=%s\n", name.str()));+ return name;+}++/* -online scripting in the staging room: -onlinesay says its line once; a -onlinejoin joiner accepts+ whenever the Accept button is live and it has not; the -onlinehost host with -onlinestart N presses+ Start once N players sit in the room and every one of them has accepted. */+static void onlineStagingScript( void )+{+ if (!OnlineIsEnabled() || !parentWOLGameSetup)+ return;+ GameSpyStagingRoom *game = TheGameSpyInfo->getCurrentStagingRoom();+ if (!game || !game->isInGame() || game->isGameInProgress())+ return;++ static Bool s_said = FALSE;+ if (!s_said && TheGlobalData->m_onlineSay.isNotEmpty())+ {+ s_said = TRUE;+ UnicodeString line;+ line.translate( TheGlobalData->m_onlineSay );+ PeerRequest req;+ req.peerRequestType = PeerRequest::PEERREQUEST_MESSAGEROOM;+ req.text = line.str();+ req.message.isAction = FALSE;+ TheGameSpyPeerMessageQueue->addRequest( req );+ DEBUG_LOG(("ONLINE SAY where=staging text=%s\n", TheGlobalData->m_onlineSay.str()));+ }++ if (!TheGameSpyInfo->amIHost())+ {+ const Int local = game->getLocalSlotNum();+ GameSlot *slot = local >= 0 ? game->getSlot( local ) : NULL;+ if (TheGlobalData->m_onlineJoinGame.isNotEmpty() && slot && !slot->isAccepted()+ && buttonStart && buttonStart->winGetEnabled())+ {+ DEBUG_LOG(("ONLINE ACCEPT slot=%d\n", local));+ TheWindowManager->winSendSystemMsg( parentWOLGameSetup, GBM_SELECTED, (WindowMsgData)buttonStart, buttonStartID );+ }+ return;+ }++ static Bool s_started = FALSE;+ if (s_started || TheGlobalData->m_onlineStart < 2 || TheGlobalData->m_onlineHostGame.isEmpty())+ return;+ Int humans = 0;+ for (Int i = 0; i < MAX_SLOTS; ++i)+ {+ GameSlot *slot = game->getSlot( i );+ if (!slot || !slot->isHuman())+ continue;+ if (!slot->isAccepted())+ return;+ ++humans;+ }+ if (humans < TheGlobalData->m_onlineStart)+ return;+ s_started = TRUE;+ DEBUG_LOG(("ONLINE START players=%d\n", humans));+ StartPressed();+}+//-------------------------------------------------------------------------------------------------/** Initialize the Lan Game Options Menu *///-------------------------------------------------------------------------------------------------@@ -1692,7 +1770,8 @@ void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )hostSlot->setPlayerTemplate( customPref.getPreferredFaction() );hostSlot->setNATBehavior((FirewallHelperClass::FirewallBehaviorType)natPref.getFirewallBehavior());hostSlot->setPingString(TheGameSpyInfo->getPingString());- game->setMap(customPref.getPreferredMap());+ const AsciiString hostMap = onlineScriptMap( customPref.getPreferredMap() );+ game->setMap(hostMap);// Recorded stats games can never limit superweapons, limit armies, or have inflated starting cash.// This should probably be enforced at the gamespy level as well, to prevent expoits.@@ -1728,7 +1807,7 @@ void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )slot->setState( SLOT_OPEN );}- AsciiString lowerMap = customPref.getPreferredMap();+ AsciiString lowerMap = hostMap;lowerMap.toLower();std::map<AsciiString, MapMetaData>::iterator it = TheMapCache->find(lowerMap);if (it != TheMapCache->end())@@ -2025,6 +2104,8 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData)}}+ onlineStagingScript();+PeerResponse resp;Int allowedMessages = TheGameSpyInfo->getMaxMessagesPerUpdate();@@ -2250,6 +2331,8 @@ void WOLGameSetupMenuUpdate( WindowLayout * layout, void *userData)case PeerResponse::PEERRESPONSE_MESSAGE:{+ if (OnlineIsEnabled())+ DEBUG_LOG(("ONLINE CHAT where=staging from=%s text=%s\n", resp.nick.c_str(), WideCharAsUtf8( resp.text.c_str() ).str()));TheGameSpyInfo->addChat(resp.nick.c_str(), resp.message.profileID,UnicodeString(resp.text.c_str()), !resp.message.isPrivate, resp.message.isAction, listboxGameSetupChat);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cppindex 9341b8cc0..5021e73d9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLobbyMenu.cpp@@ -58,6 +58,8 @@#include "GameClient/Mouse.h"#include "GameClient/Display.h"#include "GameNetwork/GameSpyOverlay.h"+#include "GameNetwork/Online/OnlineQueues.h"+#include "Lib/WideCharFns.h"#include "GameClient/GameWindowTransitions.h"#include "GameLogic/GameLogic.h"@@ -229,6 +231,93 @@ void SetLobbyAttemptHostJoin(Bool start)s_tryingToHostOrJoin = start;}+/* -online scripting in the lobby, once per process each: -onlinesay says its line, -onlinehost asks for a+ staging room the way the host popup's createGame does (no password, no observers, unrated, no ladder),+ -onlinejoin joins the first listed game of that name the way the Join button does. */+static void onlineLobbyScript( void )+{+ static Bool s_said = FALSE, s_hosted = FALSE, s_joined = FALSE;+ if (!OnlineIsEnabled() || !TheGameSpyInfo->getCurrentGroupRoom() || s_tryingToHostOrJoin)+ return;++ if (!s_said && TheGlobalData->m_onlineSay.isNotEmpty())+ {+ s_said = TRUE;+ // straight to the queue: sendChat would drop the staging room's copy as a repeat of this one+ UnicodeString line;+ line.translate( TheGlobalData->m_onlineSay );+ PeerRequest req;+ req.peerRequestType = PeerRequest::PEERREQUEST_MESSAGEROOM;+ req.text = line.str();+ req.message.isAction = FALSE;+ TheGameSpyPeerMessageQueue->addRequest( req );+ DEBUG_LOG(("ONLINE SAY where=lobby text=%s\n", TheGlobalData->m_onlineSay.str()));+ }++ if (!s_hosted && TheGlobalData->m_onlineHostGame.isNotEmpty())+ {+ s_hosted = TRUE;+ SetLobbyAttemptHostJoin( TRUE );+ TheLobbyQueuedUTMs.clear();+ groupRoomToJoin = TheGameSpyInfo->getCurrentGroupRoom();+ TheGameSpyInfo->setCurrentGroupRoom(0);++ 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()));+ return;+ }++ if (!s_joined && TheGlobalData->m_onlineJoinGame.isNotEmpty())+ {+ UnicodeString wanted;+ wanted.translate( TheGlobalData->m_onlineJoinGame );+ StagingRoomMap *srm = TheGameSpyInfo->getStagingRoomList();+ for (StagingRoomMap::iterator it = srm->begin(); it != srm->end(); ++it)+ {+ GameSpyStagingRoom *room = it->second;+ if (!room || room->getGameName().compare( wanted ) != 0)+ continue;+ s_joined = TRUE;+ TheLobbyQueuedUTMs.clear();+ groupRoomToJoin = TheGameSpyInfo->getCurrentGroupRoom();+ TheGameSpyInfo->markAsStagingRoomJoiner( it->first );+ TheGameSpyGame->setGameName( room->getGameName() );+ TheGameSpyGame->setLadderIP( room->getLadderIP() );+ TheGameSpyGame->setLadderPort( room->getLadderPort() );+ SetLobbyAttemptHostJoin( TRUE );+ PeerRequest req;+ req.peerRequestType = PeerRequest::PEERREQUEST_JOINSTAGINGROOM;+ req.text = room->getGameName().str();+ req.stagingRoom.id = it->first;+ req.password = "";+ TheGameSpyPeerMessageQueue->addRequest( req );+ DEBUG_LOG(("ONLINE JOIN name=%s id=%d\n", TheGlobalData->m_onlineJoinGame.str(), it->first));+ break;+ }+ }+}+// Tooltips -------------------------------------------------------------------------------static void playerTooltip(GameWindow *window,@@ -957,6 +1046,8 @@ void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData)//buttonPushed = true;TheGameSpyInfo->setCurrentGroupRoom(resp.joinGroupRoom.id);TheGameSpyInfo->getPlayerInfoMap()->clear();+ if (OnlineIsEnabled())+ DEBUG_LOG(("ONLINE LOBBY joined room=%d\n", resp.joinGroupRoom.id));GroupRoomMap::iterator iter = TheGameSpyInfo->getGroupRoomList()->find(resp.joinGroupRoom.id);if (iter != TheGameSpyInfo->getGroupRoomList()->end()){@@ -1026,6 +1117,8 @@ void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData)break;case PeerResponse::PEERRESPONSE_MESSAGE:{+ if (OnlineIsEnabled())+ DEBUG_LOG(("ONLINE CHAT where=lobby from=%s text=%s\n", resp.nick.c_str(), WideCharAsUtf8( resp.text.c_str() ).str()));TheGameSpyInfo->addChat(resp.nick.c_str(), resp.message.profileID,UnicodeString(resp.text.c_str()), !resp.message.isPrivate, resp.message.isAction, listboxLobbyChat);}@@ -1047,6 +1140,8 @@ void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData){sawImportantMessage = TRUE;SetLobbyAttemptHostJoin(FALSE);+ if (OnlineIsEnabled())+ DEBUG_LOG(("ONLINE HOSTED result=%d\n", (Int)resp.createStagingRoom.result));if (resp.createStagingRoom.result == PEERJoinSuccess){// Woohoo! On to our next screen!@@ -1062,6 +1157,8 @@ void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData){sawImportantMessage = TRUE;SetLobbyAttemptHostJoin(FALSE);+ if (OnlineIsEnabled())+ DEBUG_LOG(("ONLINE JOINED ok=%d\n", (Int)resp.joinStagingRoom.ok));Bool isHostPresent = TRUE;if (resp.joinStagingRoom.ok == PEERTrue){@@ -1312,6 +1409,8 @@ void WOLLobbyMenuUpdate( WindowLayout * layout, void *userData)#elserefreshGameList();#endif+ if (!buttonPushed)+ onlineLobbyScript();}}// WOLLobbyMenuUpdatediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cppindex 9d0d86c16..816689c35 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLLoginMenu.cpp@@ -71,6 +71,8 @@#include "GameNetwork/GameSpy/PersistentStorageThread.h"#include "GameNetwork/GameSpyOverlay.h"+#include "GameNetwork/Online/OnlineQueues.h"+#include "GameNetwork/Transport.h"#include "GameNetwork/WOLBrowser/WebBrowser.h"@@ -297,6 +299,43 @@ AsciiStringList GameSpyLoginPreferences::getEmails( void )static const char *PREF_FILENAME = "GameSpyLogin.ini";static GameSpyLoginPreferences *loginPref = NULL;+/* -online. The login that went out: its email keys the remembered session token, and the relay+ handshake waits for this login's ticket, never one an earlier login left behind. */+static Bool s_rememberLogin = FALSE;+static Bool s_onlineLoginPending = FALSE;+static Bool s_onlineRelayTried = FALSE;+static AsciiString s_onlineLoginEmail;+static UnsignedByte s_onlineUsedTicket[16];++static void onlineLoginSent( const AsciiString &email, const char *how )+{+ s_onlineLoginPending = TRUE;+ s_onlineRelayTried = FALSE;+ s_onlineLoginEmail = email;+ DEBUG_LOG(("ONLINE LOGIN sent how=%s\n", how));+}++/// The UDP half of an -online login: HELLO_AUTH as soon as this login's ticket is in+static void onlineOpenRelayWhenTicketed( void )+{+ UnsignedByte ticket[16];+ if (!s_onlineLoginPending || s_onlineRelayTried || !OnlineGetRelayTicket( ticket )+ || memcmp( ticket, s_onlineUsedTicket, sizeof(ticket) ) == 0)+ return;+ memcpy( s_onlineUsedTicket, ticket, sizeof(ticket) );+ s_onlineRelayTried = TRUE;+ if (Transport::openOnlineRelay())+ {+ const UnsignedInt vip = Transport::getRelayIP();+ DEBUG_LOG(("ONLINE RELAY ok vip=%d.%d.%d.%d\n", vip >> 24, (vip >> 16) & 0xff, (vip >> 8) & 0xff, vip & 0xff));+ }+ else+ {+ DEBUG_LOG(("ONLINE RELAY fail\n")); // the login then times out and says it could not connect+ }+}++static void startPings( void ){std::list<AsciiString> pingServers = TheGameSpyConfig->getPingServers();@@ -789,18 +828,55 @@ static void checkLogin( void )}}+/* -onlineuser/-onlinepass/-onlineregister: fill the fields and press the button a player would, once per+ process; a refusal leaves the screen to a person. The birth date is any adult's: the service asks none. */+static void onlineAutoLogin( void )+{+ static Bool s_done = FALSE;+ if (s_done || !OnlineIsEnabled() || TheGlobalData->m_onlineUser.isEmpty() || loginAttemptTime+ || !comboBoxEmail || !comboBoxLoginName || !textEntryPassword || !parentWOLLogin)+ return;+ s_done = TRUE;++ const Bool registering = TheGlobalData->m_onlineRegisterNick.isNotEmpty();+ UnicodeString text;+ text.translate( TheGlobalData->m_onlineUser );+ GadgetComboBoxSetText( comboBoxEmail, text );+ text.translate( registering ? TheGlobalData->m_onlineRegisterNick : TheGlobalData->m_onlineUser );+ GadgetComboBoxSetText( comboBoxLoginName, text );+ text.translate( TheGlobalData->m_onlinePass );+ GadgetTextEntrySetText( textEntryPassword, text );+ if (textEntryMonth && textEntryDay && textEntryYear)+ {+ GadgetTextEntrySetText( textEntryMonth, UnicodeString(u"01") );+ GadgetTextEntrySetText( textEntryDay, UnicodeString(u"01") );+ GadgetTextEntrySetText( textEntryYear, UnicodeString(u"1990") );+ }+ if (checkBoxRememberPassword)+ GadgetCheckBoxSetChecked( checkBoxRememberPassword, TRUE );++ DEBUG_LOG(("ONLINE AUTOLOGIN %s\n", registering ? "register" : "login"));+ GameWindow *button = registering ? buttonCreateAccount : buttonLogin;+ const NameKeyType buttonID = registering ? buttonCreateAccountID : buttonLoginID;+ if (button)+ TheWindowManager->winSendSystemMsg( parentWOLLogin, GBM_SELECTED, (WindowMsgData)button, buttonID );+}+//-------------------------------------------------------------------------------------------------/** WOL Login Menu update method *///-------------------------------------------------------------------------------------------------void WOLLoginMenuUpdate( WindowLayout * layout, void *userData){- // We'll only be successful if we've requested to+ // We'll only be successful if we've requested toif(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished())shutdownComplete(layout);if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue){+ onlineAutoLogin();+ onlineOpenRelayWhenTicketed();+PingResponse pingResp;if (ThePinger && ThePinger->getResponse(pingResp)){@@ -840,10 +916,25 @@ void WOLLoginMenuUpdate( WindowLayout * layout, void *userData)GameSpyMiscPreferences miscPref;TheGameSpyInfo->setMaxMessagesPerUpdate(miscPref.getMaxMessagesPerUpdate());++ if (OnlineIsEnabled())+ {+ // the session token is what is remembered, never the password+ s_onlineLoginPending = FALSE;+ OnlineSaveToken( s_onlineLoginEmail, s_rememberLogin ? OnlineGetSessionToken() : AsciiString::TheEmptyString );+ const UnsignedInt vip = Transport::getRelayIP();+ DEBUG_LOG(("ONLINE LOGIN ok vip=%d.%d.%d.%d nick=%s\n", vip >> 24, (vip >> 16) & 0xff, (vip >> 8) & 0xff, vip & 0xff,+ resp.nick.c_str()));+ }}break;case PeerResponse::PEERRESPONSE_DISCONNECT:{+ if (OnlineIsEnabled())+ {+ s_onlineLoginPending = FALSE;+ DEBUG_LOG(("ONLINE LOGIN fail reason=%d\n", resp.discon.reason));+ }loginAttemptTime = 0;UnicodeString title, body;AsciiString disconMunkee;@@ -871,6 +962,11 @@ void WOLLoginMenuUpdate( WindowLayout * layout, void *userData){// timed out a login attempt, so say sologinAttemptTime = 0;+ if (OnlineIsEnabled())+ {+ s_onlineLoginPending = FALSE;+ DEBUG_LOG(("ONLINE LOGIN fail reason=timeout\n"));+ }UnicodeString title, body;AsciiString disconMunkee;disconMunkee.format("GUI:GSDisconReason4"); // ("could not connect to server")@@ -1272,11 +1368,11 @@ WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg,//TheGameSpyInfo->setLocalProfileID( resp.player.profileID );TheGameSpyInfo->setLocalEmail( email );TheGameSpyInfo->setLocalPassword( password );- DEBUG_LOG(("before create: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str()));TheGameSpyBuddyMessageQueue->addRequest( req );- if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword))- {+ s_rememberLogin = checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword);+ if(s_rememberLogin)+ {(*loginPref)["lastName"] = login;(*loginPref)["lastEmail"] = email;(*loginPref)["useProfiles"] = "yes";@@ -1285,8 +1381,11 @@ WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg,date.concat(day);date.concat(year);- loginPref->addLogin(email, login, password, date);+ // -online keeps the session token instead (OnlineSaveToken at login)+ loginPref->addLogin(email, login, OnlineIsEnabled() ? AsciiString::TheEmptyString : password, date);}+ if (OnlineIsEnabled())+ onlineLoginSent( email, "register" );EnableLoginControls( FALSE );@@ -1347,25 +1446,36 @@ WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg,login.translate( GadgetComboBoxGetText(comboBoxLoginName) );password.translate( GadgetTextEntryGetText(textEntryPassword) );- if ( !email.isEmpty() && !login.isEmpty() && !password.isEmpty() )+ // -online: an empty password with a remembered session token logs in with the token+ AsciiString token;+ if (OnlineIsEnabled() && password.isEmpty() && !email.isEmpty())+ token = OnlineGetSavedToken( email );++ if ( !email.isEmpty() && !login.isEmpty() && (!password.isEmpty() || token.isNotEmpty()) ){loginAttemptTime = Clock_Milliseconds();- BuddyRequest req;- req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGIN;- strcpy(req.arg.login.nick, login.str());- strcpy(req.arg.login.email, email.str());- strcpy(req.arg.login.password, password.str());- req.arg.login.hasFirewall = true;-TheGameSpyInfo->setLocalBaseName( login );//TheGameSpyInfo->setLocalProfileID( resp.player.profileID );TheGameSpyInfo->setLocalEmail( email );TheGameSpyInfo->setLocalPassword( password );- DEBUG_LOG(("before login: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str()));- TheGameSpyBuddyMessageQueue->addRequest( req );- if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword))- {+ if (token.isNotEmpty())+ {+ OnlineResume( token );+ }+ else+ {+ BuddyRequest req;+ req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGIN;+ strcpy(req.arg.login.nick, login.str());+ strcpy(req.arg.login.email, email.str());+ strcpy(req.arg.login.password, password.str());+ req.arg.login.hasFirewall = true;+ TheGameSpyBuddyMessageQueue->addRequest( req );+ }+ s_rememberLogin = checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword);+ if(s_rememberLogin)+ {(*loginPref)["lastName"] = login;(*loginPref)["lastEmail"] = email;(*loginPref)["useProfiles"] = "yes";@@ -1374,12 +1484,15 @@ WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg,date.concat(day);date.concat(year);- loginPref->addLogin(email, login, password,date);+ // -online keeps the session token instead (OnlineSaveToken at login)+ loginPref->addLogin(email, login, OnlineIsEnabled() ? AsciiString::TheEmptyString : password, date);}else{loginPref->forgetLogin(email);}+ if (OnlineIsEnabled())+ onlineLoginSent( email, token.isNotEmpty() ? "resume" : "login" );EnableLoginControls( FALSE );// fire off some pingsdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cppindex bfed9aafe..f266878f3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLQuickMatchMenu.cpp@@ -62,6 +62,7 @@#include "GameNetwork/NAT.h"#include "GameNetwork/GameSpyOverlay.h"+#include "GameNetwork/Online/OnlineQueues.h"#include "GameNetwork/GameSpy/BuddyDefs.h"#include "GameNetwork/GameSpy/GSConfig.h"#include "GameNetwork/GameSpy/PeerDefs.h"@@ -1103,6 +1104,16 @@ void WOLQuickMatchMenuUpdate( WindowLayout * layout, void *userData)}}+ // -quickmatch: press Start once per process, the queue's own button and settings+ static Bool s_onlineQueued = FALSE;+ if (OnlineIsEnabled() && TheGlobalData->m_quickMatchOnStart && !s_onlineQueued && !s_inQM+ && buttonStart && !buttonStart->winIsHidden() && buttonStart->winGetEnabled())+ {+ s_onlineQueued = TRUE;+ DEBUG_LOG(("ONLINE QUEUE start\n"));+ TheWindowManager->winSendSystemMsg( parentWOLQuickMatch, GBM_SELECTED, (WindowMsgData)buttonStart, buttonStartID );+ }+#ifdef PERF_TESTUnsignedInt start = Clock_Milliseconds();UnsignedInt end = Clock_Milliseconds();@@ -1356,6 +1367,19 @@ void WOLQuickMatchMenuUpdate( WindowLayout * layout, void *userData)}std::list<AsciiString> maps = TheGameSpyConfig->getQMMaps();+ if (OnlineIsEnabled())+ {+ // -online: mapIdx counts the service's whole pool, installed here or not+ for (std::list<AsciiString>::const_iterator it = maps.begin(); it != maps.end(); ++it)+ {+ if (resp.qmStatus.mapIdx-- == 0)+ {+ TheGameSpyGame->setMap(*it);+ break;+ }+ }+ maps.clear();+ }for (std::list<AsciiString>::const_iterator it = maps.begin(); it != maps.end(); ++it){AsciiString theMap = *it;@@ -1399,6 +1423,8 @@ void WOLQuickMatchMenuUpdate( WindowLayout * layout, void *userData)}DEBUG_LOG(("Starting a QM game: options=[%s]\n", GameInfoToAsciiString(TheGameSpyGame).str()));+ if (OnlineIsEnabled())+ DEBUG_LOG(("ONLINE MATCHED seed=%d players=%d map=%s\n", resp.qmStatus.seed, numPlayers, TheGameSpyGame->getMap().str()));SendStatsToOtherPlayers(TheGameSpyGame);TheGameSpyGame->startGame(0);GameWindow *buttonBuddies = TheWindowManager->winGetWindowFromId(NULL, buttonBuddiesID);@@ -1652,9 +1678,32 @@ WindowMsgHandledType WOLQuickMatchMenuSystem( GameWindow *window, UnsignedInt msreq.peerRequestType = PeerRequest::PEERREQUEST_STARTQUICKMATCH;req.qmMaps.clear();Int numMaps = GadgetListBoxGetNumEntries(listboxMapSelect);- for ( Int i=0; i<numMaps; ++i )+ if (OnlineIsEnabled())+ {+ // the service's qm.join maps index its whole pool, the welcome's <QMMaps>; a pool map+ // this machine does not list (not installed, too few seats) is a veto+ std::list<AsciiString> pool = TheGameSpyConfig->getQMMaps();+ for (std::list<AsciiString>::const_iterator it = pool.begin(); it != pool.end(); ++it)+ {+ Bool ticked = FALSE;+ for ( Int i=0; i<numMaps; ++i )+ {+ const MapMetaData *md = (const MapMetaData *)GadgetListBoxGetItemData(listboxMapSelect, i, 1);+ if (md && md->m_fileName.compareNoCase(*it) == 0)+ {+ ticked = GadgetListBoxGetItemData(listboxMapSelect, i, 0) != NULL;+ break;+ }+ }+ req.qmMaps.push_back(ticked);+ }+ }+ else{- req.qmMaps.push_back(GadgetListBoxGetItemData(listboxMapSelect, i, 0));+ for ( Int i=0; i<numMaps; ++i )+ {+ req.qmMaps.push_back(GadgetListBoxGetItemData(listboxMapSelect, i, 0));+ }}UnicodeString u;AsciiString a;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cppindex fd4c82347..75ac2090d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLWelcomeMenu.cpp@@ -69,6 +69,7 @@#include "GameNetwork/GameSpy/BuddyThread.h"#include "GameNetwork/GameSpy/ThreadUtils.h"#include "GameNetwork/GameSpy/MainMenuUtils.h"+#include "GameNetwork/Online/OnlineQueues.h"#include "GameNetwork/WOLBrowser/WebBrowser.h"#ifdef _INTERNAL@@ -513,13 +514,18 @@ void WOLWelcomeMenuInit( WindowLayout *layout, void *userData )buttonLadderID = TheNameKeyGenerator->nameToKey( AsciiString( "WOLWelcomeMenu.wnd:ButtonLadder" ) );buttonLadder = TheWindowManager->winGetWindowFromId( parentWOLWelcome, buttonLadderID );- if (TheFirewallHelper == NULL) {- TheFirewallHelper = createFirewallHelper();- }- if (TheFirewallHelper->detectFirewall() == TRUE) {- // don't need to detect firewall, already been done.- delete TheFirewallHelper;- TheFirewallHelper = NULL;+ // -online: every packet goes through our relay, so EA's firewall probe (against its dead mangler+ // servers) has nothing to find+ if (!OnlineIsEnabled())+ {+ if (TheFirewallHelper == NULL) {+ TheFirewallHelper = createFirewallHelper();+ }+ if (TheFirewallHelper->detectFirewall() == TRUE) {+ // don't need to detect firewall, already been done.+ delete TheFirewallHelper;+ TheFirewallHelper = NULL;+ }}/*@@ -670,6 +676,8 @@ void WOLWelcomeMenuUpdate( WindowLayout * layout, void *userData){//buttonPushed = TRUE;TheGameSpyInfo->setCurrentGroupRoom(resp.joinGroupRoom.id);+ if (OnlineIsEnabled())+ DEBUG_LOG(("ONLINE LOBBY joined room=%d\n", resp.joinGroupRoom.id));//GSMessageBoxOk( TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSGroupRoomJoinOK") );buttonPushed = TRUE;@@ -698,6 +706,28 @@ void WOLWelcomeMenuUpdate( WindowLayout * layout, void *userData)break;}}++ // -online scripting: once per process, the click a player would make next. -quickmatch opens Quick+ // Match; -onlinehost, -onlinejoin and -onlinesay go to the lobby, which carries them on.+ static Bool s_onlineAutoDone = FALSE;+ if (OnlineIsEnabled() && !s_onlineAutoDone && !buttonPushed && TheGameSpyInfo->gotGroupRoomList())+ {+ s_onlineAutoDone = TRUE;+ if (TheGlobalData->m_quickMatchOnStart)+ {+ DEBUG_LOG(("ONLINE WELCOME to=quickmatch\n"));+ buttonPushed = TRUE;+ nextScreen = "Menus/WOLQuickMatchMenu.wnd";+ TheShell->pop();+ }+ else if (TheGlobalData->m_onlineHostGame.isNotEmpty() || TheGlobalData->m_onlineJoinGame.isNotEmpty()+ || TheGlobalData->m_onlineSay.isNotEmpty())+ {+ DEBUG_LOG(("ONLINE WELCOME to=lobby\n"));+ TheGameSpyInfo->joinBestGroupRoom();+ enableControls( FALSE );+ }+ }}}// WOLWelcomeMenuUpdatediff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cppindex 8cb86cf8f..6bcd1e89b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp@@ -45,6 +45,10 @@#include "GameLogic/GameLogic.h"#include "GameNetwork/GameSpyOverlay.h"#include "GameNetwork/GameSpy/PeerDefsImplementation.h"+#include "GameNetwork/GameSpy/MainMenuUtils.h"+#include "GameNetwork/Online/OnlineQueues.h"++static Bool s_onlineOpened = FALSE; ///< -onlineuser opened the online screens once, at the first showShell#include <rts/profile.h>@@ -549,6 +553,14 @@ void Shell::showShell( Bool runInit )TheShell->push( AsciiString("Menus/LanLobbyMenu.wnd") );}+ /* -online with -onlineuser: what the main menu's Online button does, spent the same way. The login+ screen then logs in from the switches (WOLLoginMenu.cpp). */+ if( OnlineIsEnabled() && TheGlobalData->m_onlineUser.isNotEmpty() && !s_onlineOpened )+ {+ s_onlineOpened = TRUE;+ StartPatchCheck();+ }+// -skirmishlobby: the same trick for the single-player staging room, spent the same way.if( TheGlobalData->m_skirmishLobbyOnStart ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cppindex a7d666c1c..c8a573350 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp@@ -96,6 +96,10 @@#include "GameLogic/Object.h"#include "GameLogic/PartitionManager.h"#include "GameLogic/ScriptEngine.h" // For TheScriptEngine - jkmcd+#include "GameLogic/VictoryConditions.h"+#include "GameNetwork/GameSpy/StagingRoomGameInfo.h"+#include "GameNetwork/Online/OnlineQueues.h"+#include "GameNetwork/Transport.h"#ifdef _INTERNAL// for occasional debugging...//#pragma optimize("", off)@@ -625,6 +629,32 @@ void GameClient::registerDrawable( Drawable *draw )} // end registerDrawable+/** -----------------------------------------------------------------------------------------------+ * -online, once a client pass. The relay session gets its keepalive while the lobby has no Transport+ * to pump it, and a match's report goes out on the first pass after the match is decided, without+ * waiting for the score screen a player may never reach. Here, before prepareOverlap, no tick runs+ * beside it, so reading the victory conditions and the score keepers is safe.+ */+static void updateOnline( void )+{+ if (!OnlineIsEnabled())+ return;+ Transport::keepOnlineRelay();++ static Bool s_reported = FALSE;+ if (!TheGameLogic->isInGame() || TheGameLogic->getGameMode() != GAME_INTERNET+ || !TheGameSpyGame || !TheGameSpyGame->isGameInProgress())+ {+ s_reported = FALSE;+ return;+ }+ if (!s_reported && TheVictoryConditions && TheVictoryConditions->getEndFrame() > 0)+ {+ s_reported = TRUE;+ TheGameSpyGame->sendOnlineReport( "endframe" );+ }+}+/** -----------------------------------------------------------------------------------------------* Redraw all views, update the GUI, play sound effects, etc.*/@@ -633,6 +663,7 @@ DECLARE_PERF_TIMER(GameClient_draw)void GameClient::update( void ){USE_PERF_TIMER(GameClient_update)+ updateOnline();// create the FRAME_TICK messageGameMessage *frameMsg = TheMessageStream->appendMessage( GameMessage::MSG_FRAME_TICK );frameMsg->appendTimestampArgument( getFrame() );diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cppindex a03b8c56c..f9b8478c0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp@@ -61,6 +61,8 @@#include "GameNetwork/GameSpy/MainMenuUtils.h"#include "GameNetwork/GameSpy/PeerDefs.h"#include "GameNetwork/GameSpy/PeerThread.h"+#include "GameNetwork/Online/OnlineQueues.h"+#include "Lib/Clock.h"#include "WWDownload/Registry.h"#include "WWDownload/urlBuilder.h"@@ -109,6 +111,12 @@ enum {static void startOnline( void );static void reallyStartPatchCheck( void );+/* -online: no patch check and none of EA's HTTP. StartPatchCheck dials the service and HTTPThinkWrapper+ waits for its welcome, whose config (<QMMaps>) and MOTD stand in for the two files EA fetched. */+static Bool s_onlineWelcomeWait = FALSE;+static UnsignedInt s_onlineWelcomeSince = 0;+static const UnsignedInt ONLINE_WELCOME_TIMEOUT_MS = 15000;+///////////////////////////////////////////////////////////////////////////////////////// someone has hit a button allowing downloads to start@@ -633,6 +641,11 @@ void CancelPatchCheckCallbackAndReopenDropdown( void )void CancelPatchCheckCallback( void ){+ if (s_onlineWelcomeWait)+ {+ s_onlineWelcomeWait = FALSE;+ OnlineDisconnect();+ }s_asyncDNSLookupInProgress = FALSE;if (availableCheckInProgress){@@ -810,8 +823,55 @@ int asyncGethostbyname(char * szName)// time out) but at least we'll live.static Bool isHttpOk = TRUE;+/// -online: the welcome arrived, so the queues can be made and the login screen pushed+static void startOnlineService( void )+{+ checkingForPatchBeforeGameSpy = FALSE;+ if (onlineCancelWindow)+ {+ TheWindowManager->winDestroy(onlineCancelWindow);+ onlineCancelWindow = NULL;+ }+ TheScriptEngine->signalUIInteract(TheShellHookNames[SHELL_SCRIPT_HOOK_MAIN_MENU_ONLINE_SELECTED]);+ SetUpGameSpy( OnlineGetMOTD().str(), OnlineGetConfig().str() );+ DEBUG_LOG(("ONLINE CONNECT ok\n"));+ TheShell->push( AsciiString("Menus/GameSpyLoginProfile.wnd") );+}++static void onlineCannotConnect( void )+{+ HandleCanceledDownload();+}+void HTTPThinkWrapper( void ){+ if (s_onlineWelcomeWait)+ {+ OnlineUpdate();+ const OnlineStatus status = OnlineGetStatus();+ if (status == ONLINE_WELCOMED)+ {+ s_onlineWelcomeWait = FALSE;+ startOnlineService();+ }+ else if (status == ONLINE_FAILED || status == ONLINE_OFF+ || Clock_Milliseconds() - s_onlineWelcomeSince > ONLINE_WELCOME_TIMEOUT_MS)+ {+ s_onlineWelcomeWait = FALSE;+ checkingForPatchBeforeGameSpy = FALSE;+ OnlineDisconnect();+ if (onlineCancelWindow)+ {+ TheWindowManager->winDestroy(onlineCancelWindow);+ onlineCancelWindow = NULL;+ }+ DEBUG_LOG(("ONLINE CONNECT fail status=%d\n", (Int)status));+ MessageBoxOk(TheGameText->fetch("GUI:CannotConnectToServservTitle"),+ TheGameText->fetch("GUI:CannotConnectToServserv"), onlineCannotConnect);+ }+ return;+ }+if (s_asyncDNSLookupInProgress){Int ret = asyncGethostbyname("servserv.generals.ea.com");@@ -899,6 +959,15 @@ void StartPatchCheck( void )onlineCancelWindow = MessageBoxCancel(TheGameText->fetch("GUI:CheckingForPatches"),TheGameText->fetch("GUI:CheckingForPatches"), CancelPatchCheckCallbackAndReopenDropdown);+ // -online: dial our service instead of EA's patch, config and MOTD servers (HTTPThinkWrapper waits)+ if (OnlineIsEnabled())+ {+ s_onlineWelcomeWait = TRUE;+ s_onlineWelcomeSince = Clock_Milliseconds();+ OnlineUpdate();+ return;+ }+s_asyncDNSLookupInProgress = TRUE;Int ret = asyncGethostbyname("servserv.generals.ea.com");switch(ret)diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cppindex 85d97a505..834291230 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp@@ -50,6 +50,8 @@#include "GameNetwork/GameSpy/GSConfig.h"#include "GameNetwork/GameSpyOverlay.h"#include "GameNetwork/RankPointValue.h"+#include "GameNetwork/Transport.h"+#include "GameNetwork/Online/OnlineQueues.h"#include "GameLogic/GameLogic.h"#ifdef _INTERNAL@@ -632,13 +634,16 @@ void SetUpGameSpy( const char *motdBuffer, const char *configBuffer )dir.format("%sGeneralsOnline\\Ladders", TheGlobalData->getPath_UserData().str());TheLocalFileSystem->createDirectory(dir);- TheGameSpyBuddyMessageQueue = GameSpyBuddyMessageQueueInterface::createNewMessageQueue();+ // -online: the same four interfaces, answered from our service instead of GameSpy's threads+ const Bool online = OnlineIsEnabled();++ TheGameSpyBuddyMessageQueue = online ? OnlineCreateBuddyQueue() : GameSpyBuddyMessageQueueInterface::createNewMessageQueue();TheGameSpyBuddyMessageQueue->startThread();- TheGameSpyPeerMessageQueue = GameSpyPeerMessageQueueInterface::createNewMessageQueue();+ TheGameSpyPeerMessageQueue = online ? OnlineCreatePeerQueue() : GameSpyPeerMessageQueueInterface::createNewMessageQueue();TheGameSpyPeerMessageQueue->startThread();-- TheGameSpyPSMessageQueue = GameSpyPSMessageQueueInterface::createNewMessageQueue();++ TheGameSpyPSMessageQueue = online ? OnlineCreatePSQueue() : GameSpyPSMessageQueueInterface::createNewMessageQueue();TheGameSpyPSMessageQueue->startThread();/*@@ -658,7 +663,7 @@ void SetUpGameSpy( const char *motdBuffer, const char *configBuffer )TheLadderList = NEW LadderList;- ThePinger = PingerInterface::createNewPingerInterface();+ ThePinger = online ? OnlineCreatePinger() : PingerInterface::createNewPingerInterface();ThePinger->startThreads();TheRankPointValues = NEW RankPoints;@@ -681,6 +686,9 @@ void TearDownGameSpy( void )// */}+ // -online: the relay session belongs to the login being torn down+ Transport::closeOnlineRelay();+// End our threads before we kill off the singletons they reference. No crashy-crash for you!if (TheGameSpyPSMessageQueue)TheGameSpyPSMessageQueue->endThread();diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cppindex 4688b5d13..119c7c156 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp@@ -50,6 +50,7 @@#include "GameNetwork/GameSpyOverlay.h"#include "GameNetwork/NAT.h"#include "GameNetwork/NetworkInterface.h"+#include "GameNetwork/Online/OnlineQueues.h"#ifdef _INTERNAL// for occasional debugging...@@ -603,6 +604,26 @@ void GameSpyStagingRoom::startGame(Int gameID)}}+ /* -online: every machine is a relay vip already (the login's relay.ok gave ours, the server's player+ records gave the others'), so there is no path to negotiate. Every copy uses the game's own+ logical port, the one launchGame binds without a NAT. */+ if (OnlineIsEnabled())+ {+ for (Int i=0; i<MAX_SLOTS; ++i)+ {+ if (m_GameSpySlot[i].isHuman())+ {+ m_GameSpySlot[i].setPort(8888);+ const UnsignedInt ip = m_GameSpySlot[i].getIP();+ DEBUG_LOG(("ONLINE LAUNCH slot=%d vip=%d.%d.%d.%d\n", i, ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff));+ }+ }+ launchGame();+ if (TheGameSpyInfo)+ TheGameSpyInfo->leaveStagingRoom();+ return;+ }+//#if defined(_DEBUG) || defined(_INTERNAL)if (numHumans < 2){@@ -751,9 +772,10 @@ AsciiString GameSpyStagingRoom::generateLadderGameResultsPacket( void )}AsciiString results;- results.format("seed=%d,slotNum=%d,sawDesync=%d,sawGameEnd=%d,winningTeam=%d,disconEnd=%d,duration=%d,numPlayers=%d,isQM=%d,map=%s",+ // endFrame is duration again under its own name: the online service compares it across reports+ results.format("seed=%d,slotNum=%d,sawDesync=%d,sawGameEnd=%d,winningTeam=%d,disconEnd=%d,duration=%d,endFrame=%d,numPlayers=%d,isQM=%d,map=%s",getSeed(), localSlotNum, TheNetwork->sawCRCMismatch(), sawGameEnd, winningTeam, (numTeamsAtGameEnd < 2),- endFrame, numPlayers, m_isQM, TheGameState->realMapPathToPortableMapPath(getMap()).str());+ endFrame, endFrame, numPlayers, m_isQM, TheGameState->realMapPathToPortableMapPath(getMap()).str());AsciiString tempStr;tempStr.format("ladderIP=%s,ladderPort=%d", getLadderIP().str(), getLadderPort());@@ -810,6 +832,49 @@ AsciiString GameSpyStagingRoom::generateLadderGameResultsPacket( void )return results;}+/* -online: the ladder packet's fields as OnlineSendReport takes them. The players are the human seats in+ slot order, which is the match's player order on the server (a Quick Match seats the matched ids in+ order), so winningTeam is the winner's index among them rather than EA's team number. The service sends+ a match's report once however often this runs; `from` only names the caller in the log. */+void GameSpyStagingRoom::sendOnlineReport( const char *from )+{+ if (!OnlineIsEnabled() || !TheVictoryConditions || !TheNetwork)+ return;+ OnlineReport report;+ report.seed = getSeed();+ report.endFrame = (Int)TheVictoryConditions->getEndFrame();+ report.duration = report.endFrame;+ report.sawGameEnd = report.endFrame > 0;+ report.sawDesync = TheNetwork->sawCRCMismatch();+ report.surrendered = FALSE; // a surrender is a defeat here, and the winner already says so+ report.winningTeam = -1;+ report.numPlayers = 0;+ Int teamsLeft = 0;+ Int lastTeam = -1;+ for (Int i = 0; i < MAX_SLOTS; ++i)+ {+ AsciiString playerName;+ playerName.format("player%d", i);+ Player *p = ThePlayerList->findPlayerWithNameKey(NAMEKEY(playerName));+ if (!p || !m_GameSpySlot[i].isHuman())+ continue;+ const Int n = report.numPlayers++;+ if (report.winningTeam < 0 && TheVictoryConditions->hasAchievedVictory(p))+ report.winningTeam = n;+ report.discon[n] = m_GameSpySlot[i].disconnected();+ report.side[n] = p->getPlayerTemplate()->getSide();+ if (!report.discon[n] && (teamsLeft == 0 || m_GameSpySlot[i].getTeamNumber() != lastTeam))+ {+ lastTeam = m_GameSpySlot[i].getTeamNumber();+ ++teamsLeft;+ }+ }+ report.disconEnd = teamsLeft < 2;+ OnlineSendReport( report );+ DEBUG_LOG(("ONLINE REPORT sent from=%s seed=%d endFrame=%d winner=%d desync=%d\n", from, report.seed,+ report.endFrame, report.winningTeam, (Int)report.sawDesync));+}+void GameSpyStagingRoom::launchGame( void ){setGameInProgress(TRUE);diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cppindex 4e7792c13..f392d1cb0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp@@ -33,6 +33,7 @@#include "GameNetwork/Transport.h"#include "GameNetwork/NetworkInterface.h"#include "Common/UserPreferences.h"+#include "GameNetwork/Online/OnlineQueues.h"#include <chrono>#include <thread>@@ -98,12 +99,19 @@ static inline void decryptBuf( unsigned char *buf, Int len )with no address before SetLocalIP picks one. The ports are the logical ones (the lobby's 8086,the game's 8088): a received DATA is handed to whichever Transport holds dstPort, with the sender'svip and port as its address, so LANAPI and ConnectionManager see a LAN where every machine is a- vip and a broadcast is dstVip 255.255.255.255. Nothing here touches the game logic. */+ vip and a broadcast is dstVip 255.255.255.255. Nothing here touches the game logic.++ -online uses the same socket with HELLO_AUTH (type 4) in place of HELLO: the header above, then the+ 16-byte ticket the service handed out at login, then the name (left empty: the service knows the+ account). openOnlineRelay() makes the handshake right after login, against OnlineGetRelayEndpoint,+ so the vip exists before any Transport does; keepOnlineRelay() sends the keepalive while the lobby+ has no Transport to pump. */namespace{- enum { RELAY_HELLO = 1, RELAY_WELCOME = 2, RELAY_DATA = 3 };+ enum { RELAY_HELLO = 1, RELAY_WELCOME = 2, RELAY_DATA = 3, RELAY_HELLO_AUTH = 4 };const Int RELAY_MAX_PACKET = 1400;const Int RELAY_SESSION_BYTES = 8;+ const Int RELAY_TICKET_BYTES = 16;const Int RELAY_HELLO_HEADER = 23; ///< 'ZR', type, exeCRC, iniCRC, session, wantVipconst Int RELAY_WELCOME_SIZE = 15; ///< 'ZR', type, session, vipconst Int RELAY_DATA_OUT_HEADER = 19; ///< 'ZR', type, session, dstVip, dstPort, srcPort@@ -125,6 +133,8 @@ namespaceUnsignedInt lastHello;UnsignedInt failedAt;Bool wsaStarted;+ Bool authed; ///< -online: every hello is a HELLO_AUTH carrying ticket+ unsigned char ticket[RELAY_TICKET_BYTES];Int nameLength;unsigned char name[RELAY_NAME_BYTES];Transport *users[RELAY_MAX_TRANSPORTS];@@ -171,14 +181,21 @@ namespacevoid relaySendHello( void ){- unsigned char buf[RELAY_HELLO_HEADER + RELAY_NAME_BYTES];- buf[0] = 'Z'; buf[1] = 'R'; buf[2] = RELAY_HELLO;+ unsigned char buf[RELAY_HELLO_HEADER + RELAY_TICKET_BYTES + RELAY_NAME_BYTES];+ buf[0] = 'Z'; buf[1] = 'R'; buf[2] = s_relay.authed ? RELAY_HELLO_AUTH : RELAY_HELLO;put32( buf + 3, TheGlobalData->m_exeCRC );put32( buf + 7, TheGlobalData->m_iniCRC );memcpy( buf + 11, s_relay.session, RELAY_SESSION_BYTES );put32( buf + 19, s_relay.wantVip );- memcpy( buf + RELAY_HELLO_HEADER, s_relay.name, s_relay.nameLength );- s_relay.sock->Write( buf, RELAY_HELLO_HEADER + s_relay.nameLength, s_relay.ip, s_relay.port );+ Int len = RELAY_HELLO_HEADER;+ if (s_relay.authed)+ {+ memcpy( buf + len, s_relay.ticket, RELAY_TICKET_BYTES );+ len += RELAY_TICKET_BYTES;+ }+ memcpy( buf + len, s_relay.name, s_relay.nameLength );+ len += s_relay.nameLength;+ s_relay.sock->Write( buf, len, s_relay.ip, s_relay.port );s_relay.lastHello = Clock_Milliseconds();}}@@ -237,68 +254,121 @@ void Transport::pumpRelay( void )}}-/// Joins the relay socket, opening it and waiting for a WELCOME (at most five seconds) the first time-Bool Transport::initRelayed( UnsignedInt ip, UnsignedShort port )+/// Opens the relay socket and waits for a WELCOME (at most five seconds); s_relay.wantVip and authed are the caller's+Bool Transport::connectRelay( const AsciiString &host, UnsignedShort relayPort ){- if (!s_relay.vip)+ if (s_relay.failedAt && Clock_Milliseconds() - s_relay.failedAt < RELAY_RETRY_AFTER_MS)+ return false;+#if defined(_WIN32)+ // the relay socket outlives every Transport, so it keeps winsock up by itself+ if (!s_relay.wsaStarted){- s_relay.wantVip = (ip >> 24) == 10 ? ip : 0;- if (s_relay.failedAt && Clock_Milliseconds() - s_relay.failedAt < RELAY_RETRY_AFTER_MS)+ WSADATA wsadata;+ if (WSAStartup( MAKEWORD(2, 2), &wsadata ) != 0)return false;-#if defined(_WIN32)- // the relay socket outlives every Transport, so it keeps winsock up by itself- if (!s_relay.wsaStarted)- {- WSADATA wsadata;- if (WSAStartup( MAKEWORD(2, 2), &wsadata ) != 0)- return false;- s_relay.wsaStarted = true;- }+ s_relay.wsaStarted = true;+ }#endif- s_relay.ip = ResolveIP( TheGlobalData->m_relayHost );- s_relay.port = TheGlobalData->m_relayPort;- if (s_relay.ip == 0 || s_relay.ip == INADDR_NONE || s_relay.port == 0)+ s_relay.ip = ResolveIP( host );+ s_relay.port = relayPort;+ if (s_relay.ip == 0 || s_relay.ip == INADDR_NONE || s_relay.port == 0)+ {+ DEBUG_LOG(("Transport: relay %s:%d does not resolve to an address and port\n", host.str(), relayPort));+ s_relay.failedAt = Clock_Milliseconds();+ return false;+ }+ if (!s_relay.sock)+ {+ s_relay.sock = NEW UDP();+ if (s_relay.sock->Bind( (UnsignedInt)INADDR_ANY, 0 ) != 0){- DEBUG_LOG(("Transport: -relay %s:%d does not resolve to an address and port\n", TheGlobalData->m_relayHost.str(), TheGlobalData->m_relayPort));+ DEBUG_LOG(("Transport: no socket for the relay (error %d)\n", lastSocketError()));+ delete s_relay.sock;+ s_relay.sock = NULL;s_relay.failedAt = Clock_Milliseconds();return false;}- if (!s_relay.sock)+ }+ const UnsignedInt asked = s_relay.wantVip;+ for (Int tries = 0; tries < RELAY_HELLO_TRIES && !s_relay.vip; ++tries)+ {+ relaySendHello();+ for (Int wait = 0; wait < 10 && !s_relay.vip; ++wait){- s_relay.sock = NEW UDP();- if (s_relay.sock->Bind( (UnsignedInt)INADDR_ANY, 0 ) != 0)- {- DEBUG_LOG(("Transport: no socket for the relay (error %d)\n", lastSocketError()));- delete s_relay.sock;- s_relay.sock = NULL;- s_relay.failedAt = Clock_Milliseconds();- return false;- }+ std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );+ pumpRelay();}+ }+ if (!s_relay.vip)+ {+ DEBUG_LOG(("Transport: no WELCOME from the relay at %d.%d.%d.%d:%d in five seconds\n",+ s_relay.ip >> 24, (s_relay.ip >> 16) & 0xff, (s_relay.ip >> 8) & 0xff, s_relay.ip & 0xff, s_relay.port));+ s_relay.failedAt = Clock_Milliseconds();+ return false;+ }+ relaySendHello(); // answers the WELCOME with its session, after which the relay forwards to us+ DEBUG_LOG(("Transport: the relay calls us %d.%d.%d.%d\n",+ s_relay.vip >> 24, (s_relay.vip >> 16) & 0xff, (s_relay.vip >> 8) & 0xff, s_relay.vip & 0xff));+ // a -netgame slot that did not get its address hears nobody, and the match never starts+ DEBUG_ASSERTLOG( !asked || s_relay.vip == asked, ("Transport: asked the relay for %d.%d.%d.%d, which another session holds\n",+ asked >> 24, (asked >> 16) & 0xff, (asked >> 8) & 0xff, asked & 0xff) );+ return true;+}++/// -online: the HELLO_AUTH handshake with the ticket of the login that just succeeded+Bool Transport::openOnlineRelay( void )+{+ AsciiString host;+ UnsignedShort relayPort = 0;+ if (!OnlineGetRelayTicket( s_relay.ticket ) || !OnlineGetRelayEndpoint( host, relayPort ))+ return false;+ closeOnlineRelay(); // a second login gets a new session from a new ticket+ s_relay.authed = true;+ s_relay.wantVip = 0;+ s_relay.failedAt = 0; // a login is a person asking; do not hold the last failure against it+ s_relay.nameLength = 0;+ return connectRelay( host, relayPort );+}++/// -online: the relay keepalive while the lobby and staging room have no Transport to pump it+void Transport::keepOnlineRelay( void )+{+ if (s_relay.authed)+ pumpRelay();+}++/// -online: forgets the session, so the next login starts clean. Transports still attached keep their slot.+void Transport::closeOnlineRelay( void )+{+ if (!s_relay.authed)+ return;+ for (Int u = 0; u < RELAY_MAX_TRANSPORTS; ++u)+ {+ if (s_relay.users[u])+ return; // a match still runs on it+ }+ if (s_relay.sock)+ {+ delete s_relay.sock;+ s_relay.sock = NULL;+ }+ memset( s_relay.session, 0, RELAY_SESSION_BYTES );+ s_relay.vip = 0;+ s_relay.wantVip = 0;+ s_relay.authed = false;+}++/// Joins the relay socket, opening it and waiting for a WELCOME (at most five seconds) the first time+Bool Transport::initRelayed( UnsignedInt ip, UnsignedShort port )+{+ if (!s_relay.vip)+ {+ if (s_relay.authed)+ return false; // -online: the login's handshake failed or the session was closed+ s_relay.wantVip = (ip >> 24) == 10 ? ip : 0;relayTakeName();- const UnsignedInt asked = s_relay.wantVip;- for (Int tries = 0; tries < RELAY_HELLO_TRIES && !s_relay.vip; ++tries)- {- relaySendHello();- for (Int wait = 0; wait < 10 && !s_relay.vip; ++wait)- {- std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );- pumpRelay();- }- }- if (!s_relay.vip)- {- DEBUG_LOG(("Transport: no WELCOME from the relay at %d.%d.%d.%d:%d in five seconds\n",- s_relay.ip >> 24, (s_relay.ip >> 16) & 0xff, (s_relay.ip >> 8) & 0xff, s_relay.ip & 0xff, s_relay.port));- s_relay.failedAt = Clock_Milliseconds();+ if (!connectRelay( TheGlobalData->m_relayHost, TheGlobalData->m_relayPort ))return false;- }- relaySendHello(); // answers the WELCOME with its session, after which the relay forwards to us- DEBUG_LOG(("Transport: the relay calls us %d.%d.%d.%d\n",- s_relay.vip >> 24, (s_relay.vip >> 16) & 0xff, (s_relay.vip >> 8) & 0xff, s_relay.vip & 0xff));- // a -netgame slot that did not get its address hears nobody, and the match never starts- DEBUG_ASSERTLOG( !asked || s_relay.vip == asked, ("Transport: asked the relay for %d.%d.%d.%d, which another session holds\n",- asked >> 24, (asked >> 16) & 0xff, (asked >> 8) & 0xff, asked & 0xff) );}for (Int u = 0; u < RELAY_MAX_TRANSPORTS; ++u)@@ -373,7 +443,8 @@ Bool Transport::init( AsciiString ip, UnsignedShort port )Bool Transport::init( UnsignedInt ip, UnsignedShort port ){detachRelay();- if (TheGlobalData->m_relayHost.isNotEmpty())+ // -relay, or an -online login whose relay handshake went through (openOnlineRelay)+ if (TheGlobalData->m_relayHost.isNotEmpty() || s_relay.authed){m_redirectedIP = 0;if (m_udpsock)