/////////////////////////////////////////////////////////////// // // CResourceFileDownloadManager::DownloadFinished // // Callback when file download has finished // /////////////////////////////////////////////////////////////// void CResourceFileDownloadManager::DownloadFinished(const SHttpDownloadResult& result) { CDownloadableResource* pResourceFile = ResolveDownloadContextString((SString*)result.pObj); if (!pResourceFile) return; assert(ListContains(m_ActiveFileDownloadList, pResourceFile)); if (result.bSuccess) { CChecksum checksum = CChecksum::GenerateChecksumFromFile(pResourceFile->GetName()); if (checksum != pResourceFile->GetServerChecksum()) { // Checksum failed - Try download on next server if (BeginResourceFileDownload(pResourceFile, pResourceFile->GetHttpServerIndex() + 1)) { // Was re-added - Add size again to total. AddDownloadSize(pResourceFile->GetDownloadSize()); SString strMessage("External HTTP file mismatch (Retrying this file with internal HTTP) [%s]", *ConformResourcePath(pResourceFile->GetName())); g_pClientGame->TellServerSomethingImportant(1011, strMessage, 3); return; } } } else { // Download failed due to connection type problem CNetHTTPDownloadManagerInterface* pHTTP = g_pNet->GetHTTPDownloadManager(m_HttpServerList[pResourceFile->GetHttpServerIndex()].downloadChannel); SString strHTTPError = pHTTP->GetError(); // Disable server from being used (if possible) if (DisableHttpServer(pResourceFile->GetHttpServerIndex())) { // Try download on next server if (BeginResourceFileDownload(pResourceFile, pResourceFile->GetHttpServerIndex() + 1)) { // Was re-added - Add size again to total. AddDownloadSize(pResourceFile->GetDownloadSize()); SString strMessage("External HTTP file download error:[%d] %s (Disabling External HTTP) [%s]", result.iErrorCode, *strHTTPError, *ConformResourcePath(pResourceFile->GetName())); g_pClientGame->TellServerSomethingImportant(1012, strMessage, 3); return; } } m_strLastHTTPError = strHTTPError; } // File now done (or failed) ListRemove(m_ActiveFileDownloadList, pResourceFile); pResourceFile->SetIsWaitingForDownload(false); }