From d622dbaa8d28574914b62457bdc518ca70b3ee21 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 25 Nov 2006 15:50:47 +0100 Subject: [PATCH] rnd-20061125-1-src * fixed infinite loop / crash bug when killing the player while having a CE with the setting "kill player X when explosion of " --- ChangeLog | 4 ++++ src/conftime.h | 2 +- src/game.c | 16 ++++++++++++++++ src/game.h | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dd4575c6..7215900b 100644 --- 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 " + 2006-11-21 * fixed nasty bug with initialization only done for the first player diff --git a/src/conftime.h b/src/conftime.h index b7a1b2ad..62492d10 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-11-19 16:55]" +#define COMPILE_DATE_STRING "[2006-11-25 15:47]" diff --git a/src/game.c b/src/game.c index 61d5d6b2..a41363d1 100644 --- a/src/game.c +++ b/src/game.c @@ -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 "; 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; diff --git a/src/game.h b/src/game.h index 45323679..c7e70c31 100644 --- a/src/game.h +++ b/src/game.h @@ -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) */ -- 2.34.1