rnd-20040322-B-src
[rocksndiamonds.git] / src / game.c
index 5e5fe3ea5af646bd18f97feac68c7080dbb91366..6fc7f7bdc7dbd196ecfd616c94935a282f716466 100644 (file)
 
 #define GET_NEW_PUSH_DELAY(e)  (   (element_info[e].push_delay_fixed) + \
                                 RND(element_info[e].push_delay_random))
+#define GET_NEW_DROP_DELAY(e)  (   (element_info[e].drop_delay_fixed) + \
+                                RND(element_info[e].drop_delay_random))
 #define GET_NEW_MOVE_DELAY(e)  (   (element_info[e].move_delay_fixed) + \
                                 RND(element_info[e].move_delay_random))
 #define GET_MAX_MOVE_DELAY(e)  (   (element_info[e].move_delay_fixed) + \
@@ -1351,6 +1353,7 @@ static void InitGameEngine()
     element_info[e].move_stepsize = move_stepsize_list[i].move_stepsize;
   }
 
+#if 0
   /* ---------- initialize move dig/leave ---------------------------------- */
 
   for (i = 0; i < MAX_NUM_ELEMENTS; i++)
@@ -1358,6 +1361,7 @@ static void InitGameEngine()
     element_info[i].can_leave_element = FALSE;
     element_info[i].can_leave_element_last = FALSE;
   }
+#endif
 
   /* ---------- initialize gem count --------------------------------------- */
 
@@ -2090,6 +2094,11 @@ void InitMovDir(int x, int y)
 
              break;
            }
+
+#if 1
+           if (MovDir[x][y] == MV_NO_MOVING)   /* no start direction found */
+             MovDir[x][y] = 1 << RND(4);       /* => use random direction */
+#endif
          }
        }                
       }
@@ -2616,7 +2625,7 @@ void RelocatePlayer(int x, int y, int element_raw)
   int element = (element_raw == EL_SP_MURPHY ? EL_PLAYER_1 : element_raw);
   struct PlayerInfo *player = &stored_player[element - EL_PLAYER_1];
   boolean ffwd_delay = (tape.playing && tape.fast_forward);
-  boolean no_delay = (tape.index_search);
+  boolean no_delay = (tape.warp_forward);
   int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay);
   int wait_delay_value = (no_delay ? 0 : frame_delay_value);
   int old_jx, old_jy;
@@ -5333,11 +5342,30 @@ void StartMoving(int x, int y)
          {
            int flamed = MovingOrBlocked2Element(xx, yy);
 
+           /* !!! */
+#if 0
+           if (IS_CLASSIC_ENEMY(flamed) || CAN_EXPLODE_BY_DRAGONFIRE(flamed))
+             Bang(xx, yy);
+           else if (IS_MOVING(xx, yy) || IS_BLOCKED(xx, yy))
+             RemoveMovingField(xx, yy);
+           else
+             RemoveField(xx, yy);
+#else
            if (IS_CLASSIC_ENEMY(flamed) || CAN_EXPLODE_BY_DRAGONFIRE(flamed))
              Bang(xx, yy);
            else
              RemoveMovingField(xx, yy);
+#endif
+
+#if 0
+           if (ChangeDelay[xx][yy])
+             printf("::: !!! [%d]\n", (IS_MOVING(xx, yy) ||
+                                       Feld[xx][yy] == EL_BLOCKED));
+#endif
 
+#if 1
+           ChangeDelay[xx][yy] = 0;
+#endif
            Feld[xx][yy] = EL_FLAMES;
            if (IN_SCR_FIELD(sx, sy))
            {
@@ -5537,8 +5565,21 @@ void StartMoving(int x, int y)
        PlayLevelSoundAction(x, y, action);
       }
 
+#if 1
+#if 1
+      Store[newx][newy] = EL_EMPTY;
+      if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element)))
+       Store[newx][newy] = element_info[element].move_leave_element;
+#else
+      Store[newx][newy] = EL_EMPTY;
+      if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element)) ||
+         element_info[element].move_leave_type == LEAVE_TYPE_UNLIMITED)
+       Store[newx][newy] = element_info[element].move_leave_element;
+#endif
+#else
       if (IS_EQUAL_OR_IN_GROUP(new_element, MOVE_ENTER_EL(element)))
        element_info[element].can_leave_element = TRUE;
+#endif
 
       if (move_pattern & MV_MAZE_RUNNER_STYLE)
       {
@@ -5591,11 +5632,25 @@ void StartMoving(int x, int y)
 
          MovDelay[x][y] = 50;
 
+         /* !!! */
+#if 0
+         RemoveField(newx, newy);
+#endif
          Feld[newx][newy] = EL_FLAMES;
          if (IN_LEV_FIELD(newx1, newy1) && Feld[newx1][newy1] == EL_EMPTY)
+         {
+#if 0
+           RemoveField(newx1, newy1);
+#endif
            Feld[newx1][newy1] = EL_FLAMES;
+         }
          if (IN_LEV_FIELD(newx2, newy2) && Feld[newx2][newy2] == EL_EMPTY)
+         {
+#if 0
+           RemoveField(newx2, newy2);
+#endif
            Feld[newx2][newy2] = EL_FLAMES;
+         }
 
          return;
        }
@@ -5831,8 +5886,23 @@ void ContinueMoving(int x, int y)
   {
     element = Feld[newx][newy] = EL_ACID;
   }
+#if 1
+  else if (IS_CUSTOM_ELEMENT(element) && !IS_PLAYER(x, y) &&
+          ei->move_leave_element != EL_EMPTY &&
+          (ei->move_leave_type == LEAVE_TYPE_UNLIMITED ||
+           Store[x][y] != EL_EMPTY))
+  {
+    /* some elements can leave other elements behind after moving */
+
+    Feld[x][y] = ei->move_leave_element;
+    InitField(x, y, FALSE);
+
+    if (GFX_CRUMBLED(Feld[x][y]))
+      DrawLevelFieldCrumbledSandNeighbours(x, y);
+  }
+#endif
 
-  Store[x][y] = 0;
+  Store[x][y] = EL_EMPTY;
   MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0;
   MovDelay[newx][newy] = 0;
 
@@ -5860,7 +5930,7 @@ void ContinueMoving(int x, int y)
 
   ResetGfxAnimation(x, y);     /* reset animation values for old field */
 
-#if 1
+#if 0
   /* some elements can leave other elements behind after moving */
   if (IS_CUSTOM_ELEMENT(element) && !IS_PLAYER(x, y) &&
       ei->move_leave_element != EL_EMPTY &&
@@ -7733,7 +7803,7 @@ void GameActions()
   action_delay_value =
     (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay);
 
-  if (tape.playing && tape.index_search && !tape.pausing)
+  if (tape.playing && tape.warp_forward && !tape.pausing)
     action_delay_value = 0;
 
   /* ---------- main game synchronization point ---------- */
@@ -8702,7 +8772,9 @@ boolean MovePlayerOneStep(struct PlayerInfo *player,
 
   player->step_counter++;
 
+#if 0
   player->drop_delay = 0;
+#endif
 
   PlayerVisit[jx][jy] = FrameCounter;
 
@@ -10721,13 +10793,14 @@ boolean DropElement(struct PlayerInfo *player)
   int drop_direction = player->MovDir;
   int drop_side = trigger_sides[MV_DIR_BIT(drop_direction)];
   int old_element = Feld[jx][jy];
-  int new_element = (player->inventory_size > 0 ?
-                    player->inventory_element[player->inventory_size - 1] :
-                    player->inventory_infinite_element != EL_UNDEFINED ?
-                    player->inventory_infinite_element :
-                    player->dynabombs_left > 0 ?
-                    EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr :
-                    EL_UNDEFINED);
+  int drop_element = (player->inventory_size > 0 ?
+                     player->inventory_element[player->inventory_size - 1] :
+                     player->inventory_infinite_element != EL_UNDEFINED ?
+                     player->inventory_infinite_element :
+                     player->dynabombs_left > 0 ?
+                     EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr :
+                     EL_UNDEFINED);
+  int new_element = drop_element;      /* default: element does not change */
 
   /* check if player is active, not moving and ready to drop */
   if (!player->active || player->MovPos || player->drop_delay > 0)
@@ -10835,12 +10908,14 @@ boolean DropElement(struct PlayerInfo *player)
 #endif
   }
 
-  new_element = Feld[jx][jy];
+  new_element = Feld[jx][jy];          /* element might have changed */
 
   if (IS_CUSTOM_ELEMENT(new_element) && CAN_MOVE(new_element) &&
       element_info[new_element].move_pattern == MV_WHEN_DROPPED)
   {
+#if 0
     int move_stepsize = element_info[new_element].move_stepsize;
+#endif
     int direction, dx, dy, nextx, nexty;
 
     if (element_info[new_element].move_direction_initial == MV_START_AUTOMATIC)
@@ -10873,13 +10948,19 @@ boolean DropElement(struct PlayerInfo *player)
 #endif
     }
 
+#if 0
     player->drop_delay = 2 * TILEX / move_stepsize + 1;
+#endif
   }
 
 #if 0
   player->drop_delay = 8 + 8 + 8;
 #endif
 
+#if 1
+  player->drop_delay = GET_NEW_DROP_DELAY(drop_element);
+#endif
+
 #endif
 
   player->is_dropping = TRUE;
@@ -11105,21 +11186,15 @@ void RequestQuitGame(boolean ask_if_really_quit)
   {
 
 #if 1
-    if (tape.playing && tape.index_search)
-    {
-      SetDrawDeactivationMask(REDRAW_NONE);
-      audio.sound_deactivated = FALSE;
-    }
+    if (tape.playing && tape.deactivate_display)
+      TapeDeactivateDisplayOff(TRUE);
 #endif
 
     OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
 
 #if 1
-    if (tape.playing && tape.index_search)
-    {
-      SetDrawDeactivationMask(REDRAW_FIELD);
-      audio.sound_deactivated = TRUE;
-    }
+    if (tape.playing && tape.deactivate_display)
+      TapeDeactivateDisplayOn();
 #endif
 
   }