From: Stas'M Date: Fri, 18 May 2018 15:23:59 +0000 (+0300) Subject: Res Downloader: Better handle download cancel X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=9034e63d857ef01baa7d0c1aca9f45eaa1d0fada;p=d2df-sdl.git Res Downloader: Better handle download cancel --- diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 3accde9..81eade6 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -4527,7 +4527,7 @@ begin gWADHash := MD5File(MapsDir + NewWAD); g_Game_LoadWAD(NewWAD); end else - // hash recieved in MC_RECV_GameEvent -> NET_EV_MAPSTART + // hash received in MC_RECV_GameEvent -> NET_EV_MAPSTART g_Game_ClientWAD(NewWAD, gWADHash); end else ResName := Map; diff --git a/src/game/g_res_downloader.pas b/src/game/g_res_downloader.pas index fcb4ad9..78b0b28 100644 --- a/src/game/g_res_downloader.pas +++ b/src/game/g_res_downloader.pas @@ -140,7 +140,8 @@ begin begin mapData := MapDataFromMsgStream(msgStream); msgStream.Free; - end; + end else + mapData.FileSize := 0; for i := 0 to High(mapData.ExternalResources) do begin @@ -156,6 +157,9 @@ begin 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); @@ -168,6 +172,8 @@ begin end; Result := SaveWAD(MapsDir, ExtractFileName(FileName), mapData.FileData); + if mapData.FileSize = 0 then + DeleteFile(Result); end; end.