added selecting new level set if dropped as zip file into window
[rocksndiamonds.git] / src / tools.c
index 6522b8e741382bc55352fb961f2e4fc5149fdd03..33b677954947107346e76e69d65f778027d1e2f6 100644 (file)
@@ -1150,10 +1150,12 @@ void FadeSkipNextFadeOut(void)
 
 static Bitmap *getBitmapFromGraphicOrDefault(int graphic, int default_graphic)
 {
+  if (graphic == IMG_UNDEFINED)
+    return NULL;
+
   boolean redefined = getImageListEntryFromImageID(graphic)->redefined;
 
-  return (graphic == IMG_UNDEFINED ? NULL :
-         graphic_info[graphic].bitmap != NULL || redefined ?
+  return (graphic_info[graphic].bitmap != NULL || redefined ?
          graphic_info[graphic].bitmap :
          graphic_info[default_graphic].bitmap);
 }
@@ -2274,7 +2276,9 @@ static void DrawLevelFieldCrumbledExt(int x, int y, int graphic, int frame)
          !IN_SCR_FIELD(sxx, syy))
        continue;
 
-      if (Feld[xx][yy] == EL_ELEMENT_SNAPPING)
+      // do not crumble fields that are being digged or snapped
+      if (Feld[xx][yy] == EL_EMPTY ||
+         Feld[xx][yy] == EL_ELEMENT_SNAPPING)
        continue;
 
       element = TILE_GFX_ELEMENT(xx, yy);
@@ -3514,14 +3518,11 @@ static void DrawPreviewLevelExt(boolean restart)
   }
 }
 
-static void DrawPreviewPlayers(void)
+void DrawPreviewPlayers(void)
 {
   if (game_status != GAME_MODE_MAIN)
     return;
 
-  if (!network.enabled && !setup.team_mode)
-    return;
-
   boolean player_found[MAX_PLAYERS];
   int num_players = 0;
   int i, x, y;
@@ -3570,6 +3571,9 @@ static void DrawPreviewPlayers(void)
   ClearRectangleOnBackground(drawto, max_xpos, max_ypos,
                             max_players_width, max_players_height);
 
+  if (!network.enabled && !setup.team_mode)
+    return;
+
   // only draw players if level is suited for team mode
   if (num_players < 2)
     return;
@@ -4811,17 +4815,17 @@ static boolean RequestEnvelope(char *text, unsigned int req_state)
 
 boolean Request(char *text, unsigned int req_state)
 {
-  boolean overlay_active = GetOverlayActive();
+  boolean overlay_enabled = GetOverlayEnabled();
   boolean result;
 
-  SetOverlayActive(FALSE);
+  SetOverlayEnabled(FALSE);
 
   if (global.use_envelope_request)
     result = RequestEnvelope(text, req_state);
   else
     result = RequestDoor(text, req_state);
 
-  SetOverlayActive(overlay_active);
+  SetOverlayEnabled(overlay_enabled);
 
   return result;
 }
@@ -9656,6 +9660,8 @@ void ChangeViewportPropertiesIfNeeded(void)
   {
     // printf("::: init_video_buffer\n");
 
+    FreeAllImageTextures();    // needs old renderer to free the textures
+
     InitVideoBuffer(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH, setup.fullscreen);
     InitImageTextures();
   }