| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /******************************************************************************
- *
- * NAME
- * $Archive: /Commando/Code/Commando/DlgMPConnect.cpp $
- *
- * DESCRIPTION
- * Dialog to inform user that we are connecting to a game host.
- *
- * PROGRAMMER
- * Denzil E. Long, Jr.
- * $Author: Tom_s $
- *
- * VERSION INFO
- * $Revision: 12 $
- * $Modtime: 2/25/02 11:29a $
- *
- ******************************************************************************/
- #include "dlgmpconnect.h"
- #include "gamedata.h"
- #include "gameinitmgr.h"
- #include "campaign.h"
- #include "cnetwork.h"
- #include "resource.h"
- #include <wwdebug\wwdebug.h>
- #include "dlgmainmenu.h"
- #include "gamespyadmin.h"
- #include "specialbuilds.h"
- #include "dialogtests.h"
- #include "dialogmgr.h"
- #include "gamemode.h"
- #include "langmode.h"
- #include "wolgmode.h"
- /******************************************************************************
- *
- * NAME
- * DlgMPConnect::DoDialog
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * True if dialog created successfully.
- *
- ******************************************************************************/
- bool DlgMPConnect::DoDialog(int teamChoice, unsigned long clanID)
- {
- DlgMPConnect* popup = new DlgMPConnect(teamChoice, clanID);
- if (popup)
- {
- popup->Start_Dialog();
- popup->Release_Ref();
- }
- return (popup != NULL);
- }
- /******************************************************************************
- *
- * NAME
- * DlgMPConnect::DlgMPConnect
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgMPConnect::DlgMPConnect(int teamChoice, unsigned long clanID) :
- PopupDialogClass(IDD_MULTIPLAY_CONNECTING),
- mTeamChoice(teamChoice),
- mClanID(clanID),
- mTheGame(NULL),
- mFailed(false)
- {
- WWDEBUG_SAY(("DlgMPConnect: Instantiated\n"));
- }
- /******************************************************************************
- *
- * NAME
- * DlgMPConnect::~DlgMPConnect
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- DlgMPConnect::~DlgMPConnect()
- {
- WWDEBUG_SAY(("DlgMPConnect: Destructing\n"));
- }
- /******************************************************************************
- *
- * NAME
- * DlgMPConnect::Connected
- *
- * DESCRIPTION
- * Handle connection.
- *
- * INPUTS
- * GameData - Pointer to game data instance
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgMPConnect::Connected(cGameData* theGame)
- {
- mTheGame = theGame;
- }
- /******************************************************************************
- *
- * NAME
- * DlgMPConnect::Connected
- *
- * DESCRIPTION
- * Handle connection.
- *
- * INPUTS
- * GameData - Pointer to game data instance
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgMPConnect::Failed_To_Connect(void)
- {
- mFailed = true;
- }
- /******************************************************************************
- *
- * NAME
- * DlgMPConnect::On_Command
- *
- * DESCRIPTION
- * Process command messages from controls
- *
- * INPUTS
- * Ctrl - ID of control
- * Message -
- * Param - 0 = User invoked abort. 1 = Connection refused by server.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgMPConnect::On_Command(int ctrlID, int message, DWORD param)
- {
- if ((IDCANCEL == ctrlID) && (1 != param))
- {
- if (cNetwork::I_Am_Client())
- {
- cNetwork::Cleanup_Client();
- }
- if (cGameSpyAdmin::Get_Is_Launched_From_Gamespy())
- {
- extern void Stop_Main_Loop (int);
- Stop_Main_Loop(EXIT_SUCCESS);
- }
- else if (DialogMgrClass::Get_Dialog_Count () == 1)
- {
- START_DIALOG (MainMenuDialogClass);
- }
- }
- PopupDialogClass::On_Command(ctrlID, message, param);
- }
- /******************************************************************************
- *
- * NAME
- * DlgMPConnect::On_Periodic
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void DlgMPConnect::On_Periodic(void)
- {
- PopupDialogClass::On_Periodic();
- if (mTheGame != NULL)
- {
- // Add a reference to keep us alive while we process the game start
- Add_Ref();
- // Remove the dialog from menuing system
- End_Dialog();
- // Check to ensure the settings are playable
- WideStringClass outMsg;
- if (mTheGame->Is_Valid_Settings(outMsg))
- {
- WWDEBUG_SAY(("DlgMPConnect: Starting the game.\n"));
- CampaignManager::Select_Backdrop_Number_By_MP_Type(mTheGame->Get_Game_Type());
- // Start the game!
- GameInitMgrClass::Set_Is_Client_Required(true);
- GameInitMgrClass::Set_Is_Server_Required(false);
- GameInitMgrClass::Start_Game(mTheGame->Get_Map_Name(), mTeamChoice, mClanID);
- }
- else
- {
- WWDEBUG_SAY(("ERROR: %s\n", (const WCHAR*)outMsg));
- }
- // Release the keep alive reference (this will delete this object)
- Release_Ref();
- }
- else
- {
- if (mFailed)
- {
- Add_Ref();
- // Remove the dialog from menuing system
- End_Dialog();
- if (GameModeManager::Find("LAN")->Is_Active())
- {
- PLC->Refusal_Actions();
- }
- else
- {
- GameModeClass* gameMode = GameModeManager::Find("WOL");
- if (gameMode && gameMode->Is_Active())
- {
- WolGameModeClass* wolGame = static_cast<WolGameModeClass*>(gameMode);
- WWASSERT(wolGame);
- wolGame->Refusal_Actions();
- }
- }
- Release_Ref();
- }
- }
- }
|