diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 193398d350..57a82768d0 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -915,8 +915,8 @@ public: if (ridePage) { - for (int32_t i = 0; i < 7; i++) - pressed_widgets &= ~(1 << (WIDX_FILTER_RIDE_TAB_ALL + i)); + for (int32_t i = WIDX_FILTER_RIDE_TAB_ALL; i <= WIDX_FILTER_RIDE_TAB_STALL; i++) + pressed_widgets &= ~(1 << i); if ((_filter_flags & FILTER_RIDES) == FILTER_RIDES) pressed_widgets |= (1ULL << WIDX_FILTER_RIDE_TAB_ALL); diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index de5e18fb35..a4f1355dfe 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -218,8 +218,8 @@ rct_window* WindowEditorObjectiveOptionsOpen() static void WindowEditorObjectiveOptionsSetPressedTab(rct_window* w) { int32_t i; - for (i = 0; i < 2; i++) - w->pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); + for (i = WIDX_TAB_1; i <= WIDX_TAB_2; i++) + w->pressed_widgets &= ~(1 << i); w->pressed_widgets |= 1LL << (WIDX_TAB_1 + w->page); } diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 126abe5521..0530020732 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -904,7 +904,7 @@ public: rct_widget* dropdownWidget = &widgets[widgetIndex - 1]; - for (int32_t i = 0; i < 4; i++) + for (std::size_t i = 0; i < std::size(ResearchFundingLevelNames); i++) { gDropdownItems[i].Format = STR_DROPDOWN_MENU_LABEL; gDropdownItems[i].Args = ResearchFundingLevelNames[i]; diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 7830778331..2af5f4dfce 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -842,7 +842,8 @@ static void WindowLoadsavePopulateList( { // List Windows drives w->disabled_widgets |= (1ULL << WIDX_NEW_FILE) | (1ULL << WIDX_NEW_FOLDER) | (1ULL << WIDX_UP); - for (int32_t x = 0; x < 26; x++) + static constexpr auto NumDriveLetters = 26; + for (int32_t x = 0; x < NumDriveLetters; x++) { if (drives & (1 << x)) { diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index a3fe229560..15cc579159 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -804,11 +804,11 @@ public: // Land tool mode (4 checkboxes) int checkboxY = height - 55; - for (int32_t i = 0; i < 4; i++) + for (int32_t i = WIDX_LAND_OWNED_CHECKBOX; i <= WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX; i++) { - widgets[WIDX_LAND_OWNED_CHECKBOX + i].top = checkboxY; + widgets[i].top = checkboxY; checkboxY += 11; - widgets[WIDX_LAND_OWNED_CHECKBOX + i].bottom = checkboxY; + widgets[i].bottom = checkboxY; checkboxY += 2; } @@ -844,8 +844,8 @@ public: widgets[WIDX_LAND_TOOL_SMALLER].type = WindowWidgetType::TrnBtn; widgets[WIDX_LAND_TOOL_LARGER].type = WindowWidgetType::TrnBtn; - for (int32_t i = 0; i < 4; i++) - widgets[WIDX_LAND_OWNED_CHECKBOX + i].type = WindowWidgetType::Checkbox; + for (int32_t i = WIDX_LAND_OWNED_CHECKBOX; i <= WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX; i++) + widgets[i].type = WindowWidgetType::Checkbox; widgets[WIDX_LAND_TOOL].image = LandTool::SizeToSpriteIndex(_landRightsToolSize); } diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index 2fb47106ea..9d2deda673 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -277,9 +277,9 @@ static void WindowMultiplayerAnchorBorderWidgets(rct_window* w) static void WindowMultiplayerSetPressedTab(rct_window* w) { - for (int32_t i = 0; i < 2; i++) + for (int32_t i = WIDX_TAB1; i <= WIDX_TAB4; i++) { - w->pressed_widgets &= ~(1 << (WIDX_TAB1 + i)); + w->pressed_widgets &= ~(1 << i); } w->pressed_widgets |= 1LL << (WIDX_TAB1 + w->page); } diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index 49b648126e..de3c2c4941 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -1213,8 +1213,8 @@ private: void SetPressedTab() { - for (auto i = 0; i < 7; i++) - pressed_widgets &= ~(1 << (WIDX_TAB_1 + i)); + for (int32_t i = WIDX_TAB_1; i <= WIDX_TAB_7; i++) + pressed_widgets &= ~(1 << i); pressed_widgets |= 1LL << (WIDX_TAB_1 + page); } diff --git a/src/openrct2-ui/windows/Research.cpp b/src/openrct2-ui/windows/Research.cpp index e723fb070a..5452b06a2d 100644 --- a/src/openrct2-ui/windows/Research.cpp +++ b/src/openrct2-ui/windows/Research.cpp @@ -7,6 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include #include #include #include @@ -425,15 +426,12 @@ static void WindowResearchFundingMouseup(rct_window* w, WidgetIndex widgetIndex) */ static void WindowResearchFundingMousedown(rct_window* w, WidgetIndex widgetIndex, rct_widget* widget) { - rct_widget* dropdownWidget; - int32_t i; - if (widgetIndex != WIDX_RESEARCH_FUNDING_DROPDOWN_BUTTON) return; - dropdownWidget = widget - 1; + rct_widget* dropdownWidget = widget - 1; - for (i = 0; i < 4; i++) + for (std::size_t i = 0; i < std::size(ResearchFundingLevelNames); i++) { gDropdownItems[i].Format = STR_DROPDOWN_MENU_LABEL; gDropdownItems[i].Args = ResearchFundingLevelNames[i]; diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index a455e42c33..22c7b06f8e 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -294,7 +294,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Peep, PathfindGoal.y); COMPARE_FIELD(Peep, PathfindGoal.z); COMPARE_FIELD(Peep, PathfindGoal.direction); - for (int i = 0; i < 4; i++) + for (std::size_t i = 0; i < spriteCmp.PathfindHistory.size(); i++) { COMPARE_FIELD(Peep, PathfindHistory[i].x); COMPARE_FIELD(Peep, PathfindHistory[i].y); @@ -349,7 +349,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Guest, RejoinQueueTimeout); COMPARE_FIELD(Guest, PreviousRide); COMPARE_FIELD(Guest, PreviousRideTimeOut); - for (int i = 0; i < PEEP_MAX_THOUGHTS; i++) + for (std::size_t i = 0; i < PEEP_MAX_THOUGHTS; i++) { COMPARE_FIELD(Guest, Thoughts[i].type); COMPARE_FIELD(Guest, Thoughts[i].item); @@ -412,11 +412,11 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Vehicle, SwingSpeed); COMPARE_FIELD(Vehicle, status); COMPARE_FIELD(Vehicle, sub_state); - for (int i = 0; i < 32; i++) + for (std::size_t i = 0; i < sizeof(Vehicle::peep) / sizeof(*Vehicle::peep); i++) { COMPARE_FIELD(Vehicle, peep[i]); } - for (int i = 0; i < 32; i++) + for (std::size_t i = 0; i < sizeof(Vehicle::peep_tshirt_colours) / sizeof(*Vehicle::peep_tshirt_colours); i++) { COMPARE_FIELD(Vehicle, peep_tshirt_colours[i]); } @@ -437,7 +437,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Vehicle, powered_acceleration); COMPARE_FIELD(Vehicle, CollisionDetectionTimer); COMPARE_FIELD(Vehicle, animation_frame); - for (int i = 0; i < 2; i++) + for (std::size_t i = 0; i < sizeof(Vehicle::pad_C6) / sizeof(*Vehicle::pad_C6); i++) { COMPARE_FIELD(Vehicle, pad_C6[i]); } @@ -489,7 +489,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots { COMPARE_FIELD(VehicleCrashParticle, frame); COMPARE_FIELD(VehicleCrashParticle, time_to_live); - for (int i = 0; i < 2; i++) + for (std::size_t i = 0; i < sizeof(VehicleCrashParticle::colour) / sizeof(*VehicleCrashParticle::colour); i++) { COMPARE_FIELD(VehicleCrashParticle, colour[i]); } diff --git a/src/openrct2/core/DataSerialiserTraits.h b/src/openrct2/core/DataSerialiserTraits.h index df91368b39..d12b9d44c0 100644 --- a/src/openrct2/core/DataSerialiserTraits.h +++ b/src/openrct2/core/DataSerialiserTraits.h @@ -455,13 +455,13 @@ template<> struct DataSerializerTraits_t stream->WriteValue(tileElement.base_height); stream->WriteValue(tileElement.clearance_height); stream->WriteValue(tileElement.owner); - for (int i = 0; i < 3; ++i) + for (auto v : tileElement.pad_05) { - stream->WriteValue(tileElement.pad_05[i]); + stream->WriteValue(v); } - for (int i = 0; i < 8; ++i) + for (auto v : tileElement.pad_08) { - stream->WriteValue(tileElement.pad_08[i]); + stream->WriteValue(v); } } static void decode(OpenRCT2::IStream* stream, TileElement& tileElement) @@ -471,13 +471,13 @@ template<> struct DataSerializerTraits_t tileElement.base_height = stream->ReadValue(); tileElement.clearance_height = stream->ReadValue(); tileElement.owner = stream->ReadValue(); - for (int i = 0; i < 3; ++i) + for (auto& v : tileElement.pad_05) { - tileElement.pad_05[i] = stream->ReadValue(); + v = stream->ReadValue(); } - for (int i = 0; i < 8; ++i) + for (auto& v : tileElement.pad_08) { - tileElement.pad_08[i] = stream->ReadValue(); + v = stream->ReadValue(); } } static void log(OpenRCT2::IStream* stream, const TileElement& tileElement) diff --git a/src/openrct2/entity/Fountain.cpp b/src/openrct2/entity/Fountain.cpp index 8557b1c2af..8b29329002 100644 --- a/src/openrct2/entity/Fountain.cpp +++ b/src/openrct2/entity/Fountain.cpp @@ -15,6 +15,7 @@ #include "../profiling/Profiling.h" #include "../scenario/Scenario.h" #include "../world/Footpath.h" +#include "../world/Location.hpp" #include "../world/Map.h" #include "../world/Scenery.h" #include "EntityRegistry.h" @@ -93,7 +94,7 @@ void JumpingFountain::StartAnimation(const JumpingFountainType newType, const Co { case PATTERN::CYCLIC_SQUARES: // 0, 1, 2, 3 - for (int32_t i = 0; i < 4; i++) + for (int32_t i = 0; i < NumOrthogonalDirections; i++) { JumpingFountain::Create( newType, { newLoc + _fountainDirectionsPositive[i], newZ }, _fountainDirections[i], @@ -103,7 +104,7 @@ void JumpingFountain::StartAnimation(const JumpingFountainType newType, const Co case PATTERN::BOUNCING_PAIRS: // random [0, 2 or 1, 3] randomIndex = scenario_rand() & 1; - for (int32_t i = randomIndex; i < 4; i += 2) + for (int32_t i = randomIndex; i < NumOrthogonalDirections; i += 2) { JumpingFountain::Create( newType, { newLoc + _fountainDirectionsPositive[i], newZ }, _fountainDirections[i], diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index a9f36cc17b..96c959f895 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -46,6 +46,7 @@ #include "../world/Climate.h" #include "../world/Footpath.h" #include "../world/LargeScenery.h" +#include "../world/Location.hpp" #include "../world/Map.h" #include "../world/Park.h" #include "../world/Scenery.h" @@ -4842,7 +4843,7 @@ void Guest::UpdateRideMazePathfinding() uint8_t hedges[4]{ 0xFF, 0xFF, 0xFF, 0xFF }; uint8_t openCount = 0; uint8_t mazeReverseLastEdge = DirectionReverse(MazeLastEdge); - for (uint8_t i = 0; i < 4; ++i) + for (uint8_t i = 0; i < NumOrthogonalDirections; ++i) { if (!(mazeEntry & (1 << _MazeCurrentDirectionToOpenHedge[Var37 / 4][i])) && i != mazeReverseLastEdge) { diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 946cdcc71d..d12bb77221 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -735,7 +735,6 @@ static int32_t cc_get(InteractiveConsole& console, const arguments_t& argv) } static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv) { - uint32_t i; if (argv.size() > 1) { int32_t int_val[4]; @@ -744,7 +743,7 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv) bool double_valid[4]; bool invalidArgs = false; - for (i = 0; i < 4; i++) + for (uint32_t i = 0; i < std::size(int_val); i++) { if (i + 1 < argv.size()) { @@ -1201,8 +1200,8 @@ static int32_t cc_load_object(InteractiveConsole& console, const arguments_t& ar { char name[9] = { 0 }; std::fill_n(name, 8, ' '); - int32_t i = 0; - for (const char* ch = argv[0].c_str(); *ch != '\0' && i < 8; ch++) + std::size_t i = 0; + for (const char* ch = argv[0].c_str(); *ch != '\0' && i < std::size(name) - 1; ch++) { name[i++] = *ch; } diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index ee2ac4928b..a2a9cd2e2c 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -1306,9 +1306,8 @@ void window_resize(rct_window& w, int32_t dw, int32_t dh) window_event_invalidate_call(&w); // Update scroll widgets - for (int32_t i = 0; i < 3; i++) + for (auto& scroll : w.scrolls) { - auto& scroll = w.scrolls[i]; scroll.h_right = WINDOW_SCROLL_UNDEFINED; scroll.v_bottom = WINDOW_SCROLL_UNDEFINED; } diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index df9d13e914..b31c7000b6 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -1047,7 +1047,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con tile_descriptor tileDescriptors[5]; tileDescriptors[0] = selfDescriptor; - for (int32_t i = 0; i < 4; i++) + for (std::size_t i = 0; i < std::size(viewport_surface_paint_data); i++) { const CoordsXY& offset = viewport_surface_paint_data[i][rotation]; const CoordsXY position = base + offset; diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index d7d15383c0..730bbf9805 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -310,9 +310,9 @@ static void PaintTileElementBase(PaintSession& session, const CoordsXY& origCoor { 1, 7, 3 }, }; - for (int32_t sy = 0; sy < 3; sy++) + for (std::size_t sy = 0; sy < std::size(segmentPositions); sy++) { - for (int32_t sx = 0; sx < 3; sx++) + for (std::size_t sx = 0; sx < std::size(segmentPositions[sy]); sx++) { uint16_t segmentHeight = session.SupportSegments[segmentPositions[sy][sx]].height; auto imageColourFlats = ImageId(SPR_LAND_TOOL_SIZE_1).WithTransparency(FilterPaletteID::PaletteDarken3); @@ -328,8 +328,8 @@ static void PaintTileElementBase(PaintSession& session, const CoordsXY& origCoor if ((session.ViewFlags & VIEWPORT_FLAG_CLIP_VIEW) && (segmentHeight > gClipHeight)) continue; - int32_t xOffset = sy * 10; - int32_t yOffset = -22 + sx * 10; + int32_t xOffset = static_cast(sy) * 10; + int32_t yOffset = -22 + static_cast(sx) * 10; PaintStruct* ps = PaintAddImageAsParent( session, imageColourFlats, { xOffset, yOffset, segmentHeight }, { 10, 10, 1 }, { xOffset + 1, yOffset + 16, segmentHeight }); @@ -389,7 +389,7 @@ const uint16_t segment_offsets[9] = { void PaintUtilSetSegmentSupportHeight(PaintSession& session, int32_t segments, uint16_t height, uint8_t slope) { SupportHeight* supportSegments = session.SupportSegments; - for (int32_t s = 0; s < 9; s++) + for (std::size_t s = 0; s < std::size(segment_offsets); s++) { if (segments & segment_offsets[s]) { diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 8b66d1ceb1..ac13f024ca 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -1590,7 +1590,7 @@ Direction OriginalPathfinding::ChooseDirection(const TileCoordsXYZ& loc, Peep& p if (isThin) { - for (int32_t i = 0; i < 4; ++i) + for (std::size_t i = 0; i < peep.PathfindHistory.size(); ++i) { if (peep.PathfindHistory[i] == loc) { @@ -1604,7 +1604,7 @@ Direction OriginalPathfinding::ChooseDirection(const TileCoordsXYZ& loc, Peep& p if (_pathFindDebug) { log_verbose( - "Updating existing pf_history (in index: %d) for %d,%d,%d without entry edge %d & exit edge %d.", i, + "Updating existing pf_history (in index: %u) for %d,%d,%d without entry edge %d & exit edge %d.", i, loc.x, loc.y, loc.z, DirectionReverse(peep.PeepDirection), chosen_edge); } #endif // defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 diff --git a/src/openrct2/ride/transport/Chairlift.cpp b/src/openrct2/ride/transport/Chairlift.cpp index 32e439b73f..4587e8414f 100644 --- a/src/openrct2/ride/transport/Chairlift.cpp +++ b/src/openrct2/ride/transport/Chairlift.cpp @@ -16,6 +16,8 @@ #include "../Track.h" #include "../TrackPaint.h" +#include + enum { SPR_CHAIRLIFT_CABLE_FLAT_SW_NE = 20500, @@ -79,7 +81,7 @@ static void chairlift_paint_util_draw_supports(PaintSession& session, int32_t se { bool success = false; - for (int32_t s = 0; s < 9; s++) + for (uint8_t s = 0; s < std::size(segment_offsets); s++) { if (!(segments & segment_offsets[s])) { @@ -98,7 +100,7 @@ static void chairlift_paint_util_draw_supports(PaintSession& session, int32_t se } SupportHeight* supportSegments = session.SupportSegments; - for (int32_t s = 0; s < 9; s++) + for (uint8_t s = 0; s < std::size(segment_offsets); s++) { if (!(segments & segment_offsets[s])) { diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index e1a30e91e5..cec3b68fc9 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -33,6 +33,7 @@ #include "../ride/Track.h" #include "../ride/TrackData.h" #include "../util/Util.h" +#include "Location.hpp" #include "Map.h" #include "MapAnimation.h" #include "Park.h" @@ -509,7 +510,7 @@ static void FootpathConnectCorners(const CoordsXY& footpathPos, PathElement* ini std::get<0>(tileElements) = { initialTileElement, footpathPos }; int32_t z = initialTileElement->GetBaseZ(); - for (int32_t initialDirection = 0; initialDirection < 4; initialDirection++) + for (int32_t initialDirection = 0; initialDirection < NumOrthogonalDirections; initialDirection++) { int32_t direction = initialDirection; auto currentPos = footpathPos + CoordsDirectionDelta[direction]; @@ -1862,8 +1863,7 @@ void FootpathUpdatePathWideFlags(const CoordsXY& footpathPos) // pathList is a list of elements, set by sub_6A8ACF adjacent to x,y // Spanned from 0x00F3EFA8 to 0x00F3EFC7 (8 elements) in the original std::array pathList; - - for (int32_t direction = 0; direction < 8; ++direction) + for (std::size_t direction = 0; direction < pathList.size(); ++direction) { auto footpathLoc = CoordsXYZ(footpathPos + CoordsDirectionDelta[direction], height); pathList[direction] = FootpathCanBeWide(footpathLoc); @@ -2030,7 +2030,7 @@ void FootpathUpdateQueueEntranceBanner(const CoordsXY& footpathPos, TileElement* if (tileElement->AsPath()->IsQueue()) { FootpathQueueChainPush(tileElement->AsPath()->GetRideIndex()); - for (int32_t direction = 0; direction < 4; direction++) + for (int32_t direction = 0; direction < NumOrthogonalDirections; direction++) { if (tileElement->AsPath()->GetEdges() & (1 << direction)) { @@ -2284,7 +2284,7 @@ void FootpathRemoveEdgesAt(const CoordsXY& footpathPos, TileElement* tileElement FootpathUpdateQueueEntranceBanner(footpathPos, tileElement); bool fixCorners = false; - for (uint8_t direction = 0; direction < 4; direction++) + for (uint8_t direction = 0; direction < NumOrthogonalDirections; direction++) { int32_t z1 = tileElement->base_height; if (tileElement->GetType() == TileElementType::Path) diff --git a/src/openrct2/world/MapHelpers.cpp b/src/openrct2/world/MapHelpers.cpp index 4a44a1d1ad..b35d308f2f 100644 --- a/src/openrct2/world/MapHelpers.cpp +++ b/src/openrct2/world/MapHelpers.cpp @@ -25,7 +25,7 @@ static uint8_t GetBaseHeightOrZero(int32_t x, int32_t y) */ int32_t MapSmooth(int32_t l, int32_t t, int32_t r, int32_t b) { - int32_t i, x, y, count, doubleCorner, raisedLand = 0; + int32_t x, y, count, doubleCorner, raisedLand = 0; uint8_t highest, cornerHeights[4]; for (y = t; y < b; y++) { @@ -55,14 +55,14 @@ int32_t MapSmooth(int32_t l, int32_t t, int32_t r, int32_t b) cornerHeights[2] = GetBaseHeightOrZero(x + 1, y + 1); cornerHeights[3] = GetBaseHeightOrZero(x - 1, y + 1); highest = surfaceElement->base_height; - for (i = 0; i < 4; i++) + for (std::size_t i = 0; i < std::size(cornerHeights); i++) highest = std::max(highest, cornerHeights[i]); if (highest >= surfaceElement->base_height + 4) { count = 0; int32_t canCompensate = 1; - for (i = 0; i < 4; i++) + for (std::size_t i = 0; i < std::size(cornerHeights); i++) if (cornerHeights[i] == highest) { count++;