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; }
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; } }
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; }