X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame.c;h=09dc63fd73f158752a22eee66a69ac7ddeb717d1;hp=d3c403fe75b8ad7050dfcec0a4f91d07e53f581f;hb=aecdc1103c5dff9ef3900c213931d526df0cb3a7;hpb=d0409bd76aa84a8745ec2ea6d8a5480c8bea0bcd diff --git a/src/game.c b/src/game.c index d3c403fe..09dc63fd 100644 --- a/src/game.c +++ b/src/game.c @@ -19,6 +19,7 @@ #include "files.h" #include "tape.h" #include "network.h" +#include "anim.h" /* DEBUG SETTINGS */ @@ -3048,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) @@ -3102,9 +3104,6 @@ void InitGame() SetGameStatus(GAME_MODE_PLAYING); - /* needed if different viewport properties defined for playing */ - ChangeViewportPropertiesIfNeeded(); - if (level_editor_test_game) FadeSkipNextFadeIn(); else @@ -3119,6 +3118,9 @@ void InitGame() FadeOut(fade_mask); + /* needed if different viewport properties defined for playing */ + ChangeViewportPropertiesIfNeeded(); + ClearField(); OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); @@ -3211,6 +3213,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; @@ -10687,32 +10694,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()) + if (!CheckSaveEngineSnapshotToList()) 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; } } @@ -10957,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; @@ -11236,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]; @@ -14768,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 && @@ -14780,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() @@ -14997,7 +15015,7 @@ void FreeGameButtons() FreeGadget(game_gadget[i]); } -static void MapGameButtonsAtSamePosition(int id) +static void UnmapGameButtonsAtSamePosition(int id) { int i; @@ -15005,10 +15023,26 @@ static void MapGameButtonsAtSamePosition(int id) if (i != id && gamebutton_info[i].pos->x == gamebutton_info[id].pos->x && gamebutton_info[i].pos->y == gamebutton_info[id].pos->y) - MapGadget(game_gadget[i]); + UnmapGadget(game_gadget[i]); } -static void UnmapGameButtonsAtSamePosition(int id) +static void UnmapGameButtonsAtSamePosition_All() +{ + if (setup.show_snapshot_buttons) + { + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_SAVE); + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_PAUSE2); + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_LOAD); + } + else + { + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_STOP); + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_PAUSE); + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_PLAY); + } +} + +static void MapGameButtonsAtSamePosition(int id) { int i; @@ -15016,7 +15050,9 @@ static void UnmapGameButtonsAtSamePosition(int id) if (i != id && gamebutton_info[i].pos->x == gamebutton_info[id].pos->x && gamebutton_info[i].pos->y == gamebutton_info[id].pos->y) - UnmapGadget(game_gadget[i]); + MapGadget(game_gadget[i]); + + UnmapGameButtonsAtSamePosition_All(); } void MapUndoRedoButtons() @@ -15026,6 +15062,8 @@ void MapUndoRedoButtons() MapGadget(game_gadget[GAME_CTRL_ID_UNDO]); MapGadget(game_gadget[GAME_CTRL_ID_REDO]); + + ModifyGadget(game_gadget[GAME_CTRL_ID_PAUSE2], GDI_CHECKED, TRUE, GDI_END); } void UnmapUndoRedoButtons() @@ -15035,6 +15073,8 @@ void UnmapUndoRedoButtons() MapGameButtonsAtSamePosition(GAME_CTRL_ID_UNDO); MapGameButtonsAtSamePosition(GAME_CTRL_ID_REDO); + + ModifyGadget(game_gadget[GAME_CTRL_ID_PAUSE2], GDI_CHECKED, FALSE, GDI_END); } void MapGameButtons() @@ -15046,18 +15086,7 @@ void MapGameButtons() i != GAME_CTRL_ID_REDO) MapGadget(game_gadget[i]); - if (setup.show_snapshot_buttons) - { - UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_SAVE); - UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_PAUSE2); - UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_LOAD); - } - else - { - UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_STOP); - UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_PAUSE); - UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_PLAY); - } + UnmapGameButtonsAtSamePosition_All(); RedrawGameButtons(); } @@ -15093,8 +15122,7 @@ void GameUndoRedoExt() DrawCompleteVideoDisplay(); DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime); DrawVideoDisplay(VIDEO_STATE_FRAME_ON, FrameCounter); - DrawVideoDisplay((tape.single_step ? VIDEO_STATE_1STEP_ON : - VIDEO_STATE_1STEP_OFF), 0); + DrawVideoDisplay(VIDEO_STATE_1STEP(tape.single_step), 0); BackToFront(); } @@ -15173,7 +15201,7 @@ static void HandleGameButtonsExt(int id, int button) SendToServer_ContinuePlaying(); else #endif - TapeTogglePause(TAPE_TOGGLE_MANUAL); + TapeTogglePause(TAPE_TOGGLE_MANUAL | TAPE_TOGGLE_PLAY_PAUSE); } break;