コード例 #1
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;
}
コード例 #2
0
ファイル: ScreenJoin.cpp プロジェクト: Arc0re/lithtech
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;
}
コード例 #3
0
ファイル: ScreenJoin.cpp プロジェクト: Arc0re/lithtech
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;
}
コード例 #4
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;
	}
}
コード例 #5
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;
		}
	}
}
コード例 #6
0
ファイル: ScreenPreload.cpp プロジェクト: rickyharis39/nolf2
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;
}