From: Holger Schemel Date: Sun, 3 Dec 2006 12:10:04 +0000 (+0100) Subject: rnd-20061203-1-src X-Git-Tag: 3.2.3^2~6 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=0c64a3cf001f3ef5ecdb80462ae1891d582379ee;p=rocksndiamonds.git rnd-20061203-1-src * improved "no scrolling when relocating" to also consider scroll delay (meaning that the player is not automatically centered in this case; this makes it possible to "invisibly" relocate the player to a region of the level playfield which looks the same as the old level region) --- diff --git a/ChangeLog b/ChangeLog index bf2df826..6d84463c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-12-03 + * improved "no scrolling when relocating" to also consider scroll delay + (meaning that the player is not automatically centered in this case; + this makes it possible to "invisibly" relocate the player to a region + of the level playfield which looks the same as the old level region) + 2006-12-02 * fixed bug with displaying masked borders over title screens when screen fading is disabled diff --git a/src/conftime.h b/src/conftime.h index c2aafc00..0a5d014f 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-12-02 16:27]" +#define COMPILE_DATE_STRING "[2006-12-03 12:49]" diff --git a/src/game.c b/src/game.c index a41363d1..3f3e6317 100644 --- a/src/game.c +++ b/src/game.c @@ -3328,8 +3328,8 @@ static void setScreenCenteredToAllPlayers(int *sx, int *sy) *sy = (sy1 + sy2) / 2; } -void DrawRelocateScreen(int x, int y, int move_dir, boolean center_screen, - boolean quick_relocation) +void DrawRelocateScreen(int old_x, int old_y, int x, int y, int move_dir, + boolean center_screen, boolean quick_relocation) { boolean ffwd_delay = (tape.playing && tape.fast_forward); boolean no_delay = (tape.warp_forward); @@ -3342,13 +3342,39 @@ void DrawRelocateScreen(int x, int y, int move_dir, boolean center_screen, if (!IN_VIS_FIELD(SCREENX(x), SCREENY(y)) || center_screen) { - scroll_x = (x < SBX_Left + MIDPOSX ? SBX_Left : - x > SBX_Right + MIDPOSX ? SBX_Right : - x - MIDPOSX); + if (center_screen) + { + scroll_x = (x < SBX_Left + MIDPOSX ? SBX_Left : + x > SBX_Right + MIDPOSX ? SBX_Right : + x - MIDPOSX); + + scroll_y = (y < SBY_Upper + MIDPOSY ? SBY_Upper : + y > SBY_Lower + MIDPOSY ? SBY_Lower : + y - MIDPOSY); + } + else + { + /* quick relocation (without scrolling), but do not center screen */ - scroll_y = (y < SBY_Upper + MIDPOSY ? SBY_Upper : - y > SBY_Lower + MIDPOSY ? SBY_Lower : - y - MIDPOSY); + int center_scroll_x = (old_x < SBX_Left + MIDPOSX ? SBX_Left : + old_x > SBX_Right + MIDPOSX ? SBX_Right : + old_x - MIDPOSX); + + int center_scroll_y = (old_y < SBY_Upper + MIDPOSY ? SBY_Upper : + old_y > SBY_Lower + MIDPOSY ? SBY_Lower : + old_y - MIDPOSY); + + int offset_x = x + (scroll_x - center_scroll_x); + int offset_y = y + (scroll_y - center_scroll_y); + + scroll_x = (offset_x < SBX_Left + MIDPOSX ? SBX_Left : + offset_x > SBX_Right + MIDPOSX ? SBX_Right : + offset_x - MIDPOSX); + + scroll_y = (offset_y < SBY_Upper + MIDPOSY ? SBY_Upper : + offset_y > SBY_Lower + MIDPOSY ? SBY_Lower : + offset_y - MIDPOSY); + } } else { @@ -3495,8 +3521,8 @@ void RelocatePlayer(int jx, int jy, int el_player_raw) } /* only visually relocate centered player */ - DrawRelocateScreen(player->jx, player->jy, player->MovDir, FALSE, - level.instant_relocation); + DrawRelocateScreen(old_jx, old_jy, player->jx, player->jy, player->MovDir, + FALSE, level.instant_relocation); TestIfPlayerTouchesBadThing(jx, jy); TestIfPlayerTouchesCustomElement(jx, jy); @@ -9341,7 +9367,7 @@ void GameActions_RND() game.centered_player_nr = game.centered_player_nr_next; game.set_centered_player = FALSE; - DrawRelocateScreen(sx, sy, MV_NONE, TRUE, setup.quick_switch); + DrawRelocateScreen(0, 0, sx, sy, MV_NONE, TRUE, setup.quick_switch); DrawGameDoorValues(); }