rnd-20030628-2-src
[rocksndiamonds.git] / src / game.c
index f29054575911e49267634b141081c3caba569368..30af0fcbbd7a50affb604b234f7da58d87e9e1bd 100644 (file)
                                        (condition)))
 
 #define ELEMENT_CAN_ENTER_FIELD(e, x, y)                               \
-       ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, 1)
+       ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, 0)
 
 #define ELEMENT_CAN_ENTER_FIELD_OR_ACID(e, x, y)                       \
        ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, (Feld[x][y] == EL_ACID))
@@ -1239,7 +1239,9 @@ void InitMovDir(int x, int y)
       {
        if (element_info[element].move_direction_initial != MV_NO_MOVING)
          MovDir[x][y] = element_info[element].move_direction_initial;
-       else if (element_info[element].move_pattern == MV_ALL_DIRECTIONS)
+       else if (element_info[element].move_pattern == MV_ALL_DIRECTIONS ||
+                element_info[element].move_pattern == MV_TURNING_LEFT ||
+                element_info[element].move_pattern == MV_TURNING_RIGHT)
          MovDir[x][y] = 1 << RND(4);
        else if (element_info[element].move_pattern == MV_HORIZONTAL)
          MovDir[x][y] = (RND(2) ? MV_LEFT : MV_RIGHT);
@@ -3045,12 +3047,18 @@ void TurnRound(int x, int y)
       }
     }
   }
-  else if (element_info[element].move_pattern == MV_ALL_DIRECTIONS)
+  else if (element_info[element].move_pattern == MV_ALL_DIRECTIONS ||
+          element_info[element].move_pattern == MV_TURNING_LEFT ||
+          element_info[element].move_pattern == MV_TURNING_RIGHT)
   {
     boolean can_turn_left  = ELEMENT_CAN_ENTER_FIELD(element, left_x, left_y);
     boolean can_turn_right = ELEMENT_CAN_ENTER_FIELD(element, right_x,right_y);
 
-    if (can_turn_left && can_turn_right)
+    if (element_info[element].move_pattern == MV_TURNING_LEFT)
+      MovDir[x][y] = left_dir;
+    else if (element_info[element].move_pattern == MV_TURNING_RIGHT)
+      MovDir[x][y] = right_dir;
+    else if (can_turn_left && can_turn_right)
       MovDir[x][y] = (RND(3) ? (RND(2) ? left_dir : right_dir) : back_dir);
     else if (can_turn_left)
       MovDir[x][y] = (RND(2) ? left_dir : back_dir);
@@ -3353,9 +3361,12 @@ void StartMoving(int x, int y)
             JustStopped[x][y])
 #endif
     {
-      /*
-      printf("::: %d\n", MovDir[x][y]);
-      */
+      /* calling "Impact()" here is not only completely unneccessary
+        (because it already gets called from "ContinueMoving()" in
+        all relevant situations), but also completely bullshit, because
+        "JustStopped" also indicates a finished *horizontal* movement;
+        we must keep this trash for backwards compatibility with older
+        tapes */
 
       Impact(x, y);
     }
@@ -3438,7 +3449,7 @@ void StartMoving(int x, int y)
     }
   }
 
-  /* not "else if" because of EL_SPRING */
+  /* not "else if" because of elements that can fall and move (EL_SPRING) */
   if (CAN_MOVE(element) && !started_moving)
   {
     int newx, newy;
@@ -3471,7 +3482,9 @@ void StartMoving(int x, int y)
       if (element != EL_YAMYAM &&
          element != EL_DARK_YAMYAM &&
          element != EL_PACMAN &&
-         !(element_info[element].move_pattern & MV_ANY_DIRECTION))
+         !(element_info[element].move_pattern & MV_ANY_DIRECTION) &&
+         element_info[element].move_pattern != MV_TURNING_LEFT &&
+         element_info[element].move_pattern != MV_TURNING_RIGHT)
       {
        TurnRound(x, y);
 
@@ -3994,17 +4007,25 @@ void ContinueMoving(int x, int y)
 
 #if 1
 #if 0
+    /* 2.1.1 (does not work correctly for spring) */
     if (!CAN_MOVE(element))
       MovDir[newx][newy] = 0;
 #else
 
 #if 0
+    /* (does not work for falling objects that slide horizontally) */
     if (CAN_FALL(element) && MovDir[newx][newy] == MV_DOWN)
       MovDir[newx][newy] = 0;
 #else
+    /*
     if (!CAN_MOVE(element) ||
        (element == EL_SPRING && MovDir[newx][newy] == MV_DOWN))
       MovDir[newx][newy] = 0;
+    */
+
+    if (!CAN_MOVE(element) ||
+       (CAN_FALL(element) && MovDir[newx][newy] == MV_DOWN))
+      MovDir[newx][newy] = 0;
 #endif
 
 #endif