DEADSOFTWARE

changed license to GPLv3 only; sorry, no trust to FSF anymore
[d2df-sdl.git] / src / game / g_res_downloader.pas
index fcb4ad9047279574b9622aa6158f23ed4373e7a1..04048b693c983c558af1c61168f3948eee2c5823 100644 (file)
@@ -2,8 +2,7 @@
  *
  * 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, either version 3 of the License, or
- * (at your option) any later version.
+ * 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
@@ -140,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
@@ -156,6 +156,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 +171,8 @@ begin
   end;
 
   Result := SaveWAD(MapsDir, ExtractFileName(FileName), mapData.FileData);
+  if mapData.FileSize = 0 then
+    DeleteFile(Result);
 end;
 
 end.