Skip to content

Commit

Permalink
Make four render variables const
Browse files Browse the repository at this point in the history
These variables were only set in InitRenderParams and
computed from constants, so the results were also constant.
  • Loading branch information
momoko-h committed Oct 19, 2023
1 parent a1fb0d8 commit 6748af1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
6 changes: 1 addition & 5 deletions src/game/TileEngine/Radar_Screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ static void AdjustWorldCenterFromRadarCoords(INT16 sRadarX, INT16 sRadarY)

INT16 sScreenX, sScreenY;
INT16 sTempX_W, sTempY_W;
INT16 sNewCenterWorldX, sNewCenterWorldY;
INT16 sNumXSteps, sNumYSteps;

// Use radar scale values to get screen values, then convert ot map values, rounding to nearest middle tile
Expand Down Expand Up @@ -346,10 +345,7 @@ static void AdjustWorldCenterFromRadarCoords(INT16 sRadarX, INT16 sRadarY)
FromScreenToCellCoordinates( sScreenX, sScreenY, &sTempX_W, &sTempY_W );

// Adjust these to world center
sNewCenterWorldX = (INT16)(gCenterWorldX + sTempX_W);
sNewCenterWorldY = (INT16)(gCenterWorldY + sTempY_W);

SetRenderCenter( sNewCenterWorldX, sNewCenterWorldY );
SetRenderCenter( gCenterWorldX + sTempX_W, gCenterWorldY + sTempY_W);
}


Expand Down
9 changes: 0 additions & 9 deletions src/game/TileEngine/RenderWorld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,10 @@ BOOLEAN gfIgnoreScrollDueToCenterAdjust = FALSE;
//

// GLOBAL SCROLLING PARAMS
INT16 gCenterWorldX;
INT16 gCenterWorldY;
INT16 gsLeftX; // Left edge of the current map in screen coordinates.
INT16 gsTopY; // Top edge of the current map in screen coordinates.
INT16 gsRightX; // Right edge of the current map in screen coordinates.
INT16 gsBottomY; // Bottom edge of the current map in screen coordinates.
INT16 gsCX; // Center of the map in screen coordinates (seems to be always 0).
INT16 gsCY; // Center of the map in screen coordinates (seems to be always 1625).
double gdScaleX;
double gdScaleY;

Expand Down Expand Up @@ -2252,17 +2248,12 @@ void InitRenderParams(UINT8 ubRestrictionID)
default: abort(); // HACK000E
}

gCenterWorldX = CELL_X_SIZE * WORLD_ROWS / 2;
gCenterWorldY = CELL_X_SIZE * WORLD_COLS / 2;

// Convert Bounding box into screen coords
FromCellToScreenCoordinates(gTopLeftWorldLimitX, gTopLeftWorldLimitY, &gsLeftX, &gsTopY);
FromCellToScreenCoordinates(gBottomRightWorldLimitX, gBottomRightWorldLimitY, &gsRightX, &gsBottomY);
FromCellToScreenCoordinates(gCenterWorldX, gCenterWorldY, &gsCX, &gsCY);

// Adjust for interface height tabbing!
gsTopY += ROOF_LEVEL_HEIGHT;
gsCY += ROOF_LEVEL_HEIGHT / 2;

SLOGD("World Screen Width {} Height {}", gsRightX - gsLeftX, gsBottomY - gsTopY);

Expand Down
8 changes: 4 additions & 4 deletions src/game/TileEngine/RenderWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ extern INT16 gsBottomRightWorldY;


// GLOBAL COORDINATES
extern INT16 gCenterWorldX;
extern INT16 gCenterWorldY;
constexpr INT16 gCenterWorldX = 800; // (was a variable in vanilla, always computed to 800).
constexpr INT16 gCenterWorldY = 800; // (was a variable in vanilla, always computed to 800).
extern INT16 gsLeftX;
extern INT16 gsTopY;
extern INT16 gsRightX;
extern INT16 gsBottomY;
extern INT16 gsCX;
extern INT16 gsCY;
constexpr INT16 gsCX = 0; // Center of the map in screen coordinates (was a variable in vanilla, always computed to 0).
constexpr INT16 gsCY = 1625; // Center of the map in screen coordinates (was a variable in vanilla, always computed to 1625).
extern double gdScaleX;
extern double gdScaleY;

Expand Down

0 comments on commit 6748af1

Please sign in to comment.