From: Holger Schemel Date: Sat, 17 Sep 2016 14:37:12 +0000 (+0200) Subject: fixed saving game engine snapshots (save after game actions are finished) X-Git-Tag: 4.0.0.0~41 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=aecdc1103c5dff9ef3900c213931d526df0cb3a7;p=rocksndiamonds.git fixed saving game engine snapshots (save after game actions are finished) --- diff --git a/src/game.c b/src/game.c index e0e44eb4..09dc63fd 100644 --- a/src/game.c +++ b/src/game.c @@ -3049,6 +3049,7 @@ static void InitGameEngine() SNAPSHOT_MODE_EVERY_MOVE : strEqual(setup.engine_snapshot_mode, STR_SNAPSHOT_MODE_EVERY_COLLECT) ? SNAPSHOT_MODE_EVERY_COLLECT : SNAPSHOT_MODE_OFF); + game.snapshot.save_snapshot = FALSE; } int get_num_special_action(int element, int action_first, int action_last) @@ -10698,7 +10699,7 @@ static void CheckSaveEngineSnapshot(struct PlayerInfo *player) (player->is_snapping && !player->was_snapping) || (player->is_dropping && !player->was_dropping)) { - if (!SaveEngineSnapshotToList()) + if (!CheckSaveEngineSnapshotToList()) return; player->was_moving = FALSE; @@ -10959,7 +10960,7 @@ void StartGameActions(boolean init_network_game, boolean record_tape, InitGame(); } -void GameActions() +void GameActionsExt() { #if 0 static unsigned int game_frame_delay = 0; @@ -11238,6 +11239,24 @@ void GameActions() } } +static void GameActions_CheckSaveEngineSnapshot() +{ + if (!game.snapshot.save_snapshot) + return; + + // clear flag for saving snapshot _before_ saving snapshot + game.snapshot.save_snapshot = FALSE; + + SaveEngineSnapshotToList(); +} + +void GameActions() +{ + GameActionsExt(); + + GameActions_CheckSaveEngineSnapshot(); +} + void GameActions_EM_Main() { byte effective_action[MAX_PLAYERS]; @@ -14770,11 +14789,10 @@ void SaveEngineSnapshotSingle() snapshot_level_nr = level_nr; } -static boolean SaveEngineSnapshotToListExt(boolean initial_snapshot) +boolean CheckSaveEngineSnapshotToList() { boolean save_snapshot = - (initial_snapshot || - (game.snapshot.mode == SNAPSHOT_MODE_EVERY_STEP) || + ((game.snapshot.mode == SNAPSHOT_MODE_EVERY_STEP) || (game.snapshot.mode == SNAPSHOT_MODE_EVERY_MOVE && game.snapshot.changed_action) || (game.snapshot.mode == SNAPSHOT_MODE_EVERY_COLLECT && @@ -14782,30 +14800,28 @@ static boolean SaveEngineSnapshotToListExt(boolean initial_snapshot) game.snapshot.changed_action = FALSE; game.snapshot.collected_item = FALSE; + game.snapshot.save_snapshot = save_snapshot; + + return save_snapshot; +} +void SaveEngineSnapshotToList() +{ if (game.snapshot.mode == SNAPSHOT_MODE_OFF || - tape.quick_resume || - !save_snapshot) - return FALSE; + tape.quick_resume) + return; ListNode *buffers = SaveEngineSnapshotBuffers(); /* finally save all snapshot buffers to snapshot list */ SaveSnapshotToList(buffers); - - return TRUE; -} - -boolean SaveEngineSnapshotToList() -{ - return SaveEngineSnapshotToListExt(FALSE); } void SaveEngineSnapshotToListInitial() { FreeEngineSnapshotList(); - SaveEngineSnapshotToListExt(TRUE); + SaveEngineSnapshotToList(); } void LoadEngineSnapshotValues() diff --git a/src/game.h b/src/game.h index cd388da7..2f21455f 100644 --- a/src/game.h +++ b/src/game.h @@ -122,6 +122,8 @@ struct GameSnapshotInfo byte last_action[MAX_PLAYERS]; boolean changed_action; boolean collected_item; + + boolean save_snapshot; }; struct GameInfo @@ -386,7 +388,8 @@ void FreeEngineSnapshotSingle(); void FreeEngineSnapshotList(); void LoadEngineSnapshotSingle(); void SaveEngineSnapshotSingle(); -boolean SaveEngineSnapshotToList(); +boolean CheckSaveEngineSnapshotToList(); +void SaveEngineSnapshotToList(); void SaveEngineSnapshotToListInitial(); boolean CheckEngineSnapshotSingle(); boolean CheckEngineSnapshotList(); diff --git a/src/tools.c b/src/tools.c index fe14158f..e534cc29 100644 --- a/src/tools.c +++ b/src/tools.c @@ -8037,7 +8037,7 @@ void CheckSaveEngineSnapshot_EM(byte action[MAX_PLAYERS], int frame, { if (!local_player->was_waiting) { - if (!SaveEngineSnapshotToList()) + if (!CheckSaveEngineSnapshotToList()) return; local_player->was_waiting = TRUE; @@ -8056,7 +8056,7 @@ void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting, { if (!local_player->was_waiting) { - if (!SaveEngineSnapshotToList()) + if (!CheckSaveEngineSnapshotToList()) return; local_player->was_waiting = TRUE;