From 5131f9e651b6221589252400ac8036fe4abb1d0b Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 18 Mar 2006 16:07:22 +0100 Subject: [PATCH] rnd-20060318-1-src * fixed bug in multi-player movement with focus on both players --- ChangeLog | 3 +++ src/conftime.h | 2 +- src/game_em/graphics.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/game_em/synchro_1.c | 2 ++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 817ca24a..8c7cf639 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2006-03-18 + * fixed bug in multi-player movement with focus on both players + 2006-03-14 * added player focus switching to level tape recording and re-playing diff --git a/src/conftime.h b/src/conftime.h index 46e25f2b..ec52e6ca 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-03-14 01:37]" +#define COMPILE_DATE_STRING "[2006-03-18 15:44]" diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 3b18584c..fbddeb2b 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -578,6 +578,34 @@ void DrawRelocatePlayer(struct PlayerInfo *player, boolean quick_relocation) } #endif +static int getMaxCenterDistancePlayerNr(int center_x, int center_y) +{ + int max_dx = 0, max_dy = 0; + int player_nr = game_em.last_moving_player; + int i; + + for (i = 0; i < MAX_PLAYERS; i++) + { + if (ply[i].alive) + { + int sx = PLAYER_SCREEN_X(i); + int sy = PLAYER_SCREEN_Y(i); + + if (game_em.last_player_direction[i] != MV_NONE && + (ABS(sx - center_x) > max_dx || + ABS(sy - center_y) > max_dy)) + { + max_dx = MAX(max_dx, ABS(sx - center_x)); + max_dy = MAX(max_dy, ABS(sy - center_y)); + + player_nr = i; + } + } + } + + return player_nr; +} + static void setMinimalPlayerBoundaries(int *sx1, int *sy1, int *sx2, int *sy2) { boolean num_checked_players = 0; @@ -662,6 +690,11 @@ void RedrawPlayfield_EM(boolean force_redraw) #if 0 boolean game.set_centered_player = getSetCenteredPlayer_EM(); int game.centered_player_nr_next = getCenteredPlayerNr_EM(); +#endif +#if 1 + int player_nr = getMaxCenterDistancePlayerNr(screen_x, screen_y); +#else + int player_nr = game_em.last_moving_player; #endif int offset = (setup.scroll_delay ? 3 : 0) * TILEX; int offset_x = offset; @@ -720,8 +753,13 @@ void RedrawPlayfield_EM(boolean force_redraw) } else { +#if 1 + sx = PLAYER_SCREEN_X(player_nr); + sy = PLAYER_SCREEN_Y(player_nr); +#else sx = PLAYER_SCREEN_X(game_em.last_moving_player); sy = PLAYER_SCREEN_Y(game_em.last_moving_player); +#endif } } else @@ -918,7 +956,9 @@ void RedrawPlayfield_EM(boolean force_redraw) else { /* prevent scrolling against the players move direction */ +#if 0 int player_nr = game_em.last_moving_player; +#endif int player_move_dir = game_em.last_player_direction[player_nr]; int dx = SIGN(screen_x - screen_x_old); int dy = SIGN(screen_y - screen_y_old); diff --git a/src/game_em/synchro_1.c b/src/game_em/synchro_1.c index c6f00674..48bccb9b 100644 --- a/src/game_em/synchro_1.c +++ b/src/game_em/synchro_1.c @@ -452,6 +452,8 @@ static void check_player(struct PLAYER *ply) int anim = 0; int dx = 0, dy = 0; + game_em.last_player_direction[ply->num] = MV_NONE; + #if 0 printf("::: up == %d, down == %d, left == %d, right == %d, fire == %d [spin == %d, stick == %d]\n", ply->joy_n, ply->joy_s, ply->joy_w, ply->joy_e, ply->joy_fire, -- 2.34.1