DEADSOFTWARE

some more exoma code
[d2df-sdl.git] / src / game / g_map.pas
index c395dab92374f94db5ffefe36903406bf1646bfd..ac54bd535a9d82d6e3d1c00ae97795761348f24c 100644 (file)
@@ -1620,6 +1620,7 @@ var
   moveSpeed{, moveStart, moveEnd}: TDFPoint;
   //moveActive: Boolean;
   pan: TPanel;
+  mapOk: Boolean = false;
 begin
   mapGrid.Free();
   mapGrid := nil;
@@ -1690,6 +1691,8 @@ begin
       exit;
     end;
 
+    gCurrentMap := mapReader;
+
     generateExternalResourcesList(mapReader);
     mapTextureList := mapReader['texture'];
     // get all other lists here too
@@ -1778,6 +1781,8 @@ begin
         begin
           e_WriteLog('error loading map: invalid texture index for panel', MSG_FATALERROR);
           result := false;
+          gCurrentMap := nil;
+          gCurrentMapFileName := '';
           exit;
         end;
       end;
@@ -2156,10 +2161,16 @@ begin
 
     stt := curTimeMicro()-stt;
     e_LogWritefln('map loaded in %s.%s milliseconds', [Integer(stt div 1000), Integer(stt mod 1000)]);
+    mapOk := true;
   finally
     sfsGCEnable(); // enable releasing unused volumes
     mapReader.Free();
     e_ClearInputBuffer(); // why not?
+    if not mapOk then
+    begin
+      gCurrentMap := nil;
+      gCurrentMapFileName := '';
+    end;
   end;
 
   e_WriteLog('Done loading map.', MSG_NOTIFY);