rnd-20030702-2-src
authorHolger Schemel <info@artsoft.org>
Wed, 2 Jul 2003 09:36:17 +0000 (11:36 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:42:31 +0000 (10:42 +0200)
src/conftime.h
src/editor.c
src/game.c
src/main.h

index 36ed663ddf896dbd2705a5540551d49cd7dbffe6..6bc742d5806af6a1d4ac2a90bd4e35eab76241b1 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-07-02 01:03]"
+#define COMPILE_DATE_STRING "[2003-07-02 10:20]"
index c235a7c6bf4d5d5ee045319d10b815392bf97089..f13b9bf1943267335541bc8369fef62c7086ad1b 100644 (file)
 #define ED_AREA_ELEM_CONTENT4_YPOS     (ED_SETTINGS_YPOS(12) + \
                                         ED_GADGET_DISTANCE - MINI_TILEY)
 /* custom change trigger element */
-#define ED_AREA_ELEM_CONTENT5_XPOS     (30 * MINI_TILEX + MINI_TILEX / 2)
+#define ED_AREA_ELEM_CONTENT5_XPOS     (28 * MINI_TILEX)
 #define ED_AREA_ELEM_CONTENT5_YPOS     (ED_SETTINGS_YPOS(7) + \
                                         ED_GADGET_DISTANCE)
 /* extended custom change target */
@@ -1000,13 +1000,14 @@ static int value_change_collide_action = 0;
 
 static struct ValueTextInfo options_change_other_action[] =
 {
-  { CE_OTHER_COLLECTING,       "collecting"                    },
-  { CE_OTHER_TOUCHING,         "touching"                      },
-  { CE_OTHER_PRESSING,         "pressing"                      },
-  { CE_OTHER_PUSHING,          "pushing"                       },
-  { CE_OTHER_CHANGING,         "change of"                     },
-  { CE_OTHER_EXPLODING,                "explosion of"                  },
-  { -1,                                NULL                            }
+  { CE_OTHER_IS_TOUCHING,              "touching"                      },
+  { CE_OTHER_IS_CHANGING,              "change of"                     },
+  { CE_OTHER_IS_EXPLODING,             "explosion of"                  },
+  { CE_OTHER_GETS_TOUCHED,             "player touches"                },
+  { CE_OTHER_GETS_PRESSED,             "player presses"                },
+  { CE_OTHER_GETS_PUSHED,              "player pushes"                 },
+  { CE_OTHER_GETS_COLLECTED,           "player collects"               },
+  { -1,                                NULL                                    }
 };
 static int value_change_other_action = 0;
 
@@ -1135,7 +1136,7 @@ static struct
     -1,
     options_change_other_action,
     &value_change_other_action,
-    NULL, "other element:", "type of other element action"
+    NULL, "element:", "type of other element action"
   },
   {
     ED_SETTINGS_XPOS(2),               ED_SETTINGS_YPOS(10),
@@ -3682,7 +3683,7 @@ static void CopyCustomElementPropertiesToEditor(int element)
     (HAS_CHANGE_EVENT(element, CE_PUSHED_BY_PLAYER) ? CE_PUSHED_BY_PLAYER :
      HAS_CHANGE_EVENT(element, CE_PRESSED_BY_PLAYER) ? CE_PRESSED_BY_PLAYER :
      HAS_CHANGE_EVENT(element, CE_TOUCHED_BY_PLAYER) ? CE_TOUCHED_BY_PLAYER :
-     CE_PRESSED_BY_PLAYER);
+     CE_TOUCHED_BY_PLAYER);
 
   /* set change by impact/smash selectbox help value */
   value_change_collide_action =
@@ -3693,13 +3694,14 @@ static void CopyCustomElementPropertiesToEditor(int element)
 
   /* set change by other element action selectbox help value */
   value_change_other_action =
-    (HAS_CHANGE_EVENT(element, CE_OTHER_EXPLODING) ? CE_OTHER_EXPLODING :
-     HAS_CHANGE_EVENT(element, CE_OTHER_CHANGING) ? CE_OTHER_CHANGING :
-     HAS_CHANGE_EVENT(element, CE_OTHER_PUSHING) ? CE_OTHER_PUSHING :
-     HAS_CHANGE_EVENT(element, CE_OTHER_PRESSING) ? CE_OTHER_PRESSING :
-     HAS_CHANGE_EVENT(element, CE_OTHER_TOUCHING) ? CE_OTHER_TOUCHING :
-     HAS_CHANGE_EVENT(element, CE_OTHER_COLLECTING) ? CE_OTHER_COLLECTING :
-     CE_OTHER_COLLECTING);
+    (HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED :
+     HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PUSHED) ? CE_OTHER_GETS_PUSHED :
+     HAS_CHANGE_EVENT(element, CE_OTHER_GETS_PRESSED) ? CE_OTHER_GETS_PRESSED :
+     HAS_CHANGE_EVENT(element, CE_OTHER_GETS_TOUCHED) ? CE_OTHER_GETS_TOUCHED :
+     HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING :
+     HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING :
+     HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING :
+     CE_OTHER_IS_TOUCHING);
 }
 
 static void CopyCustomElementPropertiesToGame(int element)
@@ -3762,12 +3764,13 @@ static void CopyCustomElementPropertiesToGame(int element)
     custom_element_change_events[CE_BY_COLLISION];
 
   /* set other element action change event from checkbox and selectbox */
-  custom_element_change_events[CE_OTHER_COLLECTING] = FALSE;
-  custom_element_change_events[CE_OTHER_TOUCHING] = FALSE;
-  custom_element_change_events[CE_OTHER_PRESSING] = FALSE;
-  custom_element_change_events[CE_OTHER_PUSHING] = FALSE;
-  custom_element_change_events[CE_OTHER_CHANGING] = FALSE;
-  custom_element_change_events[CE_OTHER_EXPLODING] = FALSE;
+  custom_element_change_events[CE_OTHER_IS_TOUCHING] = FALSE;
+  custom_element_change_events[CE_OTHER_IS_CHANGING] = FALSE;
+  custom_element_change_events[CE_OTHER_IS_EXPLODING] = FALSE;
+  custom_element_change_events[CE_OTHER_GETS_TOUCHED] = FALSE;
+  custom_element_change_events[CE_OTHER_GETS_PRESSED] = FALSE;
+  custom_element_change_events[CE_OTHER_GETS_PUSHED] = FALSE;
+  custom_element_change_events[CE_OTHER_GETS_COLLECTED] = FALSE;
   custom_element_change_events[value_change_other_action] =
     custom_element_change_events[CE_BY_OTHER];
 
index 6326b223d920bae9a0879b70c65ecbf9ee31a9d8..1a143d4f706fec53a9f0ecc2839baef22fe846f6 100644 (file)
@@ -89,6 +89,9 @@
 #define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY((p)->move_delay_value))
 #define HALVE_PLAYER_SPEED(p)  (DOUBLE_MOVE_DELAY((p)->move_delay_value))
 
+/* values for other actions */
+#define MOVE_STEPSIZE_NORMAL   (TILEX / MOVE_DELAY_NORMAL_SPEED)
+
 #define        INIT_GFX_RANDOM()       (SimpleRND(1000000))
 
 #define GET_NEW_PUSH_DELAY(e)  (   (element_info[e].push_delay_fixed) + \
@@ -164,6 +167,7 @@ static void CheckGravityMovement(struct PlayerInfo *);
 static void KillHeroUnlessProtected(int, int);
 
 static void TestIfPlayerTouchesCustomElement(int, int);
+static void TestIfElementTouchesCustomElement(int, int);
 
 static boolean CheckTriggeredElementChange(int, int);
 static boolean CheckElementChange(int, int, int, int);
@@ -372,6 +376,25 @@ push_delay_list[] =
   { EL_UNDEFINED,              0, 0 },
 };
 
+struct
+{
+  int element;
+  int move_stepsize;
+}
+move_stepsize_list[] =
+{
+  { EL_AMOEBA_DROP,            2 },
+  { EL_AMOEBA_DROPPING,                2 },
+  { EL_QUICKSAND_FILLING,      1 },
+  { EL_QUICKSAND_EMPTYING,     1 },
+  { EL_MAGIC_WALL_FILLING,     2 },
+  { EL_BD_MAGIC_WALL_FILLING,  2 },
+  { EL_MAGIC_WALL_EMPTYING,    2 },
+  { EL_BD_MAGIC_WALL_EMPTYING, 2 },
+
+  { EL_UNDEFINED,              0 },
+};
+
 struct
 {
   int element;
@@ -379,17 +402,17 @@ struct
 }
 gem_count_list[] =
 {
-  { EL_EMERALD,                1 },
-  { EL_BD_DIAMOND,     1 },
-  { EL_EMERALD_YELLOW, 1 },
-  { EL_EMERALD_RED,    1 },
-  { EL_EMERALD_PURPLE, 1 },
-  { EL_DIAMOND,                3 },
-  { EL_SP_INFOTRON,    1 },
-  { EL_PEARL,          5 },
-  { EL_CRYSTAL,                8 },
-
-  { EL_UNDEFINED,      0 },
+  { EL_EMERALD,                        1 },
+  { EL_BD_DIAMOND,             1 },
+  { EL_EMERALD_YELLOW,         1 },
+  { EL_EMERALD_RED,            1 },
+  { EL_EMERALD_PURPLE,         1 },
+  { EL_DIAMOND,                        3 },
+  { EL_SP_INFOTRON,            1 },
+  { EL_PEARL,                  5 },
+  { EL_CRYSTAL,                        8 },
+
+  { EL_UNDEFINED,              0 },
 };
 
 static boolean changing_element[MAX_NUM_ELEMENTS];
@@ -399,7 +422,6 @@ static unsigned long trigger_events[MAX_NUM_ELEMENTS];
 #define IS_JUST_CHANGING(x, y) (ChangeDelay[x][y] != 0)
 #define IS_CHANGING(x, y)      (IS_AUTO_CHANGING(Feld[x][y]) || \
                                 IS_JUST_CHANGING(x, y))
-#define TRIGGERS_BY_COLLECTING(e) (trigger_events[e] & CE_OTHER_COLLECTING)
 
 
 void GetPlayerConfig()
@@ -848,6 +870,21 @@ static void InitGameEngine()
     element_info[e].push_delay_random = push_delay_list[i].push_delay_random;
   }
 
+  /* ---------- initialize move stepsize ----------------------------------- */
+
+  /* initialize move stepsize values to default */
+  for (i=0; i<MAX_NUM_ELEMENTS; i++)
+    if (!IS_CUSTOM_ELEMENT(i))
+      element_info[i].move_stepsize = MOVE_STEPSIZE_NORMAL;
+
+  /* set move stepsize value for certain elements from pre-defined list */
+  for (i=0; move_stepsize_list[i].element != EL_UNDEFINED; i++)
+  {
+    int e = move_stepsize_list[i].element;
+
+    element_info[e].move_stepsize = move_stepsize_list[i].move_stepsize;
+  }
+
   /* ---------- initialize gem count --------------------------------------- */
 
   /* initialize gem count values for each element */
@@ -2219,7 +2256,7 @@ void Bang(int x, int y)
       break;
   }
 
-  CheckTriggeredElementChange(element, CE_OTHER_EXPLODING);
+  CheckTriggeredElementChange(element, CE_OTHER_IS_EXPLODING);
 }
 
 void SplashAcid(int x, int y)
@@ -3969,23 +4006,21 @@ void ContinueMoving(int x, int y)
   int horiz_move = (dx != 0);
   int newx = x + dx, newy = y + dy;
   int nextx = newx + dx, nexty = newy + dy;
-  int step = (horiz_move ? dx : dy) * TILEX / MOVE_DELAY_NORMAL_SPEED;
 #if 1
-  boolean pushed = Pushed[x][y];
-#else
-  struct PlayerInfo *player = (IS_PLAYER(x, y) ? PLAYERINFO(x, y) : NULL);
-#if 0
-  boolean pushing = (player != NULL && player->Pushing && player->MovPos != 0);
+  int sign = (horiz_move ? dx : dy);
+  int step = sign * element_info[element].move_stepsize;
 #else
-  boolean pushing = (player != NULL && player->Pushing && player->is_moving);
-#endif
-#endif
-
-#if 0
-  if (player && player->is_moving && player->MovPos == 0)
-    printf("::: !!!\n");
+  int step = (horiz_move ? dx : dy) * MOVE_STEPSIZE_NORMAL;
 #endif
+  boolean pushed = Pushed[x][y];
 
+#if 1
+  if (CAN_FALL(element) && horiz_move &&
+      y < lev_fieldy - 1 && IS_BELT_ACTIVE(Feld[x][y + 1]))
+    step = sign * MOVE_STEPSIZE_NORMAL / 2;
+  else if (element == EL_SPRING && horiz_move)
+    step = sign * MOVE_STEPSIZE_NORMAL * 2;
+#else
   if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DROPPING)
     step /= 2;
   else if (element == EL_QUICKSAND_FILLING ||
@@ -4007,33 +4042,13 @@ void ContinueMoving(int x, int y)
 #if OLD_GAME_BEHAVIOUR
   else if (CAN_FALL(element) && horiz_move && !IS_SP_ELEMENT(element))
     step*=2;
+#endif
 #endif
 
   MovPos[x][y] += step;
 
-#if 1
-#if 1
   if (pushed)          /* special case: moving object pushed by player */
-#else
-  if (pushing)         /* special case: moving object pushed by player */
-#endif
-#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 (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 */
   {
@@ -4141,7 +4156,6 @@ void ContinueMoving(int x, int y)
 
     ResetGfxAnimation(x, y);   /* reset animation values for old field */
 
-#if 1
 #if 0
     /* 2.1.1 (does not work correctly for spring) */
     if (!CAN_MOVE(element))
@@ -4163,20 +4177,14 @@ void ContinueMoving(int x, int y)
        (CAN_FALL(element) && MovDir[newx][newy] == MV_DOWN))
       MovDir[newx][newy] = 0;
 #endif
-
-#endif
 #endif
 
     DrawLevelField(x, y);
     DrawLevelField(newx, newy);
 
-#if 0
-    if (game.engine_version >= RELEASE_IDENT(2,2,0,7) || !pushing)
-#endif
-      Stop[newx][newy] = TRUE; /* ignore this element until the next frame */
-#if 1
+    Stop[newx][newy] = TRUE;   /* ignore this element until the next frame */
+
     if (!pushed)       /* special case: moving object pushed by player */
-#endif
       JustStopped[newx][newy] = 3;
 
     if (DONT_TOUCH(element))   /* object may be nasty to player or others */
@@ -4188,29 +4196,15 @@ void ContinueMoving(int x, int y)
     else if (element == EL_PENGUIN)
       TestIfFriendTouchesBadThing(newx, newy);
 
-#if 1
     if (CAN_FALL(element) && direction == MV_DOWN &&
        (newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1)))
       Impact(x, newy);
-#else
-    if (CAN_SMASH(element) && direction == MV_DOWN &&
-       (newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1)))
-      Impact(x, newy);
-#endif
 
-#if 0
-    if (!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty))
-      CheckTriggeredElementChange(element, CE_COLLISION);
-#else
-#if 1
     if (!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty))
       CheckElementChange(newx, newy, element, CE_COLLISION);
-#else
-    if ((!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty)) &&
-       CAN_CHANGE(element) && HAS_CHANGE_EVENT(element, CE_COLLISION))
-      ChangeElementNow(newx, newy, element);
-#endif
-#endif
+
+    TestIfPlayerTouchesCustomElement(newx, newy);
+    TestIfElementTouchesCustomElement(newx, newy);
   }
   else                         /* still moving on */
   {
@@ -5156,7 +5150,7 @@ static void ChangeElementNow(int x, int y, int element)
 {
   struct ElementChangeInfo *change = &element_info[element].change;
 
-  CheckTriggeredElementChange(Feld[x][y], CE_OTHER_CHANGING);
+  CheckTriggeredElementChange(Feld[x][y], CE_OTHER_IS_CHANGING);
 
   if (change->explode)
   {
@@ -6411,11 +6405,55 @@ void TestIfPlayerTouchesCustomElement(int x, int y)
     int xx = x + xy[i][0];
     int yy = y + xy[i][1];
 
-    if (center_is_player && IN_LEV_FIELD(xx, yy))
+    if (!IN_LEV_FIELD(xx, yy))
+      continue;
+
+    if (center_is_player)
     {
-      CheckTriggeredElementChange(Feld[xx][yy], CE_OTHER_TOUCHING);
+      CheckTriggeredElementChange(Feld[xx][yy], CE_OTHER_GETS_TOUCHED);
       CheckElementChange(xx, yy, Feld[xx][yy], CE_TOUCHED_BY_PLAYER);
     }
+    else if (IS_PLAYER(xx, yy))
+    {
+      CheckTriggeredElementChange(Feld[x][y], CE_OTHER_GETS_TOUCHED);
+      CheckElementChange(x, y, Feld[x][y], CE_TOUCHED_BY_PLAYER);
+
+      break;
+    }
+  }
+}
+
+void TestIfElementTouchesCustomElement(int x, int y)
+{
+  static int xy[4][2] =
+  {
+    { 0, -1 },
+    { -1, 0 },
+    { +1, 0 },
+    { 0, +1 }
+  };
+  boolean center_is_custom = (IS_CUSTOM_ELEMENT(Feld[x][y]));
+  int i;
+
+  for (i=0; i<4; i++)
+  {
+    int xx = x + xy[i][0];
+    int yy = y + xy[i][1];
+
+    if (!IN_LEV_FIELD(xx, yy))
+      continue;
+
+    if (center_is_custom &&
+       Feld[xx][yy] == element_info[Feld[x][y]].change.trigger)
+    {
+      CheckElementChange(x, y, Feld[x][y], CE_OTHER_IS_TOUCHING);
+    }
+
+    if (IS_CUSTOM_ELEMENT(Feld[xx][yy]) &&
+       Feld[x][y] == element_info[Feld[xx][yy]].change.trigger)
+    {
+      CheckElementChange(xx, yy, Feld[xx][yy], CE_OTHER_IS_TOUCHING);
+    }
   }
 }
 
@@ -7166,7 +7204,7 @@ int DigField(struct PlayerInfo *player,
        RaiseScoreElement(element);
        PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING);
 
-       CheckTriggeredElementChange(element, CE_OTHER_COLLECTING);
+       CheckTriggeredElementChange(element, CE_OTHER_GETS_COLLECTED);
 
        break;
       }
@@ -7256,14 +7294,14 @@ int DigField(struct PlayerInfo *player,
        if (game.engine_version < RELEASE_IDENT(2,2,0,7))
          player->push_delay_value = GET_NEW_PUSH_DELAY(element);
 
-       CheckTriggeredElementChange(element, CE_OTHER_PUSHING);
+       CheckTriggeredElementChange(element, CE_OTHER_GETS_PUSHED);
        CheckElementChange(x, y, element, CE_PUSHED_BY_PLAYER);
 
        break;
       }
       else
       {
-       CheckTriggeredElementChange(element, CE_OTHER_PRESSING);
+       CheckTriggeredElementChange(element, CE_OTHER_GETS_PRESSED);
        CheckElementChange(x, y, element, CE_PRESSED_BY_PLAYER);
       }
 
index 4340d7c6485b68f1d382f1d31e1d185ebe3172fd..8dd07973ad26d5f8f2a833535f325c44ced666a7 100644 (file)
 #define CE_COLLISION           4
 #define CE_IMPACT              5
 #define CE_SMASHED             6
-#define CE_OTHER_COLLECTING    7
-#define CE_OTHER_TOUCHING      8
-#define CE_OTHER_PRESSING      9
-#define CE_OTHER_PUSHING       10
-#define CE_OTHER_CHANGING      11
-#define CE_OTHER_EXPLODING     12
+#define CE_OTHER_IS_TOUCHING   7
+#define CE_OTHER_IS_CHANGING   8
+#define CE_OTHER_IS_EXPLODING  9
+#define CE_OTHER_GETS_TOUCHED  10
+#define CE_OTHER_GETS_PRESSED  11
+#define CE_OTHER_GETS_PUSHED   12
+#define CE_OTHER_GETS_COLLECTED        13
 
 /* values for internal purpose only (level editor) */
-#define CE_BY_PLAYER           13
-#define CE_BY_COLLISION                14
-#define CE_BY_OTHER            15
+#define CE_BY_PLAYER           14
+#define CE_BY_COLLISION                15
+#define CE_BY_OTHER            16
 
-#define NUM_CHANGE_EVENTS      16
+#define NUM_CHANGE_EVENTS      17
 
 #define CE_BITMASK_DEFAULT     0