mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use empty() for vectors; clean up bool comparisons (#9118)
This commit is contained in:
parent
6022521118
commit
42a1a8704d
|
@ -881,7 +881,7 @@ void OpenGLDrawingContext::FlushCommandBuffers()
|
|||
|
||||
void OpenGLDrawingContext::FlushLines()
|
||||
{
|
||||
if (_commandBuffers.lines.size() == 0)
|
||||
if (_commandBuffers.lines.empty())
|
||||
return;
|
||||
|
||||
_drawLineShader->Use();
|
||||
|
@ -892,7 +892,7 @@ void OpenGLDrawingContext::FlushLines()
|
|||
|
||||
void OpenGLDrawingContext::FlushRectangles()
|
||||
{
|
||||
if (_commandBuffers.rects.size() == 0)
|
||||
if (_commandBuffers.rects.empty())
|
||||
return;
|
||||
|
||||
OpenGLAPI::SetTexture(0, GL_TEXTURE_2D_ARRAY, _textureCache->GetAtlasesTexture());
|
||||
|
|
|
@ -197,7 +197,7 @@ void TextureCache::EnlargeAtlasesTexture(GLuint newEntries)
|
|||
{
|
||||
// Retrieve current array data, growing buffer.
|
||||
oldPixels.resize(_atlasesTextureDimensions * _atlasesTextureDimensions * _atlasesTextureCapacity);
|
||||
if (oldPixels.size() > 0)
|
||||
if (!oldPixels.empty())
|
||||
{
|
||||
glGetTexImage(GL_TEXTURE_2D_ARRAY, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, oldPixels.data());
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ void TextureCache::EnlargeAtlasesTexture(GLuint newEntries)
|
|||
GL_RED_INTEGER, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
||||
// Restore old data
|
||||
if (oldPixels.size() > 0)
|
||||
if (!oldPixels.empty())
|
||||
{
|
||||
glTexSubImage3D(
|
||||
GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _atlasesTextureDimensions, _atlasesTextureDimensions, _atlasesTextureIndices,
|
||||
|
|
|
@ -324,7 +324,7 @@ static void visible_list_refresh(rct_window* w)
|
|||
}
|
||||
}
|
||||
|
||||
if (_listItems.size() == 0)
|
||||
if (_listItems.empty())
|
||||
{
|
||||
visible_list_dispose();
|
||||
}
|
||||
|
|
|
@ -876,7 +876,7 @@ static void window_park_init_viewport(rct_window* w)
|
|||
if (w->page != WINDOW_PARK_PAGE_ENTRANCE)
|
||||
return;
|
||||
|
||||
if (gParkEntrances.size() > 0)
|
||||
if (!gParkEntrances.empty())
|
||||
{
|
||||
const auto& entrance = gParkEntrances[0];
|
||||
x = entrance.x + 16;
|
||||
|
|
|
@ -1218,7 +1218,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex,
|
|||
if (peep.type != PEEP_TYPE_STAFF)
|
||||
return;
|
||||
|
||||
if (staff_is_patrol_area_set(peep.staff_id, dest_x, dest_y) == true)
|
||||
if (staff_is_patrol_area_set(peep.staff_id, dest_x, dest_y))
|
||||
{
|
||||
_staffPatrolAreaPaintValue = PatrolAreaValue::UNSET;
|
||||
}
|
||||
|
@ -1260,7 +1260,7 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex,
|
|||
return;
|
||||
|
||||
bool patrolAreaValue = staff_is_patrol_area_set(peep.staff_id, dest_x, dest_y);
|
||||
if (_staffPatrolAreaPaintValue == PatrolAreaValue::SET && patrolAreaValue == true)
|
||||
if (_staffPatrolAreaPaintValue == PatrolAreaValue::SET && patrolAreaValue)
|
||||
return; // Since area is already the value we want, skip...
|
||||
if (_staffPatrolAreaPaintValue == PatrolAreaValue::UNSET && patrolAreaValue == false)
|
||||
return; // Since area is already the value we want, skip...
|
||||
|
|
|
@ -1758,7 +1758,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo
|
|||
}
|
||||
|
||||
// Actually place
|
||||
if (success == GA_ERROR::OK || ((q + 1 == quantity) && (forceError == true)))
|
||||
if (success == GA_ERROR::OK || ((q + 1 == quantity) && forceError))
|
||||
{
|
||||
auto smallSceneryPlaceAction = SmallSceneryPlaceAction(
|
||||
{ cur_grid_x, cur_grid_y, gSceneryPlaceZ, gSceneryPlaceRotation }, quadrant, type, primaryColour,
|
||||
|
|
|
@ -499,7 +499,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
|||
int32_t listItemIndex = w->selected_list_item;
|
||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
|
||||
{
|
||||
if (_trackDesigns.size() == 0 || listItemIndex == -1)
|
||||
if (_trackDesigns.empty() || listItemIndex == -1)
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -718,7 +718,7 @@ static void window_track_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
|||
size_t listIndex = 0;
|
||||
if (gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)
|
||||
{
|
||||
if (_trackDesigns.size() == 0)
|
||||
if (_trackDesigns.empty())
|
||||
{
|
||||
// No track designs
|
||||
gfx_draw_string_left(dpi, STR_NO_TRACK_DESIGNS_OF_THIS_TYPE, nullptr, COLOUR_BLACK, x, y - 1);
|
||||
|
|
|
@ -491,7 +491,7 @@ namespace Editor
|
|||
return false;
|
||||
}
|
||||
|
||||
if (gParkEntrances.size() == 0)
|
||||
if (gParkEntrances.empty())
|
||||
{
|
||||
gGameCommandErrorText = STR_NO_PARK_ENTRANCES;
|
||||
return false;
|
||||
|
@ -520,7 +520,7 @@ namespace Editor
|
|||
}
|
||||
}
|
||||
|
||||
if (gPeepSpawns.size() == 0)
|
||||
if (gPeepSpawns.empty())
|
||||
{
|
||||
gGameCommandErrorText = STR_PEEP_SPAWNS_NOT_SET;
|
||||
return false;
|
||||
|
|
|
@ -836,7 +836,7 @@ void game_fix_save_vars()
|
|||
}
|
||||
}
|
||||
|
||||
if (peepsToRemove.size() > 0)
|
||||
if (!peepsToRemove.empty())
|
||||
{
|
||||
// Some broken saves have broken spatial indexes
|
||||
reset_sprite_spatial_index();
|
||||
|
|
|
@ -399,7 +399,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
if (gPeepSpawns.size() == 0)
|
||||
if (gPeepSpawns.empty())
|
||||
{
|
||||
gPeepSpawns.emplace_back();
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace GameActions
|
|||
Guard::ArgumentNotNull(action);
|
||||
|
||||
uint16_t actionFlags = action->GetActionFlags();
|
||||
if (topLevel == true && !CheckActionInPausedMode(actionFlags))
|
||||
if (topLevel && !CheckActionInPausedMode(actionFlags))
|
||||
{
|
||||
GameActionResult::Ptr result = std::make_unique<GameActionResult>();
|
||||
|
||||
|
@ -358,7 +358,7 @@ namespace GameActions
|
|||
}
|
||||
|
||||
// Only show errors when its not a ghost and not a preview and also top level action.
|
||||
bool shouldShowError = !(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_NO_SPEND) && topLevel == true;
|
||||
bool shouldShowError = !(flags & GAME_COMMAND_FLAG_GHOST) && !(flags & GAME_COMMAND_FLAG_NO_SPEND) && topLevel;
|
||||
|
||||
// In network mode the error should be only shown to the issuer of the action.
|
||||
if (network_get_mode() != NETWORK_MODE_NONE)
|
||||
|
@ -369,7 +369,7 @@ namespace GameActions
|
|||
}
|
||||
}
|
||||
|
||||
if (result->Error != GA_ERROR::OK && shouldShowError == true)
|
||||
if (result->Error != GA_ERROR::OK && shouldShowError)
|
||||
{
|
||||
// Show the error box
|
||||
std::copy(result->ErrorMessageArgs.begin(), result->ErrorMessageArgs.end(), gCommonFormatArgs);
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (calculate_cost == true)
|
||||
if (calculate_cost)
|
||||
res->Cost = scenery_entry->large_scenery.removal_price * 10;
|
||||
|
||||
return res;
|
||||
|
|
|
@ -225,7 +225,7 @@ private:
|
|||
newPeep->sprite_height_negative = spriteBounds->sprite_height_negative;
|
||||
newPeep->sprite_height_positive = spriteBounds->sprite_height_positive;
|
||||
|
||||
if (_autoPosition == true)
|
||||
if (_autoPosition)
|
||||
{
|
||||
AutoPositionNewStaff(newPeep);
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ private:
|
|||
else
|
||||
{
|
||||
// No walking guests; pick random park entrance
|
||||
if (gParkEntrances.size() > 0)
|
||||
if (!gParkEntrances.empty())
|
||||
{
|
||||
auto rand = scenario_rand_max((uint32_t)gParkEntrances.size());
|
||||
const auto& entrance = gParkEntrances[rand];
|
||||
|
|
|
@ -66,7 +66,7 @@ private:
|
|||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
if (isExecuting == true)
|
||||
if (isExecuting)
|
||||
{
|
||||
tileElement->AsTrack()->SetBrakeBoosterSpeed(_brakeSpeed);
|
||||
}
|
||||
|
|
|
@ -922,7 +922,7 @@ void viewport_paint(
|
|||
if (window_get_main() != nullptr && viewport != window_get_main()->viewport)
|
||||
useMultithreading = false;
|
||||
|
||||
if (useMultithreading == true && _paintJobs == nullptr)
|
||||
if (useMultithreading && _paintJobs == nullptr)
|
||||
{
|
||||
_paintJobs = std::make_unique<JobPool>();
|
||||
}
|
||||
|
|
|
@ -2109,7 +2109,7 @@ void Network::RemoveClient(std::unique_ptr<NetworkConnection>& connection)
|
|||
[connection_player](std::unique_ptr<NetworkPlayer>& player) { return player.get() == connection_player; }),
|
||||
player_list.end());
|
||||
client_connection_list.remove(connection);
|
||||
if (gConfigNetwork.pause_server_if_no_clients && game_is_not_paused() && client_connection_list.size() == 0)
|
||||
if (gConfigNetwork.pause_server_if_no_clients && game_is_not_paused() && client_connection_list.empty())
|
||||
{
|
||||
auto pauseToggleAction = PauseToggleAction();
|
||||
GameActions::Execute(&pauseToggleAction);
|
||||
|
|
|
@ -366,7 +366,7 @@ namespace ObjectJsonHelpers
|
|||
if (is_csg_loaded())
|
||||
{
|
||||
auto range = ParseRange(s.substr(4));
|
||||
if (range.size() > 0)
|
||||
if (!range.empty())
|
||||
{
|
||||
for (auto i : range)
|
||||
{
|
||||
|
@ -380,7 +380,7 @@ namespace ObjectJsonHelpers
|
|||
else if (String::StartsWith(s, "$G1"))
|
||||
{
|
||||
auto range = ParseRange(s.substr(3));
|
||||
if (range.size() > 0)
|
||||
if (!range.empty())
|
||||
{
|
||||
for (auto i : range)
|
||||
{
|
||||
|
|
|
@ -329,7 +329,7 @@ private:
|
|||
|
||||
void SetNewLoadedObjectList(const std::vector<Object*>& newLoadedObjects)
|
||||
{
|
||||
if (newLoadedObjects.size() == 0)
|
||||
if (newLoadedObjects.empty())
|
||||
{
|
||||
UnloadAll();
|
||||
}
|
||||
|
@ -530,7 +530,7 @@ private:
|
|||
requiredObjects.push_back(ori);
|
||||
}
|
||||
|
||||
if (missingObjects.size() > 0)
|
||||
if (!missingObjects.empty())
|
||||
{
|
||||
throw ObjectLoadException(std::move(missingObjects));
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ private:
|
|||
obj->Load();
|
||||
}
|
||||
|
||||
if (badObjects.size() > 0)
|
||||
if (!badObjects.empty())
|
||||
{
|
||||
// Unload all the new objects we loaded
|
||||
for (auto object : loadedObjects)
|
||||
|
|
|
@ -668,7 +668,7 @@ static void viewport_surface_draw_tile_side_bottom(
|
|||
tunnelIndex++;
|
||||
}
|
||||
|
||||
if (isWater == true || curHeight != tunnelArray[tunnelIndex].height)
|
||||
if (isWater || curHeight != tunnelArray[tunnelIndex].height)
|
||||
{
|
||||
sub_98196C(session, base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16);
|
||||
|
||||
|
|
|
@ -2736,7 +2736,7 @@ static void peep_footpath_move_forward(Peep* peep, int16_t x, int16_t y, TileEle
|
|||
// Advance the vandalised tiles by 1
|
||||
uint8_t vandalisedTiles = (peep->vandalism_seen * 2) & 0x3F;
|
||||
|
||||
if (vandalism == true)
|
||||
if (vandalism)
|
||||
{
|
||||
// Add one more to the vandalised tiles
|
||||
vandalisedTiles |= 1;
|
||||
|
|
|
@ -644,7 +644,7 @@ static bool staff_path_finding_handyman(Peep* peep)
|
|||
}
|
||||
}
|
||||
|
||||
if (chooseRandom == true)
|
||||
if (chooseRandom)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -701,10 +701,10 @@ static uint8_t staff_direction_surface(Peep* peep, uint8_t initialDirection)
|
|||
|
||||
direction &= 3;
|
||||
|
||||
if (fence_in_the_way(peep->next_x, peep->next_y, peep->next_z, peep->next_z + 4, direction) == true)
|
||||
if (fence_in_the_way(peep->next_x, peep->next_y, peep->next_z, peep->next_z + 4, direction))
|
||||
continue;
|
||||
|
||||
if (fence_in_the_way(peep->next_x, peep->next_y, peep->next_z, peep->next_z + 4, direction_reverse(direction)) == true)
|
||||
if (fence_in_the_way(peep->next_x, peep->next_y, peep->next_z, peep->next_z + 4, direction_reverse(direction)))
|
||||
continue;
|
||||
|
||||
LocationXY16 chosenTile = { static_cast<int16_t>(peep->next_x + CoordsDirectionDelta[direction].x),
|
||||
|
|
|
@ -423,7 +423,7 @@ int32_t cable_lift_update_track_motion(rct_vehicle* cableLift)
|
|||
{
|
||||
if (vehicle->remaining_distance < 0)
|
||||
{
|
||||
if (sub_6DF21B_loop(vehicle) == true)
|
||||
if (sub_6DF21B_loop(vehicle))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -439,7 +439,7 @@ int32_t cable_lift_update_track_motion(rct_vehicle* cableLift)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (sub_6DF01A_loop(vehicle) == true)
|
||||
if (sub_6DF01A_loop(vehicle))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -7362,7 +7362,7 @@ void sub_6CB945(Ride* ride)
|
|||
shouldRemove = false;
|
||||
} while (!(trackElement++)->IsLastForTile());
|
||||
|
||||
if (shouldRemove == true)
|
||||
if (shouldRemove)
|
||||
{
|
||||
footpath_queue_chain_reset();
|
||||
maze_entrance_hedge_replacement(location.x, location.y, tileElement);
|
||||
|
|
|
@ -2499,7 +2499,7 @@ static void vehicle_update_waiting_to_depart(rct_vehicle* vehicle)
|
|||
}
|
||||
|
||||
bool skipCheck = false;
|
||||
if (shouldBreak == true || ride->status != RIDE_STATUS_OPEN)
|
||||
if (shouldBreak || ride->status != RIDE_STATUS_OPEN)
|
||||
{
|
||||
if (ride->mode == RIDE_MODE_FORWARD_ROTATION || ride->mode == RIDE_MODE_BACKWARD_ROTATION)
|
||||
{
|
||||
|
@ -3756,7 +3756,7 @@ static void vehicle_update_travelling(rct_vehicle* vehicle)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (vehicle_current_tower_element_is_top(vehicle) == true)
|
||||
if (vehicle_current_tower_element_is_top(vehicle))
|
||||
{
|
||||
vehicle->velocity = 0;
|
||||
vehicle->sub_state = 2;
|
||||
|
@ -4665,7 +4665,7 @@ static bool vehicle_boat_is_location_accessible(const TileCoordsXYZ& location)
|
|||
TileElement* tileElement = map_get_first_element_at(location.x, location.y);
|
||||
do
|
||||
{
|
||||
if (tileElement->IsGhost() == true)
|
||||
if (tileElement->IsGhost())
|
||||
continue;
|
||||
|
||||
if (tileElement->GetType() == TILE_ELEMENT_TYPE_SURFACE)
|
||||
|
@ -4940,7 +4940,7 @@ static void vehicle_update_rotating(rct_vehicle* vehicle)
|
|||
shouldStop = false;
|
||||
}
|
||||
|
||||
if (shouldStop == true)
|
||||
if (shouldStop)
|
||||
{
|
||||
if (vehicle->sub_state == 2)
|
||||
{
|
||||
|
@ -7755,7 +7755,7 @@ static bool vehicle_update_motion_collision_detection(
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (mayCollide == true)
|
||||
if (mayCollide)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -8407,7 +8407,7 @@ static bool vehicle_update_track_motion_backwards_get_new_track(
|
|||
break;
|
||||
}
|
||||
|
||||
if (nextTileBackwards == true)
|
||||
if (nextTileBackwards)
|
||||
{
|
||||
// loc_6DBB7E:;
|
||||
track_begin_end trackBeginEnd;
|
||||
|
|
|
@ -238,7 +238,7 @@ static void scenario_entrance_fee_too_high_check()
|
|||
|
||||
if ((gParkFlags & PARK_FLAGS_PARK_OPEN) && park_get_entrance_fee() > max_fee)
|
||||
{
|
||||
if (gParkEntrances.size() > 0)
|
||||
if (!gParkEntrances.empty())
|
||||
{
|
||||
const auto& entrance = gParkEntrances[0];
|
||||
auto x = entrance.x + 16;
|
||||
|
|
|
@ -1469,7 +1469,7 @@ bool PathElement::IsBroken() const
|
|||
|
||||
void PathElement::SetIsBroken(bool isBroken)
|
||||
{
|
||||
if (isBroken == true)
|
||||
if (isBroken)
|
||||
{
|
||||
flags |= TILE_ELEMENT_FLAG_BROKEN;
|
||||
}
|
||||
|
@ -1486,7 +1486,7 @@ bool PathElement::IsBlockedByVehicle() const
|
|||
|
||||
void PathElement::SetIsBlockedByVehicle(bool isBlocked)
|
||||
{
|
||||
if (isBlocked == true)
|
||||
if (isBlocked)
|
||||
{
|
||||
flags |= TILE_ELEMENT_FLAG_BLOCKED_BY_VEHICLE;
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ static void mapgen_place_trees()
|
|||
case TERRAIN_GRASS:
|
||||
case TERRAIN_DIRT:
|
||||
case TERRAIN_GRASS_CLUMPS:
|
||||
if (grassTreeIds.size() == 0)
|
||||
if (grassTreeIds.empty())
|
||||
break;
|
||||
|
||||
type = grassTreeIds[util_rand() % grassTreeIds.size()];
|
||||
|
@ -363,7 +363,7 @@ static void mapgen_place_trees()
|
|||
case TERRAIN_SAND:
|
||||
case TERRAIN_SAND_DARK:
|
||||
case TERRAIN_SAND_LIGHT:
|
||||
if (desertTreeIds.size() == 0)
|
||||
if (desertTreeIds.empty())
|
||||
break;
|
||||
|
||||
if (util_rand() % 4 == 0)
|
||||
|
@ -371,7 +371,7 @@ static void mapgen_place_trees()
|
|||
break;
|
||||
|
||||
case TERRAIN_ICE:
|
||||
if (snowTreeIds.size() == 0)
|
||||
if (snowTreeIds.empty())
|
||||
break;
|
||||
|
||||
type = snowTreeIds[util_rand() % snowTreeIds.size()];
|
||||
|
|
|
@ -95,7 +95,7 @@ void reset_park_entry()
|
|||
*/
|
||||
static PeepSpawn* get_random_peep_spawn()
|
||||
{
|
||||
if (gPeepSpawns.size() > 0)
|
||||
if (!gPeepSpawns.empty())
|
||||
{
|
||||
return &gPeepSpawns[scenario_rand() % gPeepSpawns.size()];
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ bool TileElementBase::IsGhost() const
|
|||
|
||||
void TileElementBase::SetGhost(bool isGhost)
|
||||
{
|
||||
if (isGhost == true)
|
||||
if (isGhost)
|
||||
{
|
||||
this->flags |= TILE_ELEMENT_FLAG_GHOST;
|
||||
}
|
||||
|
|
|
@ -606,7 +606,7 @@ private:
|
|||
WriteLine(tabs, "switch (direction) {");
|
||||
for (int direction = 0; direction < 4; direction++)
|
||||
{
|
||||
if (calls[direction].size() == 0)
|
||||
if (calls[direction].empty())
|
||||
continue;
|
||||
|
||||
WriteLine(tabs, "case %d:", direction);
|
||||
|
@ -720,7 +720,7 @@ private:
|
|||
function_call lastCall = calls[0].back();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (calls[i].size() == 0 || !CompareFunctionCall(calls[i].back(), lastCall))
|
||||
if (calls[i].empty() || !CompareFunctionCall(calls[i].back(), lastCall))
|
||||
{
|
||||
goto finished;
|
||||
}
|
||||
|
|
|
@ -620,7 +620,7 @@ int main(int argc, char* argv[])
|
|||
Write(Verbosity::QUIET, CLIColour::GREEN, "[ PASSED ] ");
|
||||
Write(Verbosity::QUIET, "%d tests.\n", successCount);
|
||||
|
||||
if (failures.size() > 0)
|
||||
if (!failures.empty())
|
||||
{
|
||||
Write(Verbosity::QUIET, CLIColour::RED, "[ FAILED ] ");
|
||||
Write(Verbosity::QUIET, "%d tests, listed below:\n", (int)failures.size());
|
||||
|
|
Loading…
Reference in New Issue