player->present = FALSE;
player->active = FALSE;
+ player->killed = FALSE;
player->action = 0;
player->effective_action = 0;
DrawGameValue_Score(score);
}
- if (ExitX >= 0 && ExitY >= 0) /* local player has left the level */
+ if (level.game_engine_type == GAME_ENGINE_TYPE_RND)
{
- /* close exit door after last player */
- if (AllPlayersGone &&
- (Feld[ExitX][ExitY] == EL_EXIT_OPEN ||
- Feld[ExitX][ExitY] == EL_SP_EXIT_OPEN))
+ if (ExitX >= 0 && ExitY >= 0) /* local player has left the level */
{
- int element = Feld[ExitX][ExitY];
-
- Feld[ExitX][ExitY] = (element == EL_EXIT_OPEN ? EL_EXIT_CLOSING :
- EL_SP_EXIT_CLOSING);
+ /* close exit door after last player */
+ if (AllPlayersGone &&
+ (Feld[ExitX][ExitY] == EL_EXIT_OPEN ||
+ Feld[ExitX][ExitY] == EL_SP_EXIT_OPEN))
+ {
+ int element = Feld[ExitX][ExitY];
- PlayLevelSoundElementAction(ExitX, ExitY, element, ACTION_CLOSING);
- }
+ Feld[ExitX][ExitY] = (element == EL_EXIT_OPEN ? EL_EXIT_CLOSING :
+ EL_SP_EXIT_CLOSING);
- /* player disappears */
- DrawLevelField(ExitX, ExitY);
- }
+ PlayLevelSoundElementAction(ExitX, ExitY, element, ACTION_CLOSING);
+ }
- for (i = 0; i < MAX_PLAYERS; i++)
- {
- struct PlayerInfo *player = &stored_player[i];
+ /* player disappears */
+ DrawLevelField(ExitX, ExitY);
+ }
- if (player->present)
+ for (i = 0; i < MAX_PLAYERS; i++)
{
- RemovePlayer(player);
+ struct PlayerInfo *player = &stored_player[i];
- /* player disappears */
- DrawLevelField(player->jx, player->jy);
+ if (player->present)
+ {
+ RemovePlayer(player);
+
+ /* player disappears */
+ DrawLevelField(player->jx, player->jy);
+ }
}
}
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;