shithub: choc

Download patch

ref: 4788fd8387b4206df42a95c3c2f9b848bf4eac20
parent: edfbfe1d5da7ace84e102e3b68cddfb1a7b1d6c1
author: Simon Howard <fraggle@gmail.com>
date: Sat Mar 22 12:54:47 EDT 2014

heretic/hexen: Fix automap background scrolling.

There was a bug where it was possible to keep moving the background
when the boundaries of the map were reached. This is because the code
to move the background was done in calls to AM_Drawer(), which is
fundamentally a bad idea. Some old commented-out code shows that this
was previously done in AM_Drawer (same location that scrolls the map
itself), but it was moved. Move it back.

Thanks to Chris Fielder for the bug report; this fixes #321.

--- a/src/heretic/am_map.c
+++ b/src/heretic/am_map.c
@@ -309,18 +309,23 @@
         m_y = min_y - m_h / 2;
         m_paninc.y = 0;
     }
-/*
-  mapxstart += MTOF(m_paninc.x+FRACUNIT/2);
-  mapystart -= MTOF(m_paninc.y+FRACUNIT/2);
-  if(mapxstart >= finit_width)
-		mapxstart -= finit_width;
-  if(mapxstart < 0)
-		mapxstart += finit_width;
-  if(mapystart >= finit_height)
-		mapystart -= finit_height;
-  if(mapystart < 0)
-		mapystart += finit_height;
-*/
+
+    // The following code was commented out in the released Heretic source,
+    // but I believe we need to do this here to stop the background moving
+    // when we reach the map boundaries. (In the released source it's done
+    // in AM_clearFB).
+    mapxstart += MTOF(m_paninc.x+FRACUNIT/2);
+    mapystart -= MTOF(m_paninc.y+FRACUNIT/2);
+    if(mapxstart >= finit_width)
+        mapxstart -= finit_width;
+    if(mapxstart < 0)
+        mapxstart += finit_width;
+    if(mapystart >= finit_height)
+        mapystart -= finit_height;
+    if(mapystart < 0)
+        mapystart += finit_height;
+    // - end of code that was commented-out
+
     m_x2 = m_x + m_w;
     m_y2 = m_y + m_h;
 }
@@ -783,8 +788,13 @@
     }
     else
     {
+        // The released Heretic source does this here, but this causes a bug
+        // where the map background keeps moving when we reach the map
+        // boundaries. This is instead done in AM_changeWindowLoc.
+        /*
         mapxstart += (MTOF(m_paninc.x) >> 1);
         mapystart -= (MTOF(m_paninc.y) >> 1);
+
         if (mapxstart >= finit_width)
             mapxstart -= finit_width;
         if (mapxstart < 0)
@@ -793,6 +803,7 @@
             mapystart -= finit_height;
         if (mapystart < 0)
             mapystart += finit_height;
+        */
     }
 
     //blit the automap background to the screen.
--- a/src/hexen/am_map.c
+++ b/src/hexen/am_map.c
@@ -255,18 +255,23 @@
         m_y = min_y - m_h / 2;
         m_paninc.y = 0;
     }
-/*
-  mapxstart += MTOF(m_paninc.x+FRACUNIT/2);
-  mapystart -= MTOF(m_paninc.y+FRACUNIT/2);
-  if(mapxstart >= finit_width)
-		mapxstart -= finit_width;
-  if(mapxstart < 0)
-		mapxstart += finit_width;
-  if(mapystart >= finit_height)
-		mapystart -= finit_height;
-  if(mapystart < 0)
-		mapystart += finit_height;
-*/
+
+    // The following code was commented out in the released Hexen source,
+    // but I believe we need to do this here to stop the background moving
+    // when we reach the map boundaries. (In the released source it's done
+    // in AM_clearFB).
+    mapxstart += MTOF(m_paninc.x+FRACUNIT/2);
+    mapystart -= MTOF(m_paninc.y+FRACUNIT/2);
+    if(mapxstart >= finit_width)
+        mapxstart -= finit_width;
+    if(mapxstart < 0)
+        mapxstart += finit_width;
+    if(mapystart >= finit_height)
+        mapystart -= finit_height;
+    if(mapystart < 0)
+        mapystart += finit_height;
+    // - end of code that was commented-out
+
     m_x2 = m_x + m_w;
     m_y2 = m_y + m_h;
 }
@@ -682,6 +687,10 @@
     }
     else
     {
+        // The released Hexen source does this here, but this causes a bug
+        // where the map background keeps moving when we reach the map
+        // boundaries. This is instead done in AM_changeWindowLoc.
+        /*
         mapxstart += (MTOF(m_paninc.x) >> 1);
         mapystart -= (MTOF(m_paninc.y) >> 1);
         if (mapxstart >= finit_width)
@@ -692,6 +701,7 @@
             mapystart -= finit_height;
         if (mapystart < 0)
             mapystart += finit_height;
+        */
     }
 
     //blit the automap background to the screen.