DEADSOFTWARE

Res Downloader: Better handle download cancel
authorStas'M <x86corez@gmail.com>
Fri, 18 May 2018 15:23:59 +0000 (18:23 +0300)
committerStas'M <x86corez@gmail.com>
Fri, 18 May 2018 15:24:10 +0000 (18:24 +0300)
src/game/g_game.pas
src/game/g_res_downloader.pas

index 3accde9348a9f72d31ceb9910e1a8470aabd9dac..81eade6f2a55ab1d42b15ba88d88cc92570d7961 100644 (file)
@@ -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;
index fcb4ad9047279574b9622aa6158f23ed4373e7a1..78b0b2803ddccde223d34b5705f9def7191d5b63 100644 (file)
@@ -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.