Browse Source

Optimize even/odd colculation

pull/872/head
Anders Jenbo 6 years ago
parent
commit
52f46027da
  1. 2
      Source/cursor.cpp
  2. 6
      Source/scrollrt.cpp

2
Source/cursor.cpp

@ -254,7 +254,7 @@ void CheckCursMove()
// Center player tile on screen
TilesInView(&columns, &rows);
ShiftGrid(&mx, &my, -columns / 2, -(rows - RowsCoveredByPanel()) / 4);
if ((columns % 2) != 0) {
if ((columns & 1) != 0) {
my++;
}

6
Source/scrollrt.cpp

@ -982,11 +982,11 @@ void TilesInView(int *rcolumns, int *rrows)
if (!zoomflag) {
// Half the number of tiles, rounded up
if (columns % 2) {
if (columns & 1) {
columns++;
}
columns /= 2;
if (rows % 2) {
if (rows & 1) {
rows++;
}
rows /= 2;
@ -1020,7 +1020,7 @@ static void DrawGame(int x, int y)
// Center player tile on screen
TilesInView(&columns, &rows);
ShiftGrid(&x, &y, -columns / 2, -(rows - RowsCoveredByPanel()) / 4);
if ((columns % 2) == 0) {
if ((columns & 1) == 0) {
y--;
}

Loading…
Cancel
Save