+static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting)
+{
+ boolean was_waiting = player->is_waiting;
+
+ if (is_waiting)
+ {
+ int jx = player->jx, jy = player->jy;
+ int element = player->element_nr;
+ int action;
+
+ if (!was_waiting) /* not waiting -> waiting */
+ {
+ player->is_waiting = TRUE;
+ player->is_bored = FALSE;
+ player->is_sleeping = FALSE;
+
+ player->frame_counter_bored =
+ (FrameCounter +
+ game.player_boring_delay_fixed +
+ SimpleRND(game.player_boring_delay_random));
+ player->frame_counter_sleeping =
+ (FrameCounter +
+ game.player_sleeping_delay_fixed +
+ SimpleRND(game.player_sleeping_delay_random));
+
+ InitPlayerGfxAnimation(player, ACTION_WAITING, player->MovDir);
+ }
+
+ if (FrameCounter >= player->frame_counter_bored)
+ player->is_bored = TRUE;
+ if (FrameCounter >= player->frame_counter_sleeping)
+ player->is_sleeping = TRUE;
+
+ action = (player->is_sleeping ? ACTION_SLEEPING :
+ player->is_bored ? ACTION_BORING : ACTION_WAITING);
+
+ if (!was_waiting)
+ PlayLevelSoundElementAction(jx, jy, element, action);
+ else
+ PlayLevelSoundElementActionIfLoop(jx, jy, element, action);
+ }
+ else if (was_waiting) /* waiting -> not waiting */
+ {
+ player->is_waiting = FALSE;
+ player->is_bored = FALSE;
+ player->is_sleeping = FALSE;
+
+ player->frame_counter_bored = -1;
+ player->frame_counter_sleeping = -1;
+ }
+}
+