Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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 Cyp authored
Showing with 9 additions and 24 deletions.
  1. +1 −1  src/display3d.cpp
  2. +1 −1  src/display3d.h
  3. +7 −22 src/radar.cpp
View
2  src/display3d.cpp
@@ -203,7 +203,7 @@ static Vector3f alteredPoints[iV_IMD_MAX_POINTS];
/** Number of tiles visible
* \todo This should become dynamic! (A function of resolution, angle and zoom maybe.)
*/
-Vector2i visibleTiles(VISIBLE_XTILES, VISIBLE_YTILES);
+const Vector2i visibleTiles(VISIBLE_XTILES, VISIBLE_YTILES);
/// The tile we use for drawing the bottom of a body of water
static unsigned int underwaterTile = WATER_TILE;
View
2  src/display3d.h
@@ -122,7 +122,7 @@ extern Vector2i mousePos;
extern bool bRender3DOnly;
extern bool showGateways;
extern bool showPath;
-extern Vector2i visibleTiles;
+extern const Vector2i visibleTiles;
/*returns the graphic ID for a droid rank*/
extern UDWORD getDroidRankGraphic(DROID *psDroid);
View
29 src/radar.cpp
@@ -253,22 +253,8 @@ void CalcRadarPosition(int mX, int mY, int *PosX, int *PosY)
#endif
// old safety code -- still necessary?
- if (sPosX < scrollMinX)
- {
- sPosX = scrollMinX;
- }
- else if (sPosX > scrollMaxX)
- {
- sPosX = scrollMaxX;
- }
- if (sPosY < scrollMinY)
- {
- sPosY = scrollMinY;
- }
- else if (sPosY > scrollMaxY)
- {
- sPosY = scrollMaxY;
- }
+ sPosX = clip(sPosX, scrollMinX, scrollMaxX);
+ sPosY = clip(sPosY, scrollMinY, scrollMaxY);
*PosX = sPosX;
*PosY = sPosY;
@@ -582,8 +568,7 @@ static void RotateVector2D(Vector3i *Vector, Vector3i *TVector, Vector3i *Pos, i
static SDWORD getDistanceAdjust( void )
{
- UDWORD origDistance = MAXDISTANCE;
- SDWORD dif = MAX(origDistance - getViewDistance(), 0);
+ int dif = std::max<int>(MAXDISTANCE - getViewDistance(), 0);
return dif / 100;
}
@@ -631,8 +616,8 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
v[3].x = -shortX;
v[3].y = yDrop;
- centre.x = radarX + x - scrollMinX*pixSizeH/2;
- centre.y = radarY + y - scrollMinY*pixSizeV/2;
+ centre.x = radarX + x - scrollMinX*pixSizeH;
+ centre.y = radarY + y - scrollMinY*pixSizeV;
RotateVector2D(v,tv,&centre,player.r.y,4);
@@ -666,8 +651,8 @@ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pi
static void DrawRadarExtras(float radarX, float radarY, float pixSizeH, float pixSizeV)
{
- int viewX = (player.p.x / TILE_UNITS) * pixSizeH;
- int viewY = (player.p.z / TILE_UNITS) * pixSizeV;
+ int viewX = player.p.x*pixSizeH / TILE_UNITS;
+ int viewY = player.p.z*pixSizeV / TILE_UNITS;
drawViewingWindow(radarX, radarY, viewX, viewY, pixSizeH, pixSizeV);
RenderWindowFrame(FRAME_RADAR, radarX - 1, radarY - 1, radarWidth + 2, radarHeight + 2);
Please sign in to comment.
Something went wrong with that request. Please try again.