From 84ede906a0d6753380280daa4e0ecf615e108ac0 Mon Sep 17 00:00:00 2001 From: Juliano Leal Goncalves Date: Sun, 5 Sep 2021 17:19:40 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Replace=20usages=20of=20'S?= =?UTF-8?q?hiftGrid'=20against=20'Point'=20values=20with=20direct=20offset?= =?UTF-8?q?/direction-based=20increments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/scrollrt.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/scrollrt.cpp b/Source/scrollrt.cpp index 3ec6aac92..10f146d49 100644 --- a/Source/scrollrt.cpp +++ b/Source/scrollrt.cpp @@ -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; }