rnd-20030717-2-src
[rocksndiamonds.git] / src / game.c
index 150182acf867b13d662dc4dd023d61ec5600ec87..78aa51586a8ece24210c35b23ed0c1c3c3b512e1 100644 (file)
@@ -1918,12 +1918,23 @@ void Explode(int ex, int ey, int phase, int mode)
       if (IS_MOVING(x, y) || IS_BLOCKED(x, y))
       {
        element = MovingOrBlocked2Element(x, y);
-       RemoveMovingField(x, y);
+
+       if (!IS_EXPLOSION_PROOF(element))
+         RemoveMovingField(x, y);
       }
 
+#if 1
+
 #if 1
       if (IS_EXPLOSION_PROOF(element))
        continue;
+#else
+      /* indestructible elements can only explode in center (but not flames) */
+      if ((IS_EXPLOSION_PROOF(element) && (x != ex || y != ey)) ||
+         element == EL_FLAMES)
+       continue;
+#endif
+
 #else
       if ((IS_INDESTRUCTIBLE(element) &&
           (game.engine_version < VERSION_IDENT(2,2,0) ||
@@ -1945,8 +1956,13 @@ void Explode(int ex, int ey, int phase, int mode)
       }
 
       /* save walkable background elements while explosion on same tile */
+#if 1
       if (IS_INDESTRUCTIBLE(element))
        Back[x][y] = element;
+#else
+      if (IS_INDESTRUCTIBLE(element) && IS_WALKABLE(element))
+       Back[x][y] = element;
+#endif
 
       /* ignite explodable elements reached by other explosion */
       if (element == EL_EXPLOSION)
@@ -2768,6 +2784,13 @@ void Impact(int x, int y)
       Bang(x, y + 1);
       return;
     }
+#if 0
+    else if (CAN_SMASH_ENEMIES(element) && IS_CLASSIC_ENEMY(smashed))
+    {
+      Bang(x, y + 1);
+      return;
+    }
+#endif
     else if (CAN_SMASH_EVERYTHING(element))
     {
       if (IS_CLASSIC_ENEMY(smashed) ||
@@ -3417,7 +3440,9 @@ void StartMoving(int x, int y)
   if (Stop[x][y])
     return;
 
-  GfxAction[x][y] = ACTION_DEFAULT;
+  /* !!! this should be handled more generic (not only for more) !!! */
+  if (element != EL_MOLE && GfxAction[x][y] != ACTION_DIGGING)
+    GfxAction[x][y] = ACTION_DEFAULT;
 
   if (CAN_FALL(element) && y < lev_fieldy - 1)
   {
@@ -3996,6 +4021,11 @@ void StartMoving(int x, int y)
       {
        Feld[newx][newy] = EL_AMOEBA_SHRINKING;
        PlaySoundLevel(x, y, SND_MOLE_DIGGING);
+
+       ResetGfxAnimation(x, y);
+       GfxAction[x][y] = ACTION_DIGGING;
+       DrawLevelField(x, y);
+
        MovDelay[newx][newy] = 0;       /* start amoeba shrinking delay */
        return;                         /* wait for shrinking amoeba */
       }
@@ -5119,6 +5149,10 @@ static void ChangeElementNowExt(int x, int y, int target_element)
 
   if (CAN_BE_CRUMBLED(Feld[x][y]))
     DrawLevelFieldCrumbledSandNeighbours(x, y);
+
+  TestIfBadThingTouchesHero(x, y);
+  TestIfPlayerTouchesCustomElement(x, y);
+  TestIfElementTouchesCustomElement(x, y);
 }
 
 static void ChangeElementNow(int x, int y, int element)
@@ -5173,6 +5207,9 @@ static void ChangeElementNow(int x, int y, int element)
 
       e = Feld[ex][ey];
 
+      if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
+       e = MovingOrBlocked2Element(ex, ey);
+
       half_destructible = (IS_FREE(ex, ey) || IS_DIGGABLE(e));
 
       if ((change->power <= CP_NON_DESTRUCTIVE  && !IS_FREE(ex, ey)) ||
@@ -5198,6 +5235,9 @@ static void ChangeElementNow(int x, int y, int element)
        if (can_change[xx][yy] && (!change->use_random_change ||
                                   RND(change->random) == 0))
        {
+         if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
+           RemoveMovingField(ex, ey);
+
          ChangeElementNowExt(ex, ey, change->content[xx][yy]);
 
          /* for symmetry reasons, stop newly created border elements */
@@ -5616,9 +5656,10 @@ void GameActions()
 #if 1
       graphic = el_act_dir2img(element, GfxAction[x][y], MovDir[x][y]);
 #if 0
-      if (element == EL_PACMAN)
-       printf("::: %d, %d, %d\n",
-              IS_ANIMATED(graphic), IS_MOVING(x, y), Stop[x][y]);
+      if (element == EL_MOLE)
+       printf("::: %d, %d, %d [%d]\n",
+              IS_ANIMATED(graphic), IS_MOVING(x, y), Stop[x][y],
+              GfxAction[x][y]);
 #endif
 #if 0
       if (element == EL_YAMYAM)
@@ -5634,7 +5675,7 @@ void GameActions()
        DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
 
 #if 0
-       if (element == EL_YAMYAM)
+       if (element == EL_MOLE)
          printf("::: %d, %d\n", graphic, GfxFrame[x][y]);
 #endif
       }