rnd-20030807-1-src
[rocksndiamonds.git] / src / tools.c
index a20e117759a785dd77bd709c53c3a49b6e998692..d37a7b0e991b821c3979602a3689758ccdf3504d 100644 (file)
@@ -34,6 +34,7 @@
 /* forward declaration for internal use */
 static void UnmapToolButtons();
 static void HandleToolButtons(struct GadgetInfo *);
+static int el_act_dir2crm(int, int, int);
 
 static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS];
 static int request_gadget_id = -1;
@@ -503,6 +504,9 @@ inline void DrawLevelGraphicAnimationIfNeeded(int x, int y, int graphic)
     return;
 
   DrawGraphicAnimation(sx, sy, graphic);
+
+  if (CAN_BE_CRUMBLED(Feld[x][y]))
+    DrawLevelFieldCrumbledSand(x, y);
 }
 
 void DrawLevelElementAnimationIfNeeded(int x, int y, int element)
@@ -519,6 +523,9 @@ void DrawLevelElementAnimationIfNeeded(int x, int y, int element)
     return;
 
   DrawGraphicAnimation(sx, sy, graphic);
+
+  if (CAN_BE_CRUMBLED(element))
+    DrawLevelFieldCrumbledSand(x, y);
 }
 
 void DrawAllPlayers()
@@ -658,9 +665,15 @@ void DrawPlayer(struct PlayerInfo *player)
   {
     if (player_is_moving && GfxElement[jx][jy] != EL_UNDEFINED)
     {
+#if 1
+      /* !!! insert DrawLevelFieldCrumbledSandDigging code here !!! */
+      if (player->is_digging && CAN_BE_CRUMBLED(GfxElement[jx][jy]))
+       DrawLevelFieldCrumbledSandDigging(jx, jy, move_dir, player->StepFrame);
+#else
       if (GfxElement[jx][jy] == EL_SAND)
        DrawLevelFieldCrumbledSandDigging(jx, jy, move_dir, player->StepFrame);
-      else
+#endif
+      else     /* player->is_collecting */
       {
        int old_element = GfxElement[jx][jy];
        int old_graphic = el_act_dir2img(old_element, action, move_dir);
@@ -1298,14 +1311,21 @@ void DrawLevelFieldCrumbledSand(int x, int y)
 void DrawLevelFieldCrumbledSandDigging(int x, int y, int direction,
                                       int step_frame)
 {
+#if 1
+  int graphic1 = el_act_dir2img(GfxElement[x][y], ACTION_DIGGING, direction);
+  int graphic2 = el_act_dir2crm(GfxElement[x][y], ACTION_DIGGING, direction);
+#else
   int graphic1 = el_act_dir2img(EL_SAND,          ACTION_DIGGING, direction);
   int graphic2 = el_act_dir2img(EL_SAND_CRUMBLED, ACTION_DIGGING, direction);
+#endif
   int frame1 = getGraphicAnimationFrame(graphic1, step_frame);
   int frame2 = getGraphicAnimationFrame(graphic2, step_frame);
   int sx = SCREENX(x), sy = SCREENY(y);
 
   DrawGraphic(sx, sy, graphic1, frame1);
-  DrawLevelFieldCrumbledSandExt(x, y, graphic2, frame2);
+
+  if (graphic1 != IMG_EMPTY_SPACE)
+    DrawLevelFieldCrumbledSandExt(x, y, graphic2, frame2);
 }
 
 void DrawLevelFieldCrumbledSandNeighbours(int x, int y)
@@ -2446,6 +2466,14 @@ int el_act_dir2img(int element, int action, int direction)
   return element_info[element].direction_graphic[action][direction];
 }
 
+static int el_act_dir2crm(int element, int action, int direction)
+{
+  element = GFX_ELEMENT(element);
+  direction = MV_DIR_BIT(direction);
+
+  return element_info[element].direction_crumbled[action][direction];
+}
+
 int el_act2img(int element, int action)
 {
   element = GFX_ELEMENT(element);