rnd-20051120-1-src
[rocksndiamonds.git] / src / game.c
index b0d7ec6bfd1a670820bce99d0111fd67b8c7db58..e3007408dd8b4f65da4ffddb77f446689f338357 100644 (file)
@@ -58,6 +58,8 @@
 
 #define USE_CHANGE_TO_TRIGGERED                (TRUE   * USE_NEW_STUFF         * 1)
 
+#define USE_BACK_WALKABLE_BUGFIX       (TRUE   * USE_NEW_STUFF         * 1)
+
 
 /* for DigField() */
 #define DF_NO_PUSH             0
@@ -7857,7 +7859,26 @@ static void ChangeActiveTrap(int x, int y)
     DrawLevelFieldCrumbledSand(x, y);
 }
 
-static void ChangeElementNowExt(int x, int y, int target_element)
+static void HandleChangeAction(int change_action)
+{
+  if (change_action == CA_EXIT_PLAYER)
+  {
+    printf("::: CA_EXIT_GAME\n");
+
+    /* !!! local_player <-> 4 players !!! (EXTEND THIS) !!! */
+    local_player->LevelSolved = local_player->GameOver = TRUE;
+  }
+  else if (change_action == CA_KILL_PLAYER)
+  {
+    printf("::: CA_KILL_PLAYER\n");
+
+    /* !!! local_player <-> 4 players !!! (EXTEND THIS) !!! */
+    KillHero(local_player);
+  }
+}
+
+static void ChangeElementNowExt(struct ElementChangeInfo *change,
+                               int x, int y, int target_element)
 {
   int previous_move_direction = MovDir[x][y];
 #if 1
@@ -7944,6 +7965,9 @@ static void ChangeElementNowExt(int x, int y, int target_element)
   TestIfPlayerTouchesCustomElement(x, y);
   TestIfElementTouchesCustomElement(x, y);
 #endif
+
+  if (change->use_change_action)
+    HandleChangeAction(change->change_action);
 }
 
 static boolean ChangeElementNow(int x, int y, int element, int page)
@@ -8125,7 +8149,7 @@ static boolean ChangeElementNow(int x, int y, int element, int page)
          content_element = change->target_content[xx][yy];
          target_element = GET_TARGET_ELEMENT(content_element, change);
 
-         ChangeElementNowExt(ex, ey, target_element);
+         ChangeElementNowExt(change, ex, ey, target_element);
 
          something_has_changed = TRUE;
 
@@ -8143,7 +8167,7 @@ static boolean ChangeElementNow(int x, int y, int element, int page)
   {
     target_element = GET_TARGET_ELEMENT(change->target_element, change);
 
-    ChangeElementNowExt(x, y, target_element);
+    ChangeElementNowExt(change, x, y, target_element);
 
     PlayLevelSoundElementAction(x, y, element, ACTION_CHANGING);
   }
@@ -11460,6 +11484,13 @@ int DigField(struct PlayerInfo *player,
 
   if (IS_TUBE(Back[jx][jy]) && game.engine_version >= VERSION_IDENT(2,2,0,0))
     old_element = Back[jx][jy];
+#if USE_BACK_WALKABLE_BUGFIX
+
+  /* in case of element dropped at player position, check background */
+  else if (Back[jx][jy] != EL_EMPTY &&
+          game.engine_version >= VERSION_IDENT(2,2,0,0))
+    old_element = Back[jx][jy];
+#endif
 
 #endif