fixed potential crash bug (accessing already destroyed SDL renderer)
[rocksndiamonds.git] / src / tools.c
index 2ff2a6e3a7450e00293d90a81ee25308167fa84a..459f85a769cf82263a4229a219130bcc973461af 100644 (file)
@@ -2274,7 +2274,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 +3516,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 +3569,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;
@@ -9656,6 +9658,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();
   }