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