X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Fsynchro_1.c;h=1fe8faf0a99382bd7180381da190f358ffe2025f;hb=28fe42eb060d7c9169a9b344678494e7d366a6b0;hp=058c79e3caedb4ebd3e7d40768d1bc0025300f9a;hpb=d14ff3d04c44d90b4dc151fd7774946e20da0152;p=rocksndiamonds.git diff --git a/src/game_em/synchro_1.c b/src/game_em/synchro_1.c index 058c79e3..1fe8faf0 100644 --- a/src/game_em/synchro_1.c +++ b/src/game_em/synchro_1.c @@ -11,6 +11,9 @@ #include "display.h" +extern int centered_player_nr; +extern boolean checkIfAllPlayersFitToScreen(); + static void check_player(struct PLAYER *); static void kill_player(struct PLAYER *); static boolean player_digfield(struct PLAYER *, int, int); @@ -23,6 +26,8 @@ void synchro_1(void) int start_check_nr; int i; + game_em.any_player_moving = FALSE; + /* must test for death and actually kill separately */ for (i = 0; i < MAX_PLAYERS; i++) @@ -535,6 +540,30 @@ static void check_player(struct PLAYER *ply) } #endif + if (dx || dy) + { + int oldx = ply->x; + int oldy = ply->y; + int x = oldx + dx; + int y = oldy + dy; + boolean can_move = TRUE; + + ply->x = x; + ply->y = y; + + can_move = (centered_player_nr != -1 || checkIfAllPlayersFitToScreen()); + + ply->x = oldx; + ply->y = oldy; + + if (!can_move) + { + ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0; + + return; + } + } + if (dx == 0 && dy == 0) { ply->joy_stick = 0; @@ -560,7 +589,7 @@ static void check_player(struct PLAYER *ply) ply->joy_stick = 1; ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0; - ply->dynamite_cnt = 0; /* reset dynamite timer if we move */ + ply->dynamite_cnt = 0; /* reset dynamite timer if we move */ ply->joy_spin = !ply->joy_spin; if (ply->joy_snap == 0) /* player wants to move */ @@ -584,6 +613,10 @@ static void check_player(struct PLAYER *ply) ply->last_move_dir = (dx < 0 ? MV_LEFT : MV_RIGHT); else if (oldy != ply->y) ply->last_move_dir = (dy < 0 ? MV_UP : MV_DOWN); + + game_em.any_player_moving = TRUE; + game_em.last_moving_player = ply->num; + game_em.last_player_direction[ply->num] = ply->last_move_dir; } } else /* player wants to snap */