X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_res_downloader.pas;h=04048b693c983c558af1c61168f3948eee2c5823;hb=7d53b8719f818712900fefb1c36e41b1fe9b3f32;hp=05dfc24941c070fa76adb7d9db2ee5b84a74932d;hpb=ac201b02f10ef558087d50f6b03b4519ab567558;p=d2df-sdl.git diff --git a/src/game/g_res_downloader.pas b/src/game/g_res_downloader.pas index 05dfc24..04048b6 100644 --- a/src/game/g_res_downloader.pas +++ b/src/game/g_res_downloader.pas @@ -1,4 +1,18 @@ -{$MODE DELPHI} +(* Copyright (C) Doom 2D: Forever Developers + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *) +{$INCLUDE ../shared/a_modes.inc} unit g_res_downloader; interface @@ -10,7 +24,7 @@ function g_Res_DownloadWAD(const FileName: string): string; implementation -uses g_language, sfs, utils, wadreader; +uses g_language, sfs, utils, wadreader, g_game; const DOWNLOAD_DIR = 'downloads'; @@ -116,7 +130,8 @@ var begin SetLength(mapData.ExternalResources, 0); g_Console_Add(Format(_lc[I_NET_MAP_DL], [FileName])); - e_WriteLog('Downloading map `' + FileName + '` from server', MSG_NOTIFY); + e_WriteLog('Downloading map `' + FileName + '` from server', TMsgType.Notify); + g_Game_SetLoadingText(FileName + '...', 0, False); MC_SEND_MapRequest(); msgStream := g_Net_Wait_Event(NET_MSG_MAP_RESPONSE); @@ -124,7 +139,8 @@ begin begin mapData := MapDataFromMsgStream(msgStream); msgStream.Free; - end; + end else + mapData.FileSize := 0; for i := 0 to High(mapData.ExternalResources) do begin @@ -135,10 +151,14 @@ begin g_Console_Add(Format(_lc[I_NET_WAD_DL], [mapData.ExternalResources[i].Name])); e_WriteLog('Downloading Wad `' + mapData.ExternalResources[i].Name + - '` from server', MSG_NOTIFY); + '` from server', TMsgType.Notify); + g_Game_SetLoadingText(mapData.ExternalResources[i].Name + '...', 0, False); MC_SEND_ResRequest(mapData.ExternalResources[i].Name); msgStream := g_Net_Wait_Event(NET_MSG_RES_RESPONSE); + if msgStream = nil then + continue; + resData := ResDataFromMsgStream(msgStream); resStream := createDiskFile(GameDir+'/wads/'+mapData.ExternalResources[i].Name); @@ -151,6 +171,8 @@ begin end; Result := SaveWAD(MapsDir, ExtractFileName(FileName), mapData.FileData); + if mapData.FileSize = 0 then + DeleteFile(Result); end; end.