From: Holger Schemel Date: Sun, 15 Oct 2023 00:10:30 +0000 (+0200) Subject: fixed half-tile shifting when teleporting between playfield borders X-Git-Tag: 4.3.7.0~2 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d811a094287f78f4cf22aa53c76ed228f81322a7;p=rocksndiamonds.git fixed half-tile shifting when teleporting between playfield borders When relocating the player without centering the screen and without scrolling ("teleporting" to a different playfield area, but keeping the screen position), shifting the visible part of the playfield by half a tile may happen if the screen width or height is even. This is especially true when teleporting from and to an area that is directly aligned with the border of the playfield (regardless of the tiles at the playfield border being only half or fully visible, which only happens with even sized screen width or height, depending on the current player scroll position). This change makes sure that both the source and destination area of the playfield are displayed either aligned by half a tile or a full tile when doing a "teleporting" player relocation in such a case. --- diff --git a/src/game.c b/src/game.c index 88fa0a6e..94b74f78 100644 --- a/src/game.c +++ b/src/game.c @@ -5687,6 +5687,40 @@ static void DrawRelocateScreen(int old_x, int old_y, int x, int y, // make sure that shifted scroll position does not scroll beyond screen new_scroll_x = SCROLL_POSITION_X(shifted_scroll_x + MIDPOSX); new_scroll_y = SCROLL_POSITION_Y(shifted_scroll_y + MIDPOSY); + + // special case for teleporting from one end of the playfield to the other + // (this kludge prevents the destination area to be shifted by half a tile + // against the source destination for even screen width or screen height; + // probably most useful when used with high "game.forced_scroll_delay_value" + // in combination with "game.forced_scroll_x" and "game.forced_scroll_y") + if (quick_relocation) + { + if (EVEN(SCR_FIELDX)) + { + // relocate (teleport) between left and right border (half or full) + if (scroll_x == SBX_Left && new_scroll_x == SBX_Right - 1) + new_scroll_x = SBX_Right; + else if (scroll_x == SBX_Left + 1 && new_scroll_x == SBX_Right) + new_scroll_x = SBX_Right - 1; + else if (scroll_x == SBX_Right && new_scroll_x == SBX_Left + 1) + new_scroll_x = SBX_Left; + else if (scroll_x == SBX_Right - 1 && new_scroll_x == SBX_Left) + new_scroll_x = SBX_Left + 1; + } + + if (EVEN(SCR_FIELDY)) + { + // relocate (teleport) between top and bottom border (half or full) + if (scroll_y == SBY_Upper && new_scroll_y == SBY_Lower - 1) + new_scroll_y = SBY_Lower; + else if (scroll_y == SBY_Upper + 1 && new_scroll_y == SBY_Lower) + new_scroll_y = SBY_Lower - 1; + else if (scroll_y == SBY_Lower && new_scroll_y == SBY_Upper + 1) + new_scroll_y = SBY_Upper; + else if (scroll_y == SBY_Lower - 1 && new_scroll_y == SBY_Upper) + new_scroll_y = SBY_Upper + 1; + } + } } if (quick_relocation)