Пример #1
0
uint32 CScreenJoin::HandleCallback(uint32 dwParam1, uint32 dwParam2)
{
	switch (dwParam2)
	{
		case CMD_JOIN :
		{
			JoinCurGame();
			break;
		}
		case CMD_EDIT_CDKEY :
		{
			IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
			if (!pServerDir->SetCDKey((const char *)dwParam1))
			{
				// Tell them that's a bad CD key and exit this screen
				// NYI
				ChangeState(eState_Error);
			}
			else
			{
				m_sCurCDKey = ((const char *)dwParam1);
				m_pCDKeyCtrl->SetString(1,m_sCurCDKey.c_str());
				pServerDir->QueueRequest(IServerDirectory::eRequest_Validate_CDKey);
			}
			break;
		}
	}
	ChangeState(eState_Waiting);
	return 1;
}
Пример #2
0
void CScreenJoin::Update_State_UpdateDir()
{
	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();

	// Are we still waiting?
	switch (pServerDir->GetCurStatus())
	{
		case IServerDirectory::eStatus_Processing : 
			return;
		case IServerDirectory::eStatus_Waiting : 
		{
			// Go back to waiting
			ChangeState(eState_Waiting);
			break;
		}
		case IServerDirectory::eStatus_Error : 
{
			// Whoops, something went wrong.
			// Drop out of this screen with an error
			// NYI
			break;
		}
		default :
	{
			ASSERT(!"Unknown directory status encountered");
			ChangeState(eState_Waiting);
			break;
		}
	}
}
Пример #3
0
void CScreenJoin::FindServers()
{
	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
	if (pServerDir->IsRequestPending(IServerDirectory::eRequest_Update_List))
		return;

	ChangeState(eState_UpdateDir);
}
Пример #4
0
bool CScreenJoin::PreState_UpdateDir()
{
	m_pFindCtrl->Enable(LTFALSE);

	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();

	pServerDir->ClearPeerList();
	if (!pServerDir->QueueRequest(IServerDirectory::eRequest_Update_List))
		return false;

	return true;
}
Пример #5
0
bool CScreenJoin::PreState_QueryDetails()
{
	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();

	// Get the active server
	if (m_nSelectedServer >= m_cServerList.size())
		return true;
	pServerDir->SetActivePeer(m_cServerList[m_nSelectedServer].m_sAddress.c_str());

	if (!pServerDir->QueueRequest(IServerDirectory::eRequest_Peer_Details))
		return true;

	return true;
}
Пример #6
0
bool CScreenJoin::PreState_Inactive()
{
	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();

	// Make sure we're not doing anything...
	pServerDir->ClearRequestList();

	// Make sure we don't have anything lying around...
	m_pServerListCtrl->RemoveAll();

	// Disable the "Find servers" control
	m_pFindCtrl->Enable(LTFALSE);

	return true;
}
Пример #7
0
void CScreenJoin::Update_State_Startup()
{
	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();

	// Are we still waiting?
	switch (pServerDir->GetCurStatus())
	{
		case IServerDirectory::eStatus_Processing : 
			return;
		case IServerDirectory::eStatus_Waiting : 
		{
			// Display the MOTD if it's new
			// NYI

			// Display a version warning/error if we're out of date
			// NYI

			// Update the directory list
			ChangeState(eState_UpdateDir);
			break;
		}
		case IServerDirectory::eStatus_Error : 
		{
			// Ignore errors in the MOTD/Version queries for now...
			// NYI
			IServerDirectory::ERequest eErrorRequest = pServerDir->GetLastErrorRequest();
			if ((eErrorRequest == IServerDirectory::eRequest_MOTD) || 
				(eErrorRequest == IServerDirectory::eRequest_Version))
			{
				pServerDir->ProcessRequestList();
				break;
			}

			// Whoops, something went wrong.
			// Drop out of this screen with an error
			// NYI
			break;
		}
		default :
{
			ASSERT(!"Unknown directory status encountered");
			ChangeState(eState_Waiting);
			break;
		}
	}
}
Пример #8
0
void CScreenJoin::ReadCurServerList()
{
	m_nSelectedServer = 0;

	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
	IServerDirectory::TPeerList cPeers = pServerDir->GetPeerList();
	m_cServerList.resize(cPeers.size());
	IServerDirectory::TPeerList::const_iterator iCurPeer = cPeers.begin();
	TServerList::iterator iCurServer = m_cServerList.begin();
	for (; iCurPeer != cPeers.end(); ++iCurPeer, ++iCurServer)
	{
		// Indicate that the server's an invalid entry until we get everything..
		iCurServer->m_sAddress.clear();

		char aStringBuffer[256];
	
		// Point at this server
		if (!pServerDir->SetActivePeer(iCurPeer->c_str()))
			continue;

		// Read the name
		CAutoMessage cMsg;
		if (!pServerDir->GetActivePeerInfo(IServerDirectory::ePeerInfo_Name, cMsg))
			continue;
		{
			CLTMsgRef_Read cRead(cMsg.Read());
			cRead->ReadString(aStringBuffer, sizeof(aStringBuffer));
		}
		iCurServer->m_sName = aStringBuffer;

		// Read the summary
		if (!pServerDir->GetActivePeerInfo(IServerDirectory::ePeerInfo_Summary, cMsg))
			continue;
		{
			CLTMsgRef_Read cRead(cMsg.Read());
			cRead->ReadString(aStringBuffer, sizeof(aStringBuffer));
			iCurServer->m_sMap = aStringBuffer;
			iCurServer->m_nNumPlayers = cRead->Readuint8();
			iCurServer->m_nMaxPlayers = cRead->Readuint8();
		}

		// Ok, this one's valid
		iCurServer->m_sAddress = *iCurPeer;
	}
}
Пример #9
0
bool CScreenJoin::PreState_Startup()
{
	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
	// Make a serverdir if we don't have one
	// Note : Find a way to put this back in the game client shell!!!  It has to be
	// here right now so that we can delete it when we start up a server..
	// NYI NYI NYI
	if (!pServerDir)
	{
		pServerDir = Factory_Create_IServerDirectory_Titan();
		g_pClientMultiplayerMgr->SetServerDir(pServerDir);
		// Set the game's name
		pServerDir->SetGameName("TheOperative2");
		// Set the version
		pServerDir->SetVersion(g_pVersionMgr->GetBuild());
		// Set up the packet header
		CAutoMessage cMsg;
		cMsg.Writeuint8(11); // CMSG_MESSAGE
		cMsg.Writeuint8(MID_MULTIPLAYER_SERVERDIR);
		pServerDir->SetNetHeader(*cMsg.Read());
	}

	// Load the default CD key
	if (pServerDir->GetCDKey(&m_sCurCDKey))
		m_pCDKeyCtrl->SetString(1,m_sCurCDKey.c_str());

	bool bResult = true;
	bResult &= pServerDir->QueueRequest(IServerDirectory::eRequest_MOTD);
	bResult &= pServerDir->QueueRequest(IServerDirectory::eRequest_Version);
	if (!bResult)
	{
		ChangeState(eState_Error);
		return false;
	}

	// Set the CD key
	pServerDir->SetCDKey(m_sCurCDKey.c_str());

	bResult &= pServerDir->QueueRequest(IServerDirectory::eRequest_Validate_CDKey);
	if (!bResult)
	{
		ChangeState(eState_ChangeCDKey);
		return false;
	}

	return bResult;
}
Пример #10
0
uint32 CScreenMulti::HandleCallback(uint32 dwParam1, uint32 dwParam2)
{
	switch (dwParam2)
	{
		case CMD_UPDATE:
		{
			//following notification of new version, continue validation process
			RequestValidate();
		} break;

		case CMD_EDIT_CDKEY :
		{
			IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
			if (pServerDir->SetCDKey((const char *)dwParam1))
			{
				m_sCurCDKey = ((const char *)dwParam1);
				pServerDir->SetCDKey(m_sCurCDKey.c_str());

				bool bResult = pServerDir->QueueRequest(IServerDirectory::eRequest_Validate_CDKey);
				if (bResult)
				{
					g_pLTClient->CPrint( "QueueRequest(IServerDirectory::eRequest_Validate_CDKey)");
					m_pCDKeyCtrl->SetString(1,m_sCurCDKey.c_str());
					m_eCurState = eState_ValidateCDKey;
					m_pWait->Show(LTTRUE);
					SetCapture(m_pWait);
				}

			}
			if (m_eCurState != eState_ValidateCDKey)
			{
				MBCreate mb;
				g_pInterfaceMgr->ShowMessageBox(IDS_CDKEY_INVALID,&mb);

				std::string str = pServerDir->GetLastRequestResultString( );
				g_pLTClient->CPrint( "CDKey validation error: %s", str.c_str( ));


				m_pWait->Show(LTFALSE);
				if (GetCapture() == m_pWait)
					SetCapture(NULL);
				


				m_pCDKeyCtrl->SetString(1,m_sLastValidCDKey.c_str());
				m_pJoin->Enable(!m_sLastValidCDKey.empty());
				m_pHost->Enable(!m_sLastValidCDKey.empty());
				m_sCurCDKey = m_sLastValidCDKey;
				pServerDir->SetCDKey(m_sCurCDKey.c_str());

				if (m_sLastValidCDKey.empty())
					m_eCurState = eState_NoCDKey;
			}

			break;
		}
	}
	return 1;
}
Пример #11
0
LTRESULT CTO2GameServerShell::OnServerInitialized()
{
	LTRESULT nResult = CGameServerShell::OnServerInitialized();

	// Don't do anything special if we're playing single-player
	if (!IsMultiplayerGame( ))
	{
		SetServerDir(0);
		return nResult;
	}

	IServerDirectory *pServerDir = Factory_Create_IServerDirectory_Titan( false, *g_pLTServer, NULL );
	if( !pServerDir )
	{	
		ASSERT( !"ServerDir is NULL!" );
		return LT_ERROR;
	}
	SetServerDir(pServerDir);

	// Set the game's name
	pServerDir->SetGameName(g_pVersionMgr->GetNetGameName());
	// Set the version
	pServerDir->SetVersion(g_pVersionMgr->GetNetVersion());
	pServerDir->SetRegion(g_pVersionMgr->GetNetRegion());
	// Set up the network messaging header
	CAutoMessage cMsg;
	cMsg.Writeuint8(0xD); // SMSG_MESSAGE
	cMsg.Writeuint8(MID_MULTIPLAYER_SERVERDIR);
	pServerDir->SetNetHeader(*cMsg.Read());

	StartupInfo_Titan startupInfo;
	startupInfo.m_sGameSpyName = "nolf2";
	// Obfuscate the secret key a little.
	startupInfo.m_sGameSpySecretKey = "g";
	startupInfo.m_sGameSpySecretKey += "3";
	startupInfo.m_sGameSpySecretKey += "F";
	startupInfo.m_sGameSpySecretKey += "o";
	startupInfo.m_sGameSpySecretKey += "6";
	startupInfo.m_sGameSpySecretKey += "x";
	cMsg.Writeuint32(( uint32 )&startupInfo );
	pServerDir->SetStartupInfo( *cMsg.Read( ));

	return nResult;
}
Пример #12
0
void CScreenMulti::RequestValidate()
{
	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
	// Load the default CD key
	pServerDir->GetCDKey(&m_sCurCDKey);
	if (!pServerDir->SetCDKey(m_sCurCDKey.c_str()))
		m_sCurCDKey = "";	
	
	m_pCDKeyCtrl->SetString(1,m_sCurCDKey.c_str());

	if (m_sCurCDKey.empty())
	{
		m_pJoin->Enable(LTFALSE);
		m_pHost->Enable(LTFALSE);
		m_eCurState = eState_NoCDKey;

		MBCreate mb;
		g_pInterfaceMgr->ShowMessageBox(IDS_NO_CDKEY,&mb);

		return;

	}

	if( pServerDir->IsCDKeyValid( ))
	{
		if (m_sSysMOTD.empty() ||  m_sGameMOTD.empty())
			RequestMOTD();
		else
		{
			m_pJoin->Enable(LTTRUE);
			m_pHost->Enable(LTTRUE);
			m_eCurState = eState_Ready;
		}
		return;
	};

	m_pJoin->Enable(LTFALSE);
	m_pHost->Enable(LTFALSE);
	bool bResult = true;
	
	bResult &= pServerDir->QueueRequest(IServerDirectory::eRequest_Validate_CDKey);
	if (bResult)
	{
		g_pLTClient->CPrint( "QueueRequest(IServerDirectory::eRequest_Validate_CDKey)");
		m_eCurState = eState_ValidateCDKey;
		m_pWaitText->SetString(LoadTempString(IDS_VALIDATING));
		m_pWait->Show(LTTRUE);
		SetCapture(m_pWait);

	}
	else
	{
		g_pLTClient->CPrint( "QueueRequest(IServerDirectory::eRequest_Validate_CDKey) : FAILED");
		if (m_pScreenMgr->GetLastScreenID() == SCREEN_ID_MAIN)
		{
			MBCreate mb;
			g_pInterfaceMgr->ShowMessageBox(IDS_CDKEY_INVALID,&mb);

		}
		m_pWait->Show(LTFALSE);
		if (GetCapture() == m_pWait)
			SetCapture(NULL);
		m_eCurState = eState_NoCDKey;
	}
}
Пример #13
0
void CScreenMulti::Update()
{
	if (g_bLAN) return;

	IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();

	char aTempBuffer[256];

	FormatString(IDS_STATUS_STRING,aTempBuffer,sizeof(aTempBuffer),g_pClientMultiplayerMgr->GetServerDir()->GetCurStatusString());
	m_pStatusCtrl->SetString(aTempBuffer);


	// Are we still waiting?
	switch (pServerDir->GetCurStatus())
	{
		case IServerDirectory::eStatus_Processing : 
			return;
		case IServerDirectory::eStatus_Waiting : 
		{

			switch (m_eCurState)
			{
			case eState_Startup:
				{
					//completed startup... check version
					m_eCurState = eState_VersionCheck;

					bool bResult = pServerDir->QueueRequest(IServerDirectory::eRequest_Validate_Version);
					if (bResult)
					{
						g_pLTClient->CPrint( "QueueRequest(IServerDirectory::eRequest_Validate_Version)");

					}
					else
					{
						g_pLTClient->CPrint( "QueueRequest(IServerDirectory::eRequest_Validate_Version) : FAILED");
						ASSERT(0);

						MBCreate mb;
						g_pInterfaceMgr->ShowMessageBox(IDS_VALIDATION_FAILED,&mb);

						m_pWait->Show(LTFALSE);
						SetCapture(NULL);

						Escape();
						return;
					}

				} break;

			case eState_VersionCheck:
				{
					m_pWait->Show(LTFALSE);
					SetCapture(NULL);
			
					if (pServerDir->IsVersionNewest())
					{
						//passed version check... check CDKey

					}
					else if (pServerDir->IsVersionValid())
					{
						//enable updater
						MBCreate mb;
						mb.pFn = NewVersionCallBack;
						g_pInterfaceMgr->ShowMessageBox(IDS_NEW_VERSION,&mb);

						m_pUpdate->Show(LTTRUE);
						return;
					}
					else
					{
						//error state... bail
						MBCreate mb;
						g_pInterfaceMgr->ShowMessageBox(IDS_VALIDATION_FAILED,&mb);


						Escape();
						return;
					}

					RequestValidate();

				} break;

			case eState_ValidateCDKey:
				{
					//completed validation... check MOTD;
					m_pWait->Show(LTFALSE);
					SetCapture(NULL);
					m_sLastValidCDKey = m_sCurCDKey;

					RequestMOTD();
					
				}break;

			case eState_MOTD:
				{
					//completed system MOTD... check game MOTD

					if ((m_sSysMOTD.empty() && pServerDir->IsMOTDNew(IServerDirectory::eMOTD_System)) ||
						(m_sGameMOTD.empty() && pServerDir->IsMOTDNew(IServerDirectory::eMOTD_Game)))
					{
						//deal with new system motd
						MBCreate mb;
						//add callback
						g_pInterfaceMgr->ShowMessageBox(IDS_NEW_MOTD,&mb);

					}
					
					std::string sTemp = pServerDir->GetMOTD(IServerDirectory::eMOTD_System);
					if (sTemp.length() > 512)
						m_sSysMOTD.assign(sTemp.c_str(),512);
					else
						m_sSysMOTD = sTemp;

					sTemp = pServerDir->GetMOTD(IServerDirectory::eMOTD_Game);
					if (sTemp.length() > 512)
						m_sGameMOTD.assign(sTemp.c_str(),512);
					else
						m_sGameMOTD = sTemp;

					m_pSysMOTD->SetString(m_sSysMOTD.c_str());
					m_pGameMOTD->SetString(m_sGameMOTD.c_str());

					m_pJoin->Enable(LTTRUE);
					m_pHost->Enable(LTTRUE);

					m_eCurState = eState_Ready;
						
				} break;


			}

			break;
		}
		case IServerDirectory::eStatus_Error : 
		{
			g_pLTClient->CPrint( "ServerDir request error: %s", pServerDir->GetLastRequestResultString( ));
	
			// Ignore errors in the MOTD/Version queries for now...
			// NYI
			IServerDirectory::ERequest eErrorRequest = pServerDir->GetLastErrorRequest();
			if (eErrorRequest == IServerDirectory::eRequest_Validate_CDKey)
			{
				MBCreate mb;
				g_pInterfaceMgr->ShowMessageBox(IDS_CDKEY_INVALID,&mb);

				if (m_sLastValidCDKey.empty())
				{
					m_pJoin->Enable(LTFALSE);
					m_pHost->Enable(LTFALSE);

				}
				else
				{
					m_pCDKeyCtrl->SetString(1,m_sLastValidCDKey.c_str());
					m_pJoin->Enable(LTTRUE);
					m_pHost->Enable(LTTRUE);
				}
				
				m_sCurCDKey = m_sLastValidCDKey;
				pServerDir->SetCDKey(m_sCurCDKey.c_str());

				m_eCurState = eState_Ready;
								
				m_pWait->Show(LTFALSE);
				if (GetCapture() == m_pWait)
					SetCapture(NULL);
				
								
			}
			else if ((eErrorRequest == IServerDirectory::eRequest_MOTD) )
			{

				g_pLTClient->CPrint( "QueueRequest(IServerDirectory::eRequest_MOTD) : FAILED");

				m_eCurState = eState_Ready;
				m_sSysMOTD = "";
				m_sGameMOTD = "";

				m_pSysMOTD->SetString(m_sSysMOTD.c_str());
				m_pGameMOTD->SetString(m_sGameMOTD.c_str());

				m_pJoin->Enable(LTTRUE);
				m_pHost->Enable(LTTRUE);

			}
			else
			{

				// Whoops, something went wrong.
				// Drop out of this screen with an error
				MBCreate mb;
				g_pInterfaceMgr->ShowMessageBox(pServerDir->GetLastRequestResultString(),&mb);

				

				Escape();
			}
			pServerDir->ProcessRequestList();
			break;
		}
		default :
		{
			ASSERT(!"Unknown directory status encountered");
			break;
		}
	}
}
Пример #14
0
void CScreenPreload::FirstUpdate( )
{
	int n = 0;
	char szTagName[30];
	char szAttName[30];
	char szFXName[128];

	m_bHaveLights = LTFALSE;


	HOBJECT hCamera = g_pInterfaceMgr->GetInterfaceCamera();
	if (!hCamera) return;

	// Check if we have a mission entry.
	bool bGotMission = false;
	if( !g_pMissionMgr->IsCustomLevel( ))
	{
		int nNewMission = g_pMissionMgr->GetNewMission( );
		int nNewLevel = g_pMissionMgr->GetNewLevel( );
		MISSION* pMission = g_pMissionButeMgr->GetMission( nNewMission );
		if( pMission )
		{
			int nBriefingId = pMission->aLevels[nNewLevel].nBriefingId;
			if( nBriefingId >= 0 && !g_pMissionMgr->IsRestoringLevel( ))
				m_layout = pMission->szBriefLayout;
			else
				m_layout = pMission->szLayout;

			bGotMission = true;
		}
	}

	// If we were unsuccessful in getting info from the mission, then just
	// use defaults.
	if( !bGotMission )
	{
		m_layout = "LoadScreenDefault";
	}



    g_pLTClient->GetObjectPos(hCamera, &s_vPos);
    g_pLTClient->GetObjectRotation(hCamera, &s_rRot);
	s_vU = s_rRot.Up();
	s_vR = s_rRot.Right();
	s_vF = s_rRot.Forward();


	SAFE_STRCPY(szTagName,m_layout.c_str());
	if (!g_pLayoutMgr->Exist(szTagName))
		SAFE_STRCPY(szTagName,"LoadScreenDefault");

	sprintf(szAttName,"Light%d",n);
	while (g_pLayoutMgr->HasValue(szTagName,szAttName))
	{
		g_pLayoutMgr->GetString(szTagName,szAttName,szFXName,128);
		if (strlen(szFXName))
		{
			CreateLightFX(szFXName);
		}

		n++;
		sprintf(szAttName,"Light%d",n);

	}


	n = 0;
	sprintf(szAttName,"PreScale%d",n);
	while (g_pLayoutMgr->HasValue(szTagName,szAttName))
	{
		g_pLayoutMgr->GetString(szTagName,szAttName,szFXName,128);
		if (strlen(szFXName))
		{
			CBaseScaleFX *pSFX = CreateScaleFX(szFXName);
		}

		n++;
		sprintf(szAttName,"PreScale%d",n);

	}

	

	n = 0;
	sprintf(szAttName,"PreFX%d",n);
	while (g_pLayoutMgr->HasValue(szTagName,szAttName))
	{
		g_pLayoutMgr->GetString(szTagName,szAttName,szFXName,128);
		if (strlen(szFXName))
		{
			INT_FX* pFX = g_pLayoutMgr->GetFX(szFXName);
			if (pFX)
			{
				g_pInterfaceMgr->AddInterfaceFX(LTNULL, pFX->szFXName,pFX->vPos,pFX->bLoop);
			}
		}

		
		n++;
		sprintf(szAttName,"PreFX%d",n);

	}

	ChainFXList::iterator iter = m_Chains.begin();
	while (iter != m_Chains.end())
	{
		debug_delete(*iter);
		iter++;
	}
	m_Chains.clear();

	char szIntroFXName[128] = "";
	char szShortFXName[128] = "";
	char szLoopFXName[128] = "";
	int nFXNum = 0;
	bool bFound = false;
	do
	{
		szIntroFXName[0] = 0;
		szShortFXName[0] = 0;
		szLoopFXName[0] = 0;
		bFound = false;

		sprintf(szAttName,"PreIntroFX%d",nFXNum);
		if (g_pLayoutMgr->HasValue(szTagName,szAttName))
		{
			g_pLayoutMgr->GetString(szTagName,szAttName,szIntroFXName,128);
		}
		sprintf(szAttName,"PreLoopFX%d",nFXNum);
		if (g_pLayoutMgr->HasValue(szTagName,szAttName))
		{
			g_pLayoutMgr->GetString(szTagName,szAttName,szLoopFXName,128);
		}
		if (strlen(szIntroFXName) || strlen(szShortFXName) ) //don't start loop-only chains || strlen(szLoopFXName))
		{
			nFXNum++;
			bFound = true;

			CChainedFX *pChain = debug_new(CChainedFX);
			pChain->Init(szIntroFXName,szShortFXName,szLoopFXName);
			m_Chains.push_back(pChain);
		}

	} while (bFound);


	// Start all the chains.
	iter = m_Chains.begin();
	while (iter != m_Chains.end())
	{
		(*iter)->Start(!!m_bVisited);
		iter++;
	}
	
	// If we are not joining a lan game and the cdkey hasn't been validated,
	// we need to do it now.
	m_eValidatingCDKeyState = kValidatingCDKeyState_None;
	if( !g_bLAN && g_pClientMultiplayerMgr->GetStartGameRequest( ).m_Type == STARTGAME_CLIENTTCP )
	{
		IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
		if( !pServerDir || !pServerDir->IsCDKeyValid( ))
		{
			m_eValidatingCDKeyState = kValidatingCDKeyState_Start;
		}
	}
}
Пример #15
0
bool CScreenPreload::UpdateCDKeyValidation( )
{
	switch( m_eValidatingCDKeyState )
	{
		case kValidatingCDKeyState_None:
		{
			// Not validating cdkey, so we're done.
			return true;
			break;
		}
		case kValidatingCDKeyState_Start:
		{
			IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();
			if( !pServerDir )
			{
				pServerDir = g_pClientMultiplayerMgr->CreateServerDir( );
			}

			// Need to ask serverdir what the cdkey is from registry then set it.
			std::string sCDKey;
			pServerDir->GetCDKey( &sCDKey );
			if( !pServerDir->SetCDKey( sCDKey.c_str( )))
			{
				FailCDKey( );
				return false;
			}

			if( !pServerDir->QueueRequest(IServerDirectory::eRequest_Validate_CDKey))
			{
				FailCDKey( );
				return false;
			}

			m_eValidatingCDKeyState = kValidatingCDKeyState_Waiting;
			break;
		}
		case kValidatingCDKeyState_Waiting:
		{
			IServerDirectory *pServerDir = g_pClientMultiplayerMgr->GetServerDir();

			// Are we still waiting?
			switch (pServerDir->GetCurStatus())
			{
				case IServerDirectory::eStatus_Processing : 
				{
					// Still waiting for response.
					break;
				}
				case IServerDirectory::eStatus_Waiting : 
				{
					// If we reach the waiting state, we're done.
					m_eValidatingCDKeyState = kValidatingCDKeyState_None;
					return true;
					break;
				}
				case IServerDirectory::eStatus_Error : 
				{
					FailCDKey( );
					break;
				}
				default :
				{
					ASSERT(!"Unknown directory status encountered");

					FailCDKey( );
					break;
				}
			}

			break;
		}
	}

	return false;
}