rnd-20030327-1-src
[rocksndiamonds.git] / src / game.c
index a9d0e2698361c6f1869024455056e3e6ea869e0d..06c88af1c1a5f03bede1d87faf811d2b4d3af2c8 100644 (file)
@@ -658,6 +658,8 @@ void InitGame()
 
     player->is_moving = FALSE;
     player->is_waiting = FALSE;
+    player->is_digging = FALSE;
+    player->is_collecting = FALSE;
 
     player->move_delay       = game.initial_move_delay;
     player->move_delay_value = game.initial_move_delay_value;
@@ -1382,6 +1384,7 @@ static int MovingOrBlocked2ElementIfNotLeaving(int x, int y)
 static void RemoveField(int x, int y)
 {
   Feld[x][y] = EL_EMPTY;
+  GfxElement[x][y] = EL_EMPTY;
   MovPos[x][y] = 0;
   MovDir[x][y] = 0;
   MovDelay[x][y] = 0;
@@ -1615,6 +1618,7 @@ void Explode(int ex, int ey, int phase, int mode)
       }
 
       Feld[x][y] = EL_EXPLOSION;
+      GfxElement[x][y] = EL_EMPTY;
       MovDir[x][y] = MovPos[x][y] = 0;
       AmoebaNr[x][y] = 0;
       ExplodePhase[x][y] = 1;
@@ -5664,7 +5668,10 @@ int DigField(struct PlayerInfo *player,
   int element;
 
   if (player->MovPos == 0)
+  {
     player->is_digging = FALSE;
+    player->is_collecting = FALSE;
+  }
 
   if (player->MovPos == 0)
     player->Pushing = FALSE;
@@ -5721,11 +5728,11 @@ int DigField(struct PlayerInfo *player,
     case EL_SP_BASE:
     case EL_SP_BUGGY_BASE:
     case EL_SP_BUGGY_BASE_ACTIVATING:
+      RemoveField(x, y);
 #if 1
       if (mode != DF_SNAP && element == EL_SAND)
-       GfxElement[x][y] = Feld[x][y];
+       GfxElement[x][y] = EL_SAND;
 #endif
-      RemoveField(x, y);
       PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING);
       break;
 
@@ -6368,8 +6375,13 @@ int DigField(struct PlayerInfo *player,
 
   player->push_delay = 0;
 
-  if (Feld[x][y] != element)           /* really digged something */
-    player->is_digging = TRUE;
+  if (Feld[x][y] != element)           /* really digged/collected something */
+  {
+    if (GfxElement[x][y] == EL_SAND)
+      player->is_digging = TRUE;
+    else
+      player->is_collecting = TRUE;
+  }
 
   return MF_MOVING;
 }
@@ -6393,7 +6405,10 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy)
     player->snapped = FALSE;
 
     if (player->MovPos == 0)
+    {
       player->is_digging = FALSE;
+      player->is_collecting = FALSE;
+    }
 
     return FALSE;
   }
@@ -6411,6 +6426,8 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy)
 
   player->snapped = TRUE;
   player->is_digging = FALSE;
+  player->is_collecting = FALSE;
+
   DrawLevelField(x, y);
   BackToFront();