From: Holger Schemel Date: Sat, 17 Sep 2016 14:20:58 +0000 (+0200) Subject: replaced local static variables with variables stored in engine snapshots X-Git-Tag: 4.0.0.0~42 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=37dc6b231b7e6cd2aeab259ebe52be365b7f3c17;p=rocksndiamonds.git replaced local static variables with variables stored in engine snapshots --- diff --git a/src/game.c b/src/game.c index 1b7eaa3b..e0e44eb4 100644 --- a/src/game.c +++ b/src/game.c @@ -3212,6 +3212,11 @@ void InitGame() player->is_bored = FALSE; player->is_sleeping = FALSE; + player->was_waiting = TRUE; + player->was_moving = FALSE; + player->was_snapping = FALSE; + player->was_dropping = FALSE; + player->frame_counter_bored = -1; player->frame_counter_sleeping = -1; @@ -10688,32 +10693,28 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting) static void CheckSaveEngineSnapshot(struct PlayerInfo *player) { - static boolean player_was_moving = FALSE; - static boolean player_was_snapping = FALSE; - static boolean player_was_dropping = FALSE; - - if ((!player->is_moving && player_was_moving) || - (player->MovPos == 0 && player_was_moving) || - (player->is_snapping && !player_was_snapping) || - (player->is_dropping && !player_was_dropping)) + if ((!player->is_moving && player->was_moving) || + (player->MovPos == 0 && player->was_moving) || + (player->is_snapping && !player->was_snapping) || + (player->is_dropping && !player->was_dropping)) { if (!SaveEngineSnapshotToList()) return; - player_was_moving = FALSE; - player_was_snapping = TRUE; - player_was_dropping = TRUE; + player->was_moving = FALSE; + player->was_snapping = TRUE; + player->was_dropping = TRUE; } else { if (player->is_moving) - player_was_moving = TRUE; + player->was_moving = TRUE; if (!player->is_snapping) - player_was_snapping = FALSE; + player->was_snapping = FALSE; if (!player->is_dropping) - player_was_dropping = FALSE; + player->was_dropping = FALSE; } } diff --git a/src/game.h b/src/game.h index 5e3bc7ef..cd388da7 100644 --- a/src/game.h +++ b/src/game.h @@ -272,6 +272,11 @@ struct PlayerInfo boolean is_bored; boolean is_sleeping; + boolean was_waiting; + boolean was_moving; + boolean was_snapping; + boolean was_dropping; + boolean cannot_move; int frame_counter_bored; diff --git a/src/tools.c b/src/tools.c index 959063c8..fe14158f 100644 --- a/src/tools.c +++ b/src/tools.c @@ -8033,42 +8033,38 @@ void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame, boolean any_player_snapping, boolean any_player_dropping) { - static boolean player_was_waiting = TRUE; - if (frame == 0 && !any_player_dropping) { - if (!player_was_waiting) + if (!local_player->was_waiting) { if (!SaveEngineSnapshotToList()) return; - player_was_waiting = TRUE; + local_player->was_waiting = TRUE; } } else if (any_player_moving || any_player_snapping || any_player_dropping) { - player_was_waiting = FALSE; + local_player->was_waiting = FALSE; } } void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting, boolean murphy_is_dropping) { - static boolean player_was_waiting = TRUE; - if (murphy_is_waiting) { - if (!player_was_waiting) + if (!local_player->was_waiting) { if (!SaveEngineSnapshotToList()) return; - player_was_waiting = TRUE; + local_player->was_waiting = TRUE; } } else { - player_was_waiting = FALSE; + local_player->was_waiting = FALSE; } }