Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix location of centre of viewport rendered on radar window.

This was wrong in CAM_2A, where scrollMinX and scrollMinY are non-zero.

Fixes ticket:3619.
  • Loading branch information...
commit 0dde269379507a897ef2945ca76f840a8994f04a 1 parent 667b54b
Cyp authored September 16, 2012
2  src/display3d.cpp
@@ -203,7 +203,7 @@ static Vector3f alteredPoints[iV_IMD_MAX_POINTS];
203 203
 /** Number of tiles visible
204 204
  * \todo This should become dynamic! (A function of resolution, angle and zoom maybe.)
205 205
  */
206  
-Vector2i visibleTiles(VISIBLE_XTILES, VISIBLE_YTILES);
  206
+const Vector2i visibleTiles(VISIBLE_XTILES, VISIBLE_YTILES);
207 207
 
208 208
 /// The tile we use for drawing the bottom of a body of water
209 209
 static unsigned int underwaterTile = WATER_TILE;
2  src/display3d.h
@@ -122,7 +122,7 @@ extern Vector2i mousePos;
122 122
 extern bool bRender3DOnly;
123 123
 extern bool showGateways;
124 124
 extern bool showPath;
125  
-extern Vector2i visibleTiles;
  125
+extern const Vector2i visibleTiles;
126 126
 
127 127
 /*returns the graphic ID for a droid rank*/
128 128
 extern UDWORD  getDroidRankGraphic(DROID *psDroid);
29  src/radar.cpp
@@ -253,22 +253,8 @@ void CalcRadarPosition(int mX, int mY, int *PosX, int *PosY)
253 253
 #endif
254 254
 
255 255
 	// old safety code -- still necessary?
256  
-	if (sPosX < scrollMinX)
257  
-	{
258  
-		sPosX = scrollMinX;
259  
-	}
260  
-	else if (sPosX > scrollMaxX)
261  
-	{
262  
-		sPosX = scrollMaxX;
263  
-	}
264  
-	if (sPosY < scrollMinY)
265  
-	{
266  
-		sPosY = scrollMinY;
267  
-	}
268  
-	else if (sPosY > scrollMaxY)
269  
-	{
270  
-		sPosY = scrollMaxY;
271  
-	}
  256
+	sPosX = clip(sPosX, scrollMinX, scrollMaxX);
  257
+	sPosY = clip(sPosY, scrollMinY, scrollMaxY);
272 258
 
273 259
 	*PosX = sPosX;
274 260
 	*PosY = sPosY;
@@ -582,8 +568,7 @@ static void RotateVector2D(Vector3i *Vector, Vector3i *TVector, Vector3i *Pos, i
582 568
 
583 569
 static SDWORD getDistanceAdjust( void )
584 570
 {
585  
-	UDWORD	origDistance = MAXDISTANCE;
586  
-	SDWORD	dif = MAX(origDistance - getViewDistance(), 0);
  571
+	int dif = std::max<int>(MAXDISTANCE - getViewDistance(), 0);
587 572
 
588 573
 	return dif / 100;
589 574
 }
@@ -631,8 +616,8 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
631 616
 	v[3].x = -shortX;
632 617
 	v[3].y = yDrop;
633 618
 
634  
-	centre.x = radarX + x - scrollMinX*pixSizeH/2;
635  
-	centre.y = radarY + y - scrollMinY*pixSizeV/2;
  619
+	centre.x = radarX + x - scrollMinX*pixSizeH;
  620
+	centre.y = radarY + y - scrollMinY*pixSizeV;
636 621
 
637 622
 	RotateVector2D(v,tv,&centre,player.r.y,4);
638 623
 
@@ -666,8 +651,8 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
666 651
 
667 652
 static void DrawRadarExtras(float radarX, float radarY, float pixSizeH, float pixSizeV)
668 653
 {
669  
-	int	viewX = (player.p.x / TILE_UNITS) * pixSizeH;
670  
-	int	viewY = (player.p.z / TILE_UNITS) * pixSizeV;
  654
+	int viewX = player.p.x*pixSizeH / TILE_UNITS;
  655
+	int viewY = player.p.z*pixSizeV / TILE_UNITS;
671 656
 
672 657
 	drawViewingWindow(radarX, radarY, viewX, viewY, pixSizeH, pixSizeV);
673 658
 	RenderWindowFrame(FRAME_RADAR, radarX - 1, radarY - 1, radarWidth + 2, radarHeight + 2);

0 notes on commit 0dde269

Please sign in to comment.
Something went wrong with that request. Please try again.