X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=13634a2c76122ab7b2a37f0482a5c123b1ecb90a;hb=fdbb975aee39b32064a9fdc461467e733c7854c9;hp=a17dc326f05e0a3a97c9490cb0fd39024c0982bb;hpb=b8803f08af3cf07efed781124417be11c1a306ee;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index a17dc326..13634a2c 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_network) + if (!network.enabled || player->connected_network) { player->active = TRUE; @@ -3321,7 +3321,7 @@ void InitGame() InitGameControlValues(); /* don't play tapes over network */ - network_playing = (options.network && !tape.playing); + network_playing = (network.enabled && !tape.playing); for (i = 0; i < MAX_PLAYERS; i++) { @@ -3503,11 +3503,9 @@ void InitGame() network_player_action_received = FALSE; -#if defined(NETWORK_AVALIABLE) /* initial null action */ if (network_playing) SendToServer_MovePlayer(MV_NONE); -#endif ZX = ZY = -1; ExitX = ExitY = -1; @@ -3545,18 +3543,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; @@ -3570,6 +3556,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 @@ -3693,7 +3697,7 @@ void InitGame() local_player = &stored_player[i]; } - if (!options.network) + if (!network.enabled) local_player->connected = TRUE; if (tape.playing) @@ -3701,7 +3705,7 @@ void InitGame() for (i = 0; i < MAX_PLAYERS; i++) stored_player[i].connected = tape.player_participates[i]; } - else if (options.network) + else if (network.enabled) { /* add team mode players connected over the network (needed for correct assignment of player figures from level to locally playing players) */ @@ -3730,10 +3734,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) @@ -3836,10 +3842,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) @@ -3895,6 +3903,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 */ @@ -3940,7 +3960,7 @@ void InitGame() } #endif } - else if (!options.network && !game.team_mode) /* && !tape.playing */ + else if (!network.enabled && !game.team_mode) /* && !tape.playing */ { /* when in single player mode, eliminate all but the first active player */ @@ -3989,10 +4009,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) @@ -4208,10 +4230,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) @@ -11264,14 +11288,12 @@ void StartGameActions(boolean init_network_game, boolean record_tape, if (record_tape) TapeStartRecording(new_random_seed); -#if defined(NETWORK_AVALIABLE) if (init_network_game) { SendToServer_StartPlaying(); return; } -#endif InitGame(); } @@ -11307,7 +11329,7 @@ void GameActionsExt() } if (game.restart_level) - StartGameActions(options.network, setup.autorecord, level.random_seed); + StartGameActions(network.enabled, setup.autorecord, level.random_seed); /* !!! SAME CODE AS IN "CheckLevelTime()" -- FIX THIS !!! */ if (level.game_engine_type == GAME_ENGINE_TYPE_EM) @@ -11394,10 +11416,8 @@ void GameActionsExt() { /* try to get network player actions in time */ -#if defined(NETWORK_AVALIABLE) /* last chance to get network player actions without main loop delay */ HandleNetworking(); -#endif /* game was quit by network peer */ if (game_status != GAME_MODE_PLAYING) @@ -11443,14 +11463,12 @@ void GameActionsExt() stored_player[i].effective_action = stored_player[i].action; } -#if defined(NETWORK_AVALIABLE) if (network_playing) SendToServer_MovePlayer(summarized_player_action); -#endif // summarize all actions at local players mapped input device position // (this allows using different input devices in single player mode) - if (!options.network && !game.team_mode) + if (!network.enabled && !game.team_mode) stored_player[map_player_action[local_player->index_nr]].effective_action = summarized_player_action; @@ -12360,7 +12378,7 @@ boolean MovePlayerOneStep(struct PlayerInfo *player, } } - if (!options.network && game.centered_player_nr == -1 && + if (!network.enabled && game.centered_player_nr == -1 && !AllPlayersInSight(player, new_jx, new_jy)) return MP_NO_ACTION; @@ -12547,7 +12565,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) if (scroll_x != old_scroll_x || scroll_y != old_scroll_y) { - if (!options.network && game.centered_player_nr == -1 && + if (!network.enabled && game.centered_player_nr == -1 && !AllPlayersInVisibleScreen()) { scroll_x = old_scroll_x; @@ -14941,11 +14959,9 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message) if (!skip_request) CloseDoor(DOOR_CLOSE_1); -#if defined(NETWORK_AVALIABLE) - if (options.network) + if (network.enabled) SendToServer_StopPlaying(NETWORK_STOP_BY_PLAYER); else -#endif { if (quick_quit) FadeSkipNextFadeIn(); @@ -14982,7 +14998,7 @@ void RequestRestartGame(char *message) if (Request(message, REQ_ASK | REQ_STAY_CLOSED)) { - StartGameActions(options.network, setup.autorecord, level.random_seed); + StartGameActions(network.enabled, setup.autorecord, level.random_seed); } else { @@ -15444,7 +15460,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; @@ -15498,6 +15515,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), @@ -15749,14 +15767,12 @@ static void HandleGameButtonsExt(int id, int button) case GAME_CTRL_ID_PAUSE: case GAME_CTRL_ID_PAUSE2: case GAME_CTRL_ID_PANEL_PAUSE: - if (options.network && game_status == GAME_MODE_PLAYING) + if (network.enabled && game_status == GAME_MODE_PLAYING) { -#if defined(NETWORK_AVALIABLE) if (tape.pausing) SendToServer_ContinuePlaying(); else SendToServer_PausePlaying(); -#endif } else TapeTogglePause(TAPE_TOGGLE_MANUAL); @@ -15769,15 +15785,13 @@ static void HandleGameButtonsExt(int id, int button) case GAME_CTRL_ID_PANEL_PLAY: if (game_status == GAME_MODE_MAIN) { - StartGameActions(options.network, setup.autorecord, level.random_seed); + StartGameActions(network.enabled, setup.autorecord, level.random_seed); } else if (tape.pausing) { -#if defined(NETWORK_AVALIABLE) - if (options.network) + if (network.enabled) SendToServer_ContinuePlaying(); else -#endif TapeTogglePause(TAPE_TOGGLE_MANUAL | TAPE_TOGGLE_PLAY_PAUSE); } break;