X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=6a8967685317b411cd256feb9d8fba756c639555;hb=957e1f3bce8fd0bfa083e5932d27a2298478020e;hp=82931d3f3bc55fb9888fbc314604685c6ae700f9;hpb=9fa601d400aa71f38fcdc19eaf107f42e0d2a2a3;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 82931d3f..6a896768 100644 --- a/src/game.c +++ b/src/game.c @@ -3044,8 +3044,6 @@ static void InitGameEngine() SNAPSHOT_MODE_EVERY_STEP : strEqual(setup.engine_snapshot_mode, STR_SNAPSHOT_MODE_EVERY_MOVE) ? SNAPSHOT_MODE_EVERY_MOVE : SNAPSHOT_MODE_OFF); - - FreeEngineSnapshotList(); } int get_num_special_action(int element, int action_first, int action_last) @@ -3918,8 +3916,6 @@ void InitGame() /* blit playfield from scroll buffer to normal back buffer for fading in */ BlitScreenToBitmap(backbuffer); - - redraw_mask |= REDRAW_FROM_BACKBUFFER; /* !!! FIX THIS (END) !!! */ FadeIn(REDRAW_FIELD); @@ -4007,7 +4003,7 @@ void InitGame() game.restart_level = FALSE; - SaveEngineSnapshotToList(); + SaveEngineSnapshotToListInitial(); } void UpdateEngineValues(int actual_scroll_x, int actual_scroll_y) @@ -4394,13 +4390,16 @@ void GameEnd() local_player->LevelSolved_GameEnd = TRUE; - CloseDoor(DOOR_CLOSE_1); + if (!global.use_envelope_request) + CloseDoor(DOOR_CLOSE_1); if (local_player->LevelSolved_SaveTape) { SaveTapeChecked(tape.level_nr); /* ask to save tape */ } + CloseDoor(DOOR_CLOSE_ALL); + if (level_editor_test_game) { game_status = GAME_MODE_MAIN; @@ -4435,6 +4434,9 @@ void GameEnd() { game_status = GAME_MODE_SCORES; + /* needed if different viewport properties defined for scores */ + ChangeViewportPropertiesIfNeeded(); + DrawHallOfFame(hi_pos); if (raise_level) @@ -11190,7 +11192,32 @@ void GameActions() } else { - GameActions_RND(); + GameActions_RND_Main(); + } + + BlitScreenToBitmap(backbuffer); + + CheckLevelTime(); + + AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */ + + if (options.debug) /* calculate frames per second */ + { + static unsigned int fps_counter = 0; + static int fps_frames = 0; + unsigned int fps_delay_ms = Counter() - fps_counter; + + fps_frames++; + + if (fps_delay_ms >= 500) /* calculate fps every 0.5 seconds */ + { + global.frames_per_second = 1000 * (float)fps_frames / fps_delay_ms; + + fps_frames = 0; + fps_counter = Counter(); + } + + redraw_mask |= REDRAW_FPS; } } @@ -11204,10 +11231,6 @@ void GameActions_EM_Main() effective_action[i] = stored_player[i].effective_action; GameActions_EM(effective_action, warp_mode); - - CheckLevelTime(); - - AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */ } void GameActions_SP_Main() @@ -11220,10 +11243,11 @@ void GameActions_SP_Main() effective_action[i] = stored_player[i].effective_action; GameActions_SP(effective_action, warp_mode); +} - CheckLevelTime(); - - AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */ +void GameActions_RND_Main() +{ + GameActions_RND(); } void GameActions_RND() @@ -11725,32 +11749,9 @@ void GameActions_RND() } #endif - CheckLevelTime(); - DrawAllPlayers(); PlayAllPlayersSound(); - if (options.debug) /* calculate frames per second */ - { - static unsigned int fps_counter = 0; - static int fps_frames = 0; - unsigned int fps_delay_ms = Counter() - fps_counter; - - fps_frames++; - - if (fps_delay_ms >= 500) /* calculate fps every 0.5 seconds */ - { - global.frames_per_second = 1000 * (float)fps_frames / fps_delay_ms; - - fps_frames = 0; - fps_counter = Counter(); - } - - redraw_mask |= REDRAW_FPS; - } - - AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */ - if (local_player->show_envelope != 0 && local_player->MovPos == 0) { ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1); @@ -11804,16 +11805,16 @@ static boolean AllPlayersInVisibleScreen() void ScrollLevel(int dx, int dy) { - int softscroll_offset = (setup.soft_scrolling ? 2 * TILEX_VAR : 0); + int scroll_offset = 2 * TILEX_VAR; int x, y; BlitBitmap(drawto_field, drawto_field, - FX + TILEX_VAR * (dx == -1) - softscroll_offset, - FY + TILEY_VAR * (dy == -1) - softscroll_offset, - SXSIZE - TILEX_VAR * (dx != 0) + 2 * softscroll_offset, - SYSIZE - TILEY_VAR * (dy != 0) + 2 * softscroll_offset, - FX + TILEX_VAR * (dx == 1) - softscroll_offset, - FY + TILEY_VAR * (dy == 1) - softscroll_offset); + FX + TILEX_VAR * (dx == -1) - scroll_offset, + FY + TILEY_VAR * (dy == -1) - scroll_offset, + SXSIZE - TILEX_VAR * (dx != 0) + 2 * scroll_offset, + SYSIZE - TILEY_VAR * (dy != 0) + 2 * scroll_offset, + FX + TILEX_VAR * (dx == 1) - scroll_offset, + FY + TILEY_VAR * (dy == 1) - scroll_offset); if (dx != 0) { @@ -14722,11 +14723,6 @@ ListNode *SaveEngineSnapshotBuffers() SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(scroll_x)); SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(scroll_y)); - /* save level identification information */ - - setString(&snapshot_level_identifier, leveldir_current->identifier); - snapshot_level_nr = level_nr; - #if 0 ListNode *node = engine_snapshot_list_rnd; int num_bytes = 0; @@ -14750,19 +14746,25 @@ void SaveEngineSnapshotSingle() /* finally save all snapshot buffers to single snapshot */ SaveSnapshotSingle(buffers); + + /* save level identification information */ + setString(&snapshot_level_identifier, leveldir_current->identifier); + snapshot_level_nr = level_nr; } -boolean SaveEngineSnapshotToList() +static boolean SaveEngineSnapshotToListExt(boolean initial_snapshot) { boolean save_snapshot = - (FrameCounter == 0 || + (initial_snapshot || (game.snapshot.mode == SNAPSHOT_MODE_EVERY_STEP) || (game.snapshot.mode == SNAPSHOT_MODE_EVERY_MOVE && game.snapshot.changed_action)); game.snapshot.changed_action = FALSE; - if (game.snapshot.mode == SNAPSHOT_MODE_OFF || !save_snapshot) + if (game.snapshot.mode == SNAPSHOT_MODE_OFF || + tape.quick_resume || + !save_snapshot) return FALSE; ListNode *buffers = SaveEngineSnapshotBuffers(); @@ -14773,6 +14775,18 @@ boolean SaveEngineSnapshotToList() return TRUE; } +boolean SaveEngineSnapshotToList() +{ + return SaveEngineSnapshotToListExt(FALSE); +} + +void SaveEngineSnapshotToListInitial() +{ + FreeEngineSnapshotList(); + + SaveEngineSnapshotToListExt(TRUE); +} + void LoadEngineSnapshotValues() { /* restore special values from snapshot structure */ @@ -14961,22 +14975,48 @@ void FreeGameButtons() FreeGadget(game_gadget[i]); } -void MapStopPlayButtons() +static void MapGameButtonsAtSamePosition(int id) { - UnmapGadget(game_gadget[GAME_CTRL_ID_UNDO]); - UnmapGadget(game_gadget[GAME_CTRL_ID_REDO]); + int i; - MapGadget(game_gadget[GAME_CTRL_ID_STOP]); - MapGadget(game_gadget[GAME_CTRL_ID_PLAY]); + for (i = 0; i < NUM_GAME_BUTTONS; i++) + 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]); +} + +static void UnmapGameButtonsAtSamePosition(int id) +{ + int i; + + for (i = 0; i < NUM_GAME_BUTTONS; i++) + 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]); } void MapUndoRedoButtons() { - UnmapGadget(game_gadget[GAME_CTRL_ID_STOP]); - UnmapGadget(game_gadget[GAME_CTRL_ID_PLAY]); + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_UNDO); + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_REDO); + UnmapGameButtonsAtSamePosition(GAME_CTRL_ID_PLAY); MapGadget(game_gadget[GAME_CTRL_ID_UNDO]); MapGadget(game_gadget[GAME_CTRL_ID_REDO]); + MapGadget(game_gadget[GAME_CTRL_ID_PLAY]); +} + +void UnmapUndoRedoButtons() +{ + UnmapGadget(game_gadget[GAME_CTRL_ID_UNDO]); + UnmapGadget(game_gadget[GAME_CTRL_ID_REDO]); + UnmapGadget(game_gadget[GAME_CTRL_ID_PLAY]); + + MapGameButtonsAtSamePosition(GAME_CTRL_ID_UNDO); + MapGameButtonsAtSamePosition(GAME_CTRL_ID_REDO); + MapGameButtonsAtSamePosition(GAME_CTRL_ID_PLAY); } void MapGameButtons() @@ -14985,7 +15025,8 @@ void MapGameButtons() for (i = 0; i < NUM_GAME_BUTTONS; i++) if (i != GAME_CTRL_ID_UNDO && - i != GAME_CTRL_ID_REDO) + i != GAME_CTRL_ID_REDO && + i != GAME_CTRL_ID_PLAY) MapGadget(game_gadget[i]); } @@ -15095,10 +15136,7 @@ static void HandleGameButtonsExt(int id, int button) SendToServer_ContinuePlaying(); else #endif - { - tape.pausing = FALSE; - DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF, 0); - } + TapeTogglePause(TAPE_TOGGLE_MANUAL); } break;