X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame.c;h=96fa321fb09a10f26898014f98dfd79846f3a7fa;hp=02331879311f3a7680e95bcd80e3a37148220f0e;hb=70fe541d68f18a22eb3bd134f128c0d56b885701;hpb=7f515c3d57a5cc2d551564531c75f7be2e15c863 diff --git a/src/game.c b/src/game.c index 02331879..96fa321f 100644 --- a/src/game.c +++ b/src/game.c @@ -1731,7 +1731,7 @@ static void InitPlayerField(int x, int y, int element, boolean init_game) if (game.use_block_last_field_bug) player->block_delay_adjustment = (player->block_last_field ? -1 : 1); - if (!options.network || player->connected) + if (!options.network || player->connected_network) { player->active = TRUE; @@ -3305,17 +3305,18 @@ void InitGame() ExpireSoundLoops(TRUE); - FadeOut(fade_mask); + if (!level_editor_test_game) + FadeOut(fade_mask); /* needed if different viewport properties defined for playing */ ChangeViewportPropertiesIfNeeded(); ClearField(); - OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); - DrawCompleteVideoDisplay(); + OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); + InitGameEngine(); InitGameControlValues(); @@ -3344,10 +3345,12 @@ void InitGame() player->mouse_action.lx = 0; player->mouse_action.ly = 0; player->mouse_action.button = 0; + player->mouse_action.button_hint = 0; player->effective_mouse_action.lx = 0; player->effective_mouse_action.ly = 0; player->effective_mouse_action.button = 0; + player->effective_mouse_action.button_hint = 0; player->score = 0; player->score_final = 0; @@ -3542,18 +3545,6 @@ void InitGame() game.envelope_active = FALSE; - /* set focus to local player for network games, else to all players */ - game.centered_player_nr = (network_playing ? local_player->index_nr : -1); - game.centered_player_nr_next = game.centered_player_nr; - game.set_centered_player = FALSE; - - if (network_playing && tape.recording) - { - /* store client dependent player focus when recording network games */ - tape.centered_player_nr_next = game.centered_player_nr_next; - tape.set_centered_player = TRUE; - } - for (i = 0; i < NUM_BELTS; i++) { game.belt_dir[i] = MV_NONE; @@ -3567,6 +3558,24 @@ void InitGame() if (options.debug) { printf("Player status at level initialization:\n"); + + for (i = 0; i < MAX_PLAYERS; i++) + { + struct PlayerInfo *player = &stored_player[i]; + + printf("- player %d: present == %d, connected == %d [%d/%d], active == %d", + i + 1, + player->present, + player->connected, + player->connected_locally, + player->connected_network, + player->active); + + if (local_player == player) + printf(" (local player)"); + + printf("\n"); + } } #endif @@ -3681,22 +3690,33 @@ void InitGame() game.belt_dir_nr[i] = 3; /* not moving, next moving left */ #if USE_NEW_PLAYER_ASSIGNMENTS - /* !!! SAME AS init.c:InitPlayerInfo() -- FIX THIS !!! */ - /* choose default local player */ - local_player = &stored_player[0]; - for (i = 0; i < MAX_PLAYERS; i++) + { stored_player[i].connected = FALSE; - local_player->connected = TRUE; - /* !!! SAME AS init.c:InitPlayerInfo() -- FIX THIS !!! */ + /* in network game mode, the local player might not be the first player */ + if (stored_player[i].connected_locally) + local_player = &stored_player[i]; + } + + if (!options.network) + local_player->connected = TRUE; if (tape.playing) { for (i = 0; i < MAX_PLAYERS; i++) stored_player[i].connected = tape.player_participates[i]; } - else if (game.team_mode && !options.network) + else if (options.network) + { + /* add team mode players connected over the network (needed for correct + assignment of player figures from level to locally playing players) */ + + for (i = 0; i < MAX_PLAYERS; i++) + if (stored_player[i].connected_network) + stored_player[i].connected = TRUE; + } + else if (game.team_mode) { /* try to guess locally connected team mode players (needed for correct assignment of player figures from level to locally playing players) */ @@ -3716,10 +3736,12 @@ void InitGame() { struct PlayerInfo *player = &stored_player[i]; - printf("- player %d: present == %d, connected == %d, active == %d", + printf("- player %d: present == %d, connected == %d [%d/%d], active == %d", i + 1, player->present, player->connected, + player->connected_locally, + player->connected_network, player->active); if (local_player == player) @@ -3822,10 +3844,12 @@ void InitGame() { struct PlayerInfo *player = &stored_player[i]; - printf("- player %d: present == %d, connected == %d, active == %d", + printf("- player %d: present == %d, connected == %d [%d/%d], active == %d", i + 1, player->present, player->connected, + player->connected_locally, + player->connected_network, player->active); if (local_player == player) @@ -3881,6 +3905,18 @@ void InitGame() printf("::: local_player->present == %d\n", local_player->present); #endif + /* set focus to local player for network games, else to all players */ + game.centered_player_nr = (network_playing ? local_player->index_nr : -1); + game.centered_player_nr_next = game.centered_player_nr; + game.set_centered_player = FALSE; + + if (network_playing && tape.recording) + { + /* store client dependent player focus when recording network games */ + tape.centered_player_nr_next = game.centered_player_nr_next; + tape.set_centered_player = TRUE; + } + if (tape.playing) { /* when playing a tape, eliminate all players who do not participate */ @@ -3975,10 +4011,12 @@ void InitGame() { struct PlayerInfo *player = &stored_player[i]; - printf("- player %d: present == %d, connected == %d, active == %d", + printf("- player %d: present == %d, connected == %d [%d/%d], active == %d", i + 1, player->present, player->connected, + player->connected_locally, + player->connected_network, player->active); if (local_player == player) @@ -4183,11 +4221,6 @@ void InitGame() OpenDoor(DOOR_OPEN_ALL); - PlaySound(SND_GAME_STARTING); - - if (setup.sound_music) - PlayLevelMusic(); - KeyboardAutoRepeatOffUnlessAutoplay(); #if DEBUG_INIT_PLAYER @@ -4199,10 +4232,12 @@ void InitGame() { struct PlayerInfo *player = &stored_player[i]; - printf("- player %d: present == %d, connected == %d, active == %d", + printf("- player %d: present == %d, connected == %d [%d/%d], active == %d", i + 1, player->present, player->connected, + player->connected_locally, + player->connected_network, player->active); if (local_player == player) @@ -4227,11 +4262,20 @@ void InitGame() } game.restart_level = FALSE; + game.restart_game_message = NULL; if (level.game_engine_type == GAME_ENGINE_TYPE_MM) InitGameActions_MM(); SaveEngineSnapshotToListInitial(); + + if (!game.restart_level) + { + PlaySound(SND_GAME_STARTING); + + if (setup.sound_music) + PlayLevelMusic(); + } } void UpdateEngineValues(int actual_scroll_x, int actual_scroll_y, @@ -4692,14 +4736,16 @@ void GameEnd() local_player->LevelSolved_GameEnd = TRUE; - if (!global.use_envelope_request) - CloseDoor(DOOR_CLOSE_1); - if (local_player->LevelSolved_SaveTape) { - SaveTapeChecked(tape.level_nr); /* ask to save tape */ + /* make sure that request dialog to save tape does not open door again */ + if (!global.use_envelope_request) + CloseDoor(DOOR_CLOSE_1); + + SaveTapeChecked_LevelSolved(tape.level_nr); /* ask to save tape */ } + /* if no tape is to be saved, close both doors simultaneously */ CloseDoor(DOOR_CLOSE_ALL); if (level_editor_test_game) @@ -14956,6 +15002,22 @@ void RequestQuitGame(boolean ask_if_really_quit) "Do you really want to quit the game?"); } +void RequestRestartGame(char *message) +{ + game.restart_game_message = NULL; + + if (Request(message, REQ_ASK | REQ_STAY_CLOSED)) + { + StartGameActions(options.network, setup.autorecord, level.random_seed); + } + else + { + SetGameStatus(GAME_MODE_MAIN); + + DrawMainMenu(); + } +} + /* ------------------------------------------------------------------------- */ /* random generator functions */ @@ -15266,7 +15328,7 @@ void LoadEngineSnapshotValues() LoadEngineSnapshotValues_EM(); if (level.game_engine_type == GAME_ENGINE_TYPE_SP) LoadEngineSnapshotValues_SP(); - if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + if (level.game_engine_type == GAME_ENGINE_TYPE_MM) LoadEngineSnapshotValues_MM(); } @@ -15408,7 +15470,8 @@ void CreateGameButtons() for (i = 0; i < NUM_GAME_BUTTONS; i++) { - struct GraphicInfo *gfx = &graphic_info[gamebutton_info[i].graphic]; + int graphic = gamebutton_info[i].graphic; + struct GraphicInfo *gfx = &graphic_info[graphic]; struct XY *pos = gamebutton_info[i].pos; struct GadgetInfo *gi; int button_type; @@ -15462,6 +15525,7 @@ void CreateGameButtons() } gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_IMAGE_ID, graphic, GDI_INFO_TEXT, gamebutton_info[i].infotext, GDI_X, base_x + GDI_ACTIVE_POS(pos->x), GDI_Y, base_y + GDI_ACTIVE_POS(pos->y),