rnd-20030624-1-src
[rocksndiamonds.git] / src / game.c
index 88f2c53c32bbd122c54a991945d68e413a513040..d0f7751bbbca9183bf1fed4ec03edb5008671678 100644 (file)
@@ -3791,7 +3791,16 @@ void ContinueMoving(int x, int y)
   int newx = x + dx, newy = y + dy;
   int step = (horiz_move ? dx : dy) * TILEX / MOVE_DELAY_NORMAL_SPEED;
   struct PlayerInfo *player = (IS_PLAYER(x, y) ? PLAYERINFO(x, y) : NULL);
+#if 0
+  boolean pushing = (player != NULL && player->Pushing && player->MovPos != 0);
+#else
   boolean pushing = (player != NULL && player->Pushing && player->is_moving);
+#endif
+
+#if 0
+  if (player && player->is_moving && player->MovPos == 0)
+    printf("::: !!!\n");
+#endif
 
   if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DROPPING)
     step /= 2;
@@ -3820,12 +3829,22 @@ void ContinueMoving(int x, int y)
 
 #if 1
   if (pushing)         /* special case: moving object pushed by player */
+#if 1
+    MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->MovPos));
+#else
     MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->GfxPos));
 #endif
+#endif
 
 #if 0
-  if (pushing)
-    printf("::: OOPS! pushing '%s'\n", element_info[element].token_name);
+  if (element == EL_SPRING)
+    printf("::: spring moves %d [%d: %d, %d, %d/%d]\n",
+          MovPos[x][y],
+          pushing,
+          (player?player->Pushing:-42),
+          (player?player->is_moving:-42),
+          (player?player->MovPos:-42),
+          (player?player->GfxPos:-42));
 #endif
 
   if (ABS(MovPos[x][y]) >= TILEX)      /* object reached its destination */
@@ -4991,7 +5010,12 @@ static void CheckPlayerElementChange(int x, int y, int element,
   if (!CAN_CHANGE(element) || !HAS_CHANGE_EVENT(element, trigger_event))
     return;
 
+#if 1
+  ChangeDelay[x][y] = 1;
+  ChangeElement(x, y);
+#else
   ChangeElementDoIt(x, y, element_info[element].change.successor);
+#endif
 }
 
 static void PlayerActions(struct PlayerInfo *player, byte player_action)
@@ -6347,6 +6371,7 @@ static boolean checkDiagonalPushing(struct PlayerInfo *player,
 int DigField(struct PlayerInfo *player,
             int x, int y, int real_dx, int real_dy, int mode)
 {
+  boolean use_spring_bug = (game.engine_version < VERSION_IDENT(2,2,0));
   int jx = player->jx, jy = player->jy;
   int dx = x - jx, dy = y - jy;
   int move_direction = (dx == -1 ? MV_LEFT :
@@ -6760,6 +6785,10 @@ int DigField(struct PlayerInfo *player,
       if (dy)
        return MF_NO_ACTION;
 
+      if (CAN_FALL(element) && IN_LEV_FIELD(x, y + 1) && IS_FREE(x, y + 1) &&
+         !(element == EL_SPRING && use_spring_bug))
+       return MF_NO_ACTION;
+
       player->Pushing = TRUE;
 
 #if 0
@@ -6817,11 +6846,13 @@ int DigField(struct PlayerInfo *player,
             FrameCounter, player->push_delay_value);
 #endif
 
+#if 0
       if (element == EL_SPRING)
       {
        Feld[x + dx][y + dy] = EL_SPRING;
        MovDir[x + dx][y + dy] = move_direction;
       }
+#endif
 
       player->push_delay_value = (element == EL_SPRING ? 0 : 2 + RND(8));
 
@@ -7174,6 +7205,9 @@ int DigField(struct PlayerInfo *player,
        if (CAN_FALL(element) && dy)
          return MF_NO_ACTION;
 
+       if (CAN_FALL(element) && IN_LEV_FIELD(x, y + 1) && IS_FREE(x, y + 1))
+         return MF_NO_ACTION;
+
        if (!player->Pushing &&
            game.engine_version >= RELEASE_IDENT(2,2,0,7))
          player->push_delay_value = GET_NEW_PUSH_DELAY(element);
@@ -7214,7 +7248,11 @@ int DigField(struct PlayerInfo *player,
        PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING);
 
        CheckTriggeredElementChange(element, CE_OTHER_PUSHING);
+#if 1
+       CheckPlayerElementChange(x, y, element, CE_PUSHED_BY_PLAYER);
+#else
        CheckPlayerElementChange(x + dx, y + dy, element, CE_PUSHED_BY_PLAYER);
+#endif
 
        break;
       }