fixed bug with even sized playfield screen and levels without border element
[rocksndiamonds.git] / src / tools.c
index 2505f402bc83c843e2b265c2ea5eaeb35064db04..c2b1ec15c80b9e31719171cb40b7d587f4f33478 100644 (file)
@@ -217,9 +217,10 @@ static int getFieldbufferOffsetX_RND(void)
 
   if (EVEN(SCR_FIELDX))
   {
+    int sbx_right = SBX_Right + (BorderElement != EL_EMPTY ? 1 : 0);
     int ffx = (scroll_x - SBX_Left)  * TILEX_VAR + dx_var;
 
-    if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR)
+    if (ffx < sbx_right * TILEX_VAR + TILEX_VAR / 2)
       fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR;
     else
       fx += (dx_var > 0 ? TILEX_VAR : 0);
@@ -249,9 +250,10 @@ static int getFieldbufferOffsetY_RND(void)
 
   if (EVEN(SCR_FIELDY))
   {
+    int sby_lower = SBY_Lower + (BorderElement != EL_EMPTY ? 1 : 0);
     int ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var;
 
-    if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR)
+    if (ffy < sby_lower * TILEY_VAR + TILEY_VAR / 2)
       fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR;
     else
       fy += (dy_var > 0 ? TILEY_VAR : 0);
@@ -3523,6 +3525,10 @@ void DrawPreviewPlayers(void)
   if (game_status != GAME_MODE_MAIN)
     return;
 
+  // do not draw preview players if level preview redefined, but players aren't
+  if (preview.redefined && !menu.main.preview_players.redefined)
+    return;
+
   boolean player_found[MAX_PLAYERS];
   int num_players = 0;
   int i, x, y;
@@ -3628,6 +3634,10 @@ static void DrawNetworkPlayersExt(boolean force)
   if (!network.connected && !force)
     return;
 
+  // do not draw network players if level preview redefined, but players aren't
+  if (preview.redefined && !menu.main.network_players.redefined)
+    return;
+
   int num_players = 0;
   int i;