X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame.c;h=9b91031193dda070ee3285f3f9c976682c80e8ab;hp=fd774e84c30b33e2c80ad0ae00346e2dc8fdf101;hb=8a5247c6a6ee1936c6fbd02e22731411c2d5051a;hpb=4666f6614557b1a47fda7442da7523519a4a1ac6 diff --git a/src/game.c b/src/game.c index fd774e84..9b910311 100644 --- a/src/game.c +++ b/src/game.c @@ -3358,14 +3358,15 @@ void InitGame(void) else FadeSetEnterScreen(); - if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged()) + if (CheckFadeAll()) fade_mask = REDRAW_ALL; FadeLevelSoundsAndMusic(); ExpireSoundLoops(TRUE); - FadeOut(fade_mask); + if (!level_editor_test_game) + FadeOut(fade_mask); // needed if different viewport properties defined for playing ChangeViewportPropertiesIfNeeded(); @@ -3401,6 +3402,7 @@ void InitGame(void) player->action = 0; player->effective_action = 0; player->programmed_action = 0; + player->snap_action = 0; player->mouse_action.lx = 0; player->mouse_action.ly = 0; @@ -3566,6 +3568,8 @@ void InitGame(void) game.LevelSolved = FALSE; game.GameOver = FALSE; + game.GamePlayed = !tape.playing; + game.LevelSolved_GameWon = FALSE; game.LevelSolved_GameEnd = FALSE; game.LevelSolved_SaveTape = FALSE; @@ -3735,6 +3739,19 @@ void InitGame(void) game.belt_dir_nr[i] = 3; // not moving, next moving left #if USE_NEW_PLAYER_ASSIGNMENTS + // use preferred player also in local single-player mode + if (!network.enabled && !game.team_mode) + { + int old_index_nr = local_player->index_nr; + int new_index_nr = setup.network_player_nr; + + if (new_index_nr >= 0 && new_index_nr < MAX_PLAYERS) + { + stored_player[old_index_nr].connected_locally = FALSE; + stored_player[new_index_nr].connected_locally = TRUE; + } + } + for (i = 0; i < MAX_PLAYERS; i++) { stored_player[i].connected = FALSE; @@ -4501,7 +4518,7 @@ void GameWon(void) int i; // do not start end game actions before the player stops moving (to exit) - if (local_player->MovPos) + if (local_player->active && local_player->MovPos) return; game.LevelSolved_GameWon = TRUE; @@ -11042,10 +11059,7 @@ static void CheckSingleStepMode(struct PlayerInfo *player) if (!player->is_moving && !player->is_pushing && !player->is_dropping_pressed) - { TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); - SnapField(player, 0, 0); // stop snapping - } } CheckSaveEngineSnapshot(player); @@ -11364,6 +11378,15 @@ static void GameActionsExt(void) SetVideoFrameDelay(game_frame_delay_value); + // (de)activate virtual buttons depending on current game status + if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS)) + { + if (game.all_players_gone) // if no players there to be controlled anymore + SetOverlayActive(FALSE); + else if (!tape.playing) // if game continues after tape stopped playing + SetOverlayActive(TRUE); + } + #if 0 #if 0 // ---------- main game synchronization point ---------- @@ -11474,6 +11497,10 @@ static void GameActionsExt(void) if (tape.recording) TapeRecordAction(tape_action); + // remember if game was played (especially after tape stopped playing) + if (!tape.playing && summarized_player_action) + game.GamePlayed = TRUE; + #if USE_NEW_PLAYER_ASSIGNMENTS // !!! also map player actions in single player mode !!! // if (game.team_mode) @@ -11967,7 +11994,7 @@ void GameActions_RND(void) element == EL_DC_MAGIC_WALL_FULL || element == EL_DC_MAGIC_WALL_ACTIVE || element == EL_DC_MAGIC_WALL_EMPTYING) && - ABS(x-jx) + ABS(y-jy) < ABS(magic_wall_x-jx) + ABS(magic_wall_y-jy)) + ABS(x - jx) + ABS(y - jy) < ABS(magic_wall_x - jx) + ABS(magic_wall_y - jy)) { magic_wall_x = x; magic_wall_y = y; @@ -12149,7 +12176,8 @@ void GameActions_RND(void) DrawAllPlayers(); PlayAllPlayersSound(); - if (local_player->show_envelope != 0 && local_player->MovPos == 0) + if (local_player->show_envelope != 0 && (!local_player->active || + local_player->MovPos == 0)) { ShowEnvelope(local_player->show_envelope - EL_ENVELOPE_1); @@ -12500,7 +12528,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) { if ((player->MovDir == MV_LEFT && scroll_x > jx - MIDPOSX + offset) || (player->MovDir == MV_RIGHT && scroll_x < jx - MIDPOSX - offset)) - scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset); + scroll_x = jx - MIDPOSX + (scroll_x < jx - MIDPOSX ? -offset : +offset); // don't scroll over playfield boundaries if (scroll_x < SBX_Left || scroll_x > SBX_Right) @@ -12518,7 +12546,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) { if ((player->MovDir == MV_UP && scroll_y > jy - MIDPOSY + offset) || (player->MovDir == MV_DOWN && scroll_y < jy - MIDPOSY - offset)) - scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset); + scroll_y = jy - MIDPOSY + (scroll_y < jy - MIDPOSY ? -offset : +offset); // don't scroll over playfield boundaries if (scroll_y < SBY_Upper || scroll_y > SBY_Lower) @@ -13436,6 +13464,9 @@ void RemovePlayer(struct PlayerInfo *player) player->present = FALSE; player->active = FALSE; + // required for some CE actions (even if the player is not active anymore) + player->MovPos = 0; + if (!ExplodeField[jx][jy]) StorePlayer[jx][jy] = 0; @@ -14958,7 +14989,12 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message) { // closing door required in case of envelope style request dialogs if (!skip_request) + { + // prevent short reactivation of overlay buttons while closing door + SetOverlayActive(FALSE); + CloseDoor(DOOR_CLOSE_1); + } if (network.enabled) SendToServer_StopPlaying(NETWORK_STOP_BY_PLAYER); @@ -15023,6 +15059,10 @@ void CheckGameOver(void) if (game.request_active) return; + // do not ask to play again if game was never actually played + if (!game.GamePlayed) + return; + if (!game_over) { last_game_over = FALSE;