rnd-20061125-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 25 Nov 2006 14:50:47 +0000 (15:50 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:53:47 +0000 (10:53 +0200)
* fixed infinite loop / crash bug when killing the player while having
  a CE with the setting "kill player X when explosion of <player X>"

ChangeLog
src/conftime.h
src/game.c
src/game.h

index dd4575c61f6269d74db66bf33f2c9576fd982af7..7215900b2d9539d450d77ec11b8fbcc8d385d324 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-11-25
+       * fixed infinite loop / crash bug when killing the player while having
+         a CE with the setting "kill player X when explosion of <player X>"
+
 2006-11-21
        * fixed nasty bug with initialization only done for the first player
 
index b7a1b2ad5e8bedc25cf47d10ac9f1610e65b0122..62492d1052bd7fcce507d424e7dbd948055add27 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2006-11-19 16:55]"
+#define COMPILE_DATE_STRING "[2006-11-25 15:47]"
index 61d5d6b2f313b7586c73527b7bafd7a19da749dd..a41363d1837fb06e63ad1bd140b80c9f743f5716 100644 (file)
@@ -1845,6 +1845,7 @@ void InitGame()
 
     player->present = FALSE;
     player->active = FALSE;
+    player->killed = FALSE;
 
     player->action = 0;
     player->effective_action = 0;
@@ -11059,6 +11060,21 @@ void KillPlayer(struct PlayerInfo *player)
   if (!player->active)
     return;
 
+  /* the following code was introduced to prevent an infinite loop when calling
+     -> Bang()
+     -> CheckTriggeredElementChangeExt()
+     -> ExecuteCustomElementAction()
+     -> KillPlayer()
+     -> (infinitely repeating the above sequence of function calls)
+     which occurs when killing the player while having a CE with the setting
+     "kill player X when explosion of <player X>"; the solution using a new
+     field "player->killed" was chosen for backwards compatibility, although
+     clever use of the fields "player->active" etc. would probably also work */
+  if (player->killed)
+    return;
+
+  player->killed = TRUE;
+
   /* remove accessible field at the player's position */
   Feld[jx][jy] = EL_EMPTY;
 
index 4532367944b698fb9d1a4396eece66ef9c15d58d..c7e70c315d2cd08b697e85dd52b9e0870befafe2 100644 (file)
@@ -96,6 +96,7 @@ struct PlayerInfo
   boolean present;             /* player present in level playfield */
   boolean connected;           /* player connected (locally or via network) */
   boolean active;              /* player present and connected */
+  boolean killed;              /* player maybe present/active, but killed */
 
   int index_nr;                        /* player number (0 to 3) */
   int index_bit;               /* player number bit (1 << 0 to 1 << 3) */