=============== idAsyncClient::ProcessDownloadInfoMessage =============== */
| 2175 | =============== |
| 2176 | */ |
| 2177 | void idAsyncClient::ProcessDownloadInfoMessage( const netadr_t from, const idBitMsg &msg ) { |
| 2178 | char buf[ MAX_STRING_CHARS ]; |
| 2179 | int srvDlRequest = msg.ReadInt(); |
| 2180 | int infoType = msg.ReadByte(); |
| 2181 | int pakDl; |
| 2182 | int pakIndex; |
| 2183 | |
| 2184 | pakDlEntry_t entry; |
| 2185 | bool gotAllFiles = true; |
| 2186 | idStr sizeStr; |
| 2187 | bool gotGame = false; |
| 2188 | |
| 2189 | if ( dlRequest == -1 || srvDlRequest != dlRequest ) { |
| 2190 | common->Warning( "bad download id from server, ignored" ); |
| 2191 | return; |
| 2192 | } |
| 2193 | // mark the dlRequest as dead now whatever how we process it |
| 2194 | dlRequest = -1; |
| 2195 | |
| 2196 | if ( infoType == SERVER_DL_REDIRECT ) { |
| 2197 | msg.ReadString( buf, MAX_STRING_CHARS ); |
| 2198 | cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" ); |
| 2199 | // "You are missing required pak files to connect to this server.\nThe server gave a web page though:\n%s\nDo you want to go there now?" |
| 2200 | // "Missing required files" |
| 2201 | if ( session->MessageBox( MSG_YESNO, va( common->GetLanguageDict()->GetString( "#str_07217" ), buf ), |
| 2202 | common->GetLanguageDict()->GetString( "#str_07218" ), true, "yes" )[ 0 ] ) { |
| 2203 | sys->OpenURL( buf, true ); |
| 2204 | } |
| 2205 | } else if ( infoType == SERVER_DL_LIST ) { |
| 2206 | cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" ); |
| 2207 | if ( dlList.Num() ) { |
| 2208 | common->Warning( "tried to process a download list while already busy downloading things" ); |
| 2209 | return; |
| 2210 | } |
| 2211 | // read the URLs, check against what we requested, prompt for download |
| 2212 | pakIndex = -1; |
| 2213 | totalDlSize = 0; |
| 2214 | do { |
| 2215 | pakIndex++; |
| 2216 | pakDl = msg.ReadByte(); |
| 2217 | if ( pakDl == SERVER_PAK_YES ) { |
| 2218 | if ( pakIndex == 0 ) { |
| 2219 | gotGame = true; |
| 2220 | } |
| 2221 | msg.ReadString( buf, MAX_STRING_CHARS ); |
| 2222 | entry.filename = buf; |
| 2223 | msg.ReadString( buf, MAX_STRING_CHARS ); |
| 2224 | entry.url = buf; |
| 2225 | entry.size = msg.ReadInt(); |
| 2226 | // checksums are not transmitted, we read them from the dl request we sent |
| 2227 | entry.checksum = dlChecksums[ pakIndex ]; |
| 2228 | totalDlSize += entry.size; |
| 2229 | dlList.Append( entry ); |
| 2230 | common->Printf( "download %s from %s ( 0x%x )\n", entry.filename.c_str(), entry.url.c_str(), entry.checksum ); |
| 2231 | } else if ( pakDl == SERVER_PAK_NO ) { |
| 2232 | msg.ReadString( buf, MAX_STRING_CHARS ); |
| 2233 | entry.filename = buf; |
| 2234 | entry.url = ""; |
nothing calls this directly
no test coverage detected