fixed bug causing crash when trying to draw undefined optional graphics
[rocksndiamonds.git] / src / tools.c
index 903818a414b6b5ea5ca0a23ec70640b7d57a1b22..6d3a0aeb00f5866603f28f4a720b0b05bd17d3b5 100644 (file)
@@ -1574,6 +1574,10 @@ void getSizedGraphicSourceExt(int graphic, int frame, int tilesize,
 {
   struct GraphicInfo *g = &graphic_info[graphic];
 
+  // if no graphics defined at all, use fallback graphics
+  if (g->bitmaps == NULL)
+    *g = graphic_info[IMG_CHAR_EXCLAM];
+
   // if no in-game graphics defined, always use standard graphic size
   if (g->bitmaps[IMG_BITMAP_GAME] == NULL)
     tilesize = TILESIZE;
@@ -5150,11 +5154,14 @@ unsigned int MoveDoor(unsigned int door_state)
     {
       /* wait for specified door action post delay */
       if (door_state & DOOR_ACTION_1 && door_state & DOOR_ACTION_2)
-       Delay(MAX(door_1.post_delay, door_2.post_delay));
+       door_delay_value = MAX(door_1.post_delay, door_2.post_delay);
       else if (door_state & DOOR_ACTION_1)
-       Delay(door_1.post_delay);
+       door_delay_value = door_1.post_delay;
       else if (door_state & DOOR_ACTION_2)
-       Delay(door_2.post_delay);
+       door_delay_value = door_2.post_delay;
+
+      while (!DelayReached(&door_delay, door_delay_value))
+       BackToFront();
     }
   }