♻️ Replace usages of 'ShiftGrid' against 'Point' values with direct offset/direction-based increments
This commit is contained in:
parent
f5e88b0d9e
commit
84ede906a0
1 changed files with 15 additions and 14 deletions
|
|
@ -943,11 +943,11 @@ void DrawFloor(const Surface &out, Point tilePosition, Point targetBufferPositio
|
|||
} else {
|
||||
world_draw_black_tile(out, targetBufferPosition.x, targetBufferPosition.y);
|
||||
}
|
||||
ShiftGrid(&tilePosition.x, &tilePosition.y, 1, 0);
|
||||
tilePosition += DIR_E;
|
||||
targetBufferPosition.x += TILE_WIDTH;
|
||||
}
|
||||
// Return to start of row
|
||||
ShiftGrid(&tilePosition.x, &tilePosition.y, -columns, 0);
|
||||
tilePosition += Displacement::fromDirection(DIR_W) * columns;
|
||||
targetBufferPosition.x -= columns * TILE_WIDTH;
|
||||
|
||||
// Jump to next row
|
||||
|
|
@ -999,11 +999,11 @@ void DrawTileContent(const Surface &out, Point tilePosition, Point targetBufferP
|
|||
DrawDungeon(out, tilePosition, targetBufferPosition);
|
||||
}
|
||||
}
|
||||
ShiftGrid(&tilePosition.x, &tilePosition.y, 1, 0);
|
||||
tilePosition += DIR_E;
|
||||
targetBufferPosition.x += TILE_WIDTH;
|
||||
}
|
||||
// Return to start of row
|
||||
ShiftGrid(&tilePosition.x, &tilePosition.y, -columns, 0);
|
||||
tilePosition += Displacement::fromDirection(DIR_W) * columns;
|
||||
targetBufferPosition.x -= columns * TILE_WIDTH;
|
||||
|
||||
// Jump to next row
|
||||
|
|
@ -1109,23 +1109,23 @@ void DrawGame(const Surface &fullOut, Point position)
|
|||
if (CanPanelsCoverView()) {
|
||||
if (zoomflag) {
|
||||
if (chrflag || QuestLogIsOpen) {
|
||||
ShiftGrid(&position.x, &position.y, 2, 0);
|
||||
position += Displacement::fromDirection(DIR_E) * 2;
|
||||
columns -= 4;
|
||||
sx += SPANEL_WIDTH - TILE_WIDTH / 2;
|
||||
}
|
||||
if (invflag || sbookflag) {
|
||||
ShiftGrid(&position.x, &position.y, 2, 0);
|
||||
position += Displacement::fromDirection(DIR_E) * 2;
|
||||
columns -= 4;
|
||||
sx += -TILE_WIDTH / 2;
|
||||
}
|
||||
} else {
|
||||
if (chrflag || QuestLogIsOpen) {
|
||||
ShiftGrid(&position.x, &position.y, 1, 0);
|
||||
position += DIR_E;
|
||||
columns -= 2;
|
||||
sx += -TILE_WIDTH / 2 / 2; // SPANEL_WIDTH accounted for in Zoom()
|
||||
}
|
||||
if (invflag || sbookflag) {
|
||||
ShiftGrid(&position.x, &position.y, 1, 0);
|
||||
position += DIR_E;
|
||||
columns -= 2;
|
||||
sx += -TILE_WIDTH / 2 / 2;
|
||||
}
|
||||
|
|
@ -1138,12 +1138,12 @@ void DrawGame(const Surface &fullOut, Point position)
|
|||
switch (ScrollInfo._sdir) {
|
||||
case SDIR_N:
|
||||
sy -= TILE_HEIGHT;
|
||||
ShiftGrid(&position.x, &position.y, 0, -1);
|
||||
position += DIR_N;
|
||||
rows += 2;
|
||||
break;
|
||||
case SDIR_NE:
|
||||
sy -= TILE_HEIGHT;
|
||||
ShiftGrid(&position.x, &position.y, 0, -1);
|
||||
position += DIR_N;
|
||||
columns++;
|
||||
rows += 2;
|
||||
break;
|
||||
|
|
@ -1159,13 +1159,13 @@ void DrawGame(const Surface &fullOut, Point position)
|
|||
break;
|
||||
case SDIR_SW:
|
||||
sx -= TILE_WIDTH;
|
||||
ShiftGrid(&position.x, &position.y, -1, 0);
|
||||
position += DIR_W;
|
||||
columns++;
|
||||
rows++;
|
||||
break;
|
||||
case SDIR_W:
|
||||
sx -= TILE_WIDTH;
|
||||
ShiftGrid(&position.x, &position.y, -1, 0);
|
||||
position += DIR_W;
|
||||
columns++;
|
||||
break;
|
||||
case SDIR_NW:
|
||||
|
|
@ -1530,7 +1530,8 @@ void CalcViewportGeometry()
|
|||
int lrow = tileRows - RowsCoveredByPanel();
|
||||
|
||||
// Center player tile on screen
|
||||
ShiftGrid(&tileShift.deltaX, &tileShift.deltaY, -tileColums / 2, -lrow / 2);
|
||||
tileShift += Displacement::fromDirection(DIR_W) * (tileColums / 2);
|
||||
tileShift += Displacement::fromDirection(DIR_N) * (lrow / 2);
|
||||
|
||||
tileRows *= 2;
|
||||
|
||||
|
|
@ -1544,7 +1545,7 @@ void CalcViewportGeometry()
|
|||
}
|
||||
} else if ((tileColums & 1) != 0 && (lrow & 1) != 0) {
|
||||
// Offset tile to vertically align the player when both rows and colums are odd
|
||||
ShiftGrid(&tileShift.deltaX, &tileShift.deltaY, 0, -1);
|
||||
tileShift += Displacement::fromDirection(DIR_N);
|
||||
tileRows++;
|
||||
tileOffset.deltaY -= TILE_HEIGHT / 2;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue