From f2658eb8713a94143026aa30dcc1305652b925a8 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:14:54 -0500 Subject: [PATCH] Enumerate the map tiles in row order --- src/keybind.cpp | 4 ++-- src/lighting.cpp | 4 ++-- src/map.cpp | 6 ++---- src/qtscript.cpp | 4 ++-- src/visibility.cpp | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/keybind.cpp b/src/keybind.cpp index afc4e6a29b3..83352333ba5 100644 --- a/src/keybind.cpp +++ b/src/keybind.cpp @@ -305,9 +305,9 @@ void kf_HalveHeights() { MAPTILE *psTile; - for (int i = 0; i < mapWidth; ++i) + for (int j = 0; j < mapHeight; ++j) { - for (int j = 0; j < mapHeight; ++j) + for (int i = 0; i < mapWidth; ++i) { psTile = mapTile(i, j); psTile->height /= 2; diff --git a/src/lighting.cpp b/src/lighting.cpp index d9cede1a9c1..e93631aa24b 100644 --- a/src/lighting.cpp +++ b/src/lighting.cpp @@ -89,9 +89,9 @@ void initLighting(UDWORD x1, UDWORD y1, UDWORD x2, UDWORD y2) return; } - for (unsigned i = x1; i < x2; i++) + for (unsigned j = y1; j < y2; j++) { - for (unsigned j = y1; j < y2; j++) + for (unsigned i = x1; i < x2; i++) { MAPTILE *psTile = mapTile(i, j); diff --git a/src/map.cpp b/src/map.cpp index f573ea3ba93..55e6c729393 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -708,11 +708,9 @@ static bool hasDecals(int i, int j) // Sets the ground type to be a decal or not static bool mapSetGroundTypes() { - int i, j; - - for (i = 0; i < mapWidth; i++) + for (int j = 0; j < mapHeight; j++) { - for (j = 0; j < mapHeight; j++) + for (int i = 0; i < mapWidth; i++) { MAPTILE *psTile = mapTile(i, j); diff --git a/src/qtscript.cpp b/src/qtscript.cpp index a8a6c31e2b0..01022825891 100644 --- a/src/qtscript.cpp +++ b/src/qtscript.cpp @@ -1760,9 +1760,9 @@ std::vector scripting_engine::debug_GetLabelInfo() void clearMarks() { - for (int x = 0; x < mapWidth; x++) // clear old marks + for (int y = 0; y < mapHeight; y++) { - for (int y = 0; y < mapHeight; y++) + for (int x = 0; x < mapWidth; x++) // clear old marks { MAPTILE *psTile = mapTile(x, y); psTile->tileInfoBits &= ~BITS_MARKED; diff --git a/src/visibility.cpp b/src/visibility.cpp index 0ab0dbe0a07..f5439ce7489 100644 --- a/src/visibility.cpp +++ b/src/visibility.cpp @@ -462,9 +462,9 @@ void revealAll(UBYTE player) } //reveal all tiles - for (i = 0; i < mapWidth; i++) + for (j = 0; j < mapHeight; j++) { - for (j = 0; j < mapHeight; j++) + for (i = 0; i < mapWidth; i++) { psTile = mapTile(i, j); psTile->tileExploredBits |= alliancebits[player];