From 6833da77e3ecc2344ea2c27301563a33a07e1192 Mon Sep 17 00:00:00 2001 From: Filip Gawin Date: Fri, 10 May 2019 22:00:38 +0200 Subject: [PATCH] Simplify boolean expresions --- .../windows/EditorObjectSelection.cpp | 5 +---- src/openrct2-ui/windows/RideConstruction.cpp | 4 ++-- src/openrct2-ui/windows/ServerList.cpp | 2 +- src/openrct2-ui/windows/Staff.cpp | 6 +++--- src/openrct2/ReplayManager.cpp | 11 ++++------- src/openrct2/actions/GameAction.cpp | 4 ++-- src/openrct2/actions/GameActionCompat.cpp | 9 +-------- src/openrct2/interface/InteractiveConsole.cpp | 2 +- src/openrct2/localisation/UTF8.cpp | 4 +--- src/openrct2/management/Finance.cpp | 8 +------- src/openrct2/network/Network.cpp | 6 +++--- .../network/NetworkServerAdvertiser.cpp | 2 +- src/openrct2/paint/Supports.cpp | 2 +- .../paint/tile_element/Paint.Surface.cpp | 2 +- src/openrct2/peep/Guest.cpp | 7 +------ src/openrct2/peep/GuestPathfinding.cpp | 2 +- src/openrct2/peep/Staff.cpp | 2 +- src/openrct2/platform/Posix.cpp | 6 +----- src/openrct2/ride/Ride.cpp | 19 +++++-------------- src/openrct2/ride/Vehicle.cpp | 13 +++++-------- .../ride/transport/MiniatureRailway.cpp | 12 ++++++------ src/openrct2/util/SawyerCoding.cpp | 2 +- src/openrct2/world/Banner.cpp | 2 +- src/openrct2/world/Map.cpp | 15 ++++++--------- src/openrct2/world/Sprite.cpp | 5 +---- 25 files changed, 52 insertions(+), 100 deletions(-) diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index d751d2b33f..9d61f7c1a8 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -1460,10 +1460,7 @@ static bool filter_chunks(const ObjectRepositoryItem* item) break; } } - if (_filter_flags & (1 << (gRideCategories[rideType] + _numSourceGameItems))) - return true; - - return false; + return (_filter_flags & (1 << (gRideCategories[rideType] + _numSourceGameItems))) != 0; } return true; } diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 2c62047cc4..408d789a8c 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -2449,14 +2449,14 @@ static void sub_6CBCE2( // Set the temporary track element _tempTrackTileElement.SetType(TILE_ELEMENT_TYPE_TRACK); _tempTrackTileElement.SetDirection(trackDirection); - _tempTrackTileElement.AsTrack()->SetHasChain((edx & 0x10000) ? true : false); + _tempTrackTileElement.AsTrack()->SetHasChain((edx & 0x10000) != 0); _tempTrackTileElement.flags = quarterTile.GetBaseQuarterOccupied() | TILE_ELEMENT_FLAG_LAST_TILE; _tempTrackTileElement.base_height = baseZ; _tempTrackTileElement.clearance_height = clearanceZ; _tempTrackTileElement.AsTrack()->SetTrackType(trackType); _tempTrackTileElement.AsTrack()->SetSequenceIndex(trackBlock->index); _tempTrackTileElement.AsTrack()->SetHasCableLift(false); - _tempTrackTileElement.AsTrack()->SetInverted((edx & 0x20000) ? true : false); + _tempTrackTileElement.AsTrack()->SetInverted((edx & 0x20000) != 0); _tempTrackTileElement.AsTrack()->SetColourScheme(RIDE_COLOUR_SCHEME_MAIN); // Skipping seat rotation, should not be necessary for a temporary piece. _tempTrackTileElement.AsTrack()->SetRideIndex(rideIndex); diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 4561afc690..16f665d7e8 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -639,7 +639,7 @@ static void join_server(std::string address) static void fetch_servers() { std::string masterServerUrl = OPENRCT2_MASTER_SERVER_URL; - if (gConfigNetwork.master_server_url.empty() == false) + if (!gConfigNetwork.master_server_url.empty()) { masterServerUrl = gConfigNetwork.master_server_url; } diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 6758034a3d..a6e47a306c 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -1211,7 +1211,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, return; rct_sprite* sprite = try_get_sprite(w->number); - if (sprite == nullptr || sprite->IsPeep() == false) + if (sprite == nullptr || !sprite->IsPeep()) return; Peep& peep = sprite->peep; @@ -1252,7 +1252,7 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex, return; rct_sprite* sprite = try_get_sprite(w->number); - if (sprite == nullptr || sprite->IsPeep() == false) + if (sprite == nullptr || !sprite->IsPeep()) return; Peep& peep = sprite->peep; @@ -1262,7 +1262,7 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex, bool patrolAreaValue = staff_is_patrol_area_set(peep.staff_id, dest_x, dest_y); if (_staffPatrolAreaPaintValue == PatrolAreaValue::SET && patrolAreaValue) return; // Since area is already the value we want, skip... - if (_staffPatrolAreaPaintValue == PatrolAreaValue::UNSET && patrolAreaValue == false) + if (_staffPatrolAreaPaintValue == PatrolAreaValue::UNSET && !patrolAreaValue) return; // Since area is already the value we want, skip... auto staffSetPatrolAreaAction = StaffSetPatrolAreaAction(w->number, { dest_x, dest_y }); diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index baafa4c97c..157be538b0 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -443,12 +443,12 @@ namespace OpenRCT2 { _mode = ReplayMode::NORMALISATION; - if (StartPlayback(file) == false) + if (!StartPlayback(file)) { return false; } - if (StartRecording(outFile, k_MaxReplayTicks) == false) + if (!StartRecording(outFile, k_MaxReplayTicks)) { StopPlayback(); return false; @@ -621,7 +621,7 @@ namespace OpenRCT2 return false; char buffer[128]; - while (feof(fp) == false) + while (feof(fp) == 0) { size_t numBytesRead = fread(buffer, 1, 128, fp); if (numBytesRead == 0) @@ -785,10 +785,7 @@ namespace OpenRCT2 bool Compatible(ReplayRecordData& data) { - if (data.version == 1 && ReplayVersion == 2) - return true; - - return false; + return data.version == 1 && ReplayVersion == 2; } bool Serialise(DataSerialiser& serialiser, ReplayRecordData& data) diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index aab701bc92..731e4d59ae 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -154,7 +154,7 @@ namespace GameActions if (result->Error == GA_ERROR::OK) { - if (finance_check_affordability(result->Cost, action->GetFlags()) == false) + if (!finance_check_affordability(result->Cost, action->GetFlags())) { result->Error = GA_ERROR::INSUFFICIENT_FUNDS; result->ErrorMessage = STR_NOT_ENOUGH_CASH_REQUIRES; @@ -290,7 +290,7 @@ namespace GameActions LogActionFinish(logContext, action, result); // If not top level just give away the result. - if (topLevel == false) + if (!topLevel) return result; gCommandPosition.x = result->Position.x; diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index b30569dd0e..7d71693de3 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -252,14 +252,7 @@ bool place_peep_spawn(CoordsXYZD location) { auto gameAction = PlacePeepSpawnAction(location); auto result = GameActions::Execute(&gameAction); - if (result->Error == GA_ERROR::OK) - { - return true; - } - else - { - return false; - } + return result->Error == GA_ERROR::OK; } #pragma endregion diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index ecb41e51ed..eebeea7f4d 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1436,7 +1436,7 @@ static int32_t cc_replay_stoprecord(InteractiveConsole& console, const arguments } auto* replayManager = OpenRCT2::GetContext()->GetReplayManager(); - if (replayManager->IsRecording() == false && replayManager->IsNormalising() == false) + if (!replayManager->IsRecording() && !replayManager->IsNormalising()) { console.WriteFormatLine("Replay currently not recording"); return 0; diff --git a/src/openrct2/localisation/UTF8.cpp b/src/openrct2/localisation/UTF8.cpp index 6318b58b9c..708e8df85d 100644 --- a/src/openrct2/localisation/UTF8.cpp +++ b/src/openrct2/localisation/UTF8.cpp @@ -276,7 +276,5 @@ bool utf8_is_format_code(int32_t codepoint) bool utf8_is_colour_code(int32_t codepoint) { - if (codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END) - return true; - return false; + return codepoint >= FORMAT_COLOUR_CODE_START && codepoint <= FORMAT_COLOUR_CODE_END; } diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index dcacab3d7f..9eedd38245 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -89,13 +89,7 @@ bool finance_check_money_required(uint32_t flags) */ bool finance_check_affordability(money32 cost, uint32_t flags) { - if (cost <= 0) - return true; - if (finance_check_money_required(flags) == false) - return true; - if (cost > gCash) - return false; - return true; + return cost <= 0 || !finance_check_money_required(flags) || cost <= gCash; } /** diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index cbc767b85c..314408b792 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -986,7 +986,7 @@ void Network::SendPacketToClients(NetworkPacket& packet, bool front, bool gameCm bool Network::CheckSRAND(uint32_t tick, uint32_t srand0) { // We have to wait for the map to be loaded first, ticks may match current loaded map. - if (_clientMapLoaded == false) + if (!_clientMapLoaded) return true; auto itTickData = _serverTickData.find(tick); @@ -999,7 +999,7 @@ bool Network::CheckSRAND(uint32_t tick, uint32_t srand0) if (storedTick.srand0 != srand0) return false; - if (storedTick.spriteHash.empty() == false) + if (!storedTick.spriteHash.empty()) { rct_sprite_checksum checksum = sprite_checksum(); std::string clientSpriteHash = checksum.ToString(); @@ -2198,7 +2198,7 @@ NetworkPlayer* Network::AddPlayer(const std::string& name, const std::string& ke if (networkUser == nullptr) { player->Group = GetDefaultGroup(); - if (name.empty() == false) + if (!name.empty()) { player->SetName(MakePlayerNameUnique(String::Trim(name))); } diff --git a/src/openrct2/network/NetworkServerAdvertiser.cpp b/src/openrct2/network/NetworkServerAdvertiser.cpp index 84ee0c2934..1b8623bfb4 100644 --- a/src/openrct2/network/NetworkServerAdvertiser.cpp +++ b/src/openrct2/network/NetworkServerAdvertiser.cpp @@ -254,7 +254,7 @@ private: static std::string GetMasterServerUrl() { std::string result = OPENRCT2_MASTER_SERVER_URL; - if (gConfigNetwork.master_server_url.empty() == false) + if (!gConfigNetwork.master_server_url.empty()) { result = gConfigNetwork.master_server_url; } diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 9818b68711..593e4e2370 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -1320,7 +1320,7 @@ bool path_b_supports_paint_setup( baseHeight += z; } - if (keepGoing == false) + if (!keepGoing) { break; } diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index b95667f9d9..27b7cba907 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -781,7 +781,7 @@ static void viewport_surface_draw_tile_side_top( return; } - if (isWater == false) + if (!isWater) dl = height; // save ecx diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index ce1b11bb70..3ea536e340 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -5884,12 +5884,7 @@ bool Guest::ShouldFindBench() return false; } - if (!GetNextIsSurface() && !GetNextIsSloped()) - { - return true; - } - - return false; + return !GetNextIsSurface() && !GetNextIsSloped(); } /** diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 90c96eb0fd..7837749dc4 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -1797,7 +1797,7 @@ static void get_ride_queue_end(TileCoordsXYZ& loc) } } while (!(tileElement++)->IsLastForTile()); - if (found == false) + if (!found) break; if (!tileElement->AsPath()->IsQueue()) diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 362782a553..daaccae5dc 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -710,7 +710,7 @@ static uint8_t staff_direction_surface(Peep* peep, uint8_t initialDirection) LocationXY16 chosenTile = { static_cast(peep->next_x + CoordsDirectionDelta[direction].x), static_cast(peep->next_y + CoordsDirectionDelta[direction].y) }; - if (map_surface_is_blocked(chosenTile.x, chosenTile.y) == false) + if (!map_surface_is_blocked(chosenTile.x, chosenTile.y)) { return direction; } diff --git a/src/openrct2/platform/Posix.cpp b/src/openrct2/platform/Posix.cpp index d769268afa..733df1b6fc 100644 --- a/src/openrct2/platform/Posix.cpp +++ b/src/openrct2/platform/Posix.cpp @@ -130,11 +130,7 @@ bool platform_directory_exists(const utf8* path) struct stat dirinfo; int32_t result = stat(buffer, &dirinfo); log_verbose("checking dir %s, result = %d, is_dir = %d", buffer, result, S_ISDIR(dirinfo.st_mode)); - if ((result != 0) || !S_ISDIR(dirinfo.st_mode)) - { - return false; - } - return true; + return result == 0 && S_ISDIR(dirinfo.st_mode); } bool platform_original_game_data_exists(const utf8* path) diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 7bfe2d534f..28c96ebe07 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2570,12 +2570,7 @@ bool Ride::CanBreakDown() const } rct_ride_entry* entry = GetRideEntry(); - if (entry == nullptr || entry->flags & RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN) - { - return false; - } - - return true; + return entry != nullptr && !(entry->flags & RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN); } static void choose_random_train_to_breakdown_safe(Ride* ride) @@ -7197,7 +7192,7 @@ void sub_6CB945(Ride* ride) break; } while (!(tileElement++)->IsLastForTile()); - if (trackFound == false) + if (!trackFound) { break; } @@ -7212,7 +7207,7 @@ void sub_6CB945(Ride* ride) } } - if (specialTrack == false) + if (!specialTrack) { continue; } @@ -7782,13 +7777,9 @@ uint8_t ride_entry_get_first_non_null_ride_type(const rct_ride_entry* rideEntry) bool ride_type_supports_boosters(uint8_t rideType) { - if (rideType == RIDE_TYPE_LOOPING_ROLLER_COASTER || rideType == RIDE_TYPE_CORKSCREW_ROLLER_COASTER + return rideType == RIDE_TYPE_LOOPING_ROLLER_COASTER || rideType == RIDE_TYPE_CORKSCREW_ROLLER_COASTER || rideType == RIDE_TYPE_TWISTER_ROLLER_COASTER || rideType == RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER - || rideType == RIDE_TYPE_GIGA_COASTER || rideType == RIDE_TYPE_JUNIOR_ROLLER_COASTER) - { - return true; - } - return false; + || rideType == RIDE_TYPE_GIGA_COASTER || rideType == RIDE_TYPE_JUNIOR_ROLLER_COASTER; } int32_t get_booster_speed(uint8_t rideType, int32_t rawSpeed) diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 1c52163f3f..81c4cb0dbe 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -1862,7 +1862,7 @@ static void vehicle_update_measurements(rct_vehicle* vehicle) // Iterate through each tile_element. } while (!(tile_element++)->IsLastForTile()); - if (cover_found == false) + if (!cover_found) { ride->testing_flags &= ~RIDE_TESTING_SHELTERED; return; @@ -2544,7 +2544,7 @@ static void vehicle_update_waiting_to_depart(rct_vehicle* vehicle) } } - if (skipCheck == false) + if (!skipCheck) { if (!(ride->stations[vehicle->current_station].Depart & STATION_DEPART_FLAG)) return; @@ -3414,7 +3414,7 @@ static void vehicle_update_departing(rct_vehicle* vehicle) } } - if (vehicle_current_tower_element_is_top(vehicle) == false) + if (!vehicle_current_tower_element_is_top(vehicle)) { if (ride->mode == RIDE_MODE_FREEFALL_DROP) vehicle_invalidate(vehicle); @@ -7669,10 +7669,7 @@ static bool vehicle_update_motion_collision_detection( return false; uint8_t direction = (vehicle->sprite_direction - collideVehicle->sprite_direction + 7) & 0x1F; - if (direction >= 0xF) - return false; - - return true; + return direction < 0xF; } LocationXY8 location = { static_cast(x / 32), static_cast(y / 32) }; @@ -7760,7 +7757,7 @@ static bool vehicle_update_motion_collision_detection( } } - if (mayCollide == false) + if (!mayCollide) { vehicle->var_C4 = 0; return false; diff --git a/src/openrct2/ride/transport/MiniatureRailway.cpp b/src/openrct2/ride/transport/MiniatureRailway.cpp index f0b3a8d829..7a34f54d73 100644 --- a/src/openrct2/ride/transport/MiniatureRailway.cpp +++ b/src/openrct2/ride/transport/MiniatureRailway.cpp @@ -927,7 +927,7 @@ static void paint_miniature_railway_track_right_quarter_turn_5_tiles( session, right_quarter_turn_5_supports_type[direction][trackSequence], 0, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); - if (isSupported == false || (trackSequence == 3 && direction == 2)) + if (!isSupported || (trackSequence == 3 && direction == 2)) { track_paint_util_right_quarter_turn_5_tiles_paint( session, 2, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], @@ -1063,7 +1063,7 @@ static void paint_miniature_railway_track_s_bend_left( LocationXY16 offset = offsetList[trackSequence]; LocationXY16 bounds = boundsList[trackSequence]; - if (isSupported == false) + if (!isSupported) { sub_98197C_rotated( session, direction, imageId, (int8_t)offset.x, (int8_t)offset.y, bounds.x, bounds.y, 2, height, offset.x, offset.y, @@ -1163,7 +1163,7 @@ static void paint_miniature_railway_track_s_bend_right( | session->TrackColours[SCHEME_TRACK]; LocationXY16 offset = offsetList[trackSequence]; LocationXY16 bounds = boundsList[trackSequence]; - if (isSupported == false) + if (!isSupported) { sub_98197C_rotated( session, direction, imageId, (int8_t)offset.x, (int8_t)offset.y, bounds.x, bounds.y, 2, height, offset.x, offset.y, @@ -1274,7 +1274,7 @@ static void paint_miniature_railway_track_right_quarter_turn_3_tiles( isSupported = wooden_a_supports_paint_setup( session, supportType[direction], 0, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); } - if (isSupported == false) + if (!isSupported) { track_paint_util_right_quarter_turn_3_tiles_paint( session, 3, height, direction, trackSequence, session->TrackColours[SCHEME_TRACK], @@ -1429,7 +1429,7 @@ static void paint_miniature_railway_track_left_eighth_to_diag( session, supportType[direction][trackSequence], 0, height, session->TrackColours[SCHEME_SUPPORTS], nullptr); } uint32_t imageId; - if (isSupported == false) + if (!isSupported) { int8_t index = paint_miniature_railway_eighth_to_diag_index[trackSequence]; if (index >= 0) @@ -1566,7 +1566,7 @@ static void paint_miniature_railway_track_right_eighth_to_diag( } uint32_t imageId; - if (isSupported == false) + if (!isSupported) { int8_t index = paint_miniature_railway_eighth_to_diag_index[trackSequence]; if (index >= 0) diff --git a/src/openrct2/util/SawyerCoding.cpp b/src/openrct2/util/SawyerCoding.cpp index 5af5b86702..c5c3a408d0 100644 --- a/src/openrct2/util/SawyerCoding.cpp +++ b/src/openrct2/util/SawyerCoding.cpp @@ -44,7 +44,7 @@ size_t sawyercoding_write_chunk_buffer(uint8_t* dst_file, const uint8_t* buffer, { uint8_t *encode_buffer, *encode_buffer2; - if (gUseRLE == false) + if (!gUseRLE) { if (chunkHeader.encoding == CHUNK_ENCODING_RLE || chunkHeader.encoding == CHUNK_ENCODING_RLECOMPRESSED) { diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index af42fc01d4..f0f3aa0ce6 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -214,7 +214,7 @@ void fix_duplicated_banners() log_error("Failed to create new banner."); continue; } - Guard::Assert(activeBanners[newBannerIndex] == false); + Guard::Assert(!activeBanners[newBannerIndex]); // Copy over the original banner, but update the location rct_banner& newBanner = gBanners[newBannerIndex]; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index f9ce97242f..e612c344a5 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -733,12 +733,9 @@ int32_t map_height_from_slope(const CoordsXY coords, int32_t slope, bool isSlope bool map_is_location_valid(const CoordsXY coords) { - if (coords.x < (MAXIMUM_MAP_SIZE_TECHNICAL * 32) && coords.x >= 0 && coords.y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32) - && coords.y >= 0) - { - return true; - } - return false; + const bool is_x_valid = coords.x < (MAXIMUM_MAP_SIZE_TECHNICAL * 32) && coords.x >= 0; + const bool is_y_valid = coords.y < (MAXIMUM_MAP_SIZE_TECHNICAL * 32) && coords.y >= 0; + return is_x_valid && is_y_valid; } bool map_is_edge(const CoordsXY coords) @@ -1904,7 +1901,7 @@ EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE) continue; - if ((ghost == false) && (tileElement->IsGhost())) + if (!ghost && tileElement->IsGhost()) continue; return tileElement->AsEntrance(); @@ -1929,7 +1926,7 @@ EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE) continue; - if ((ghost == false) && (tileElement->IsGhost())) + if (!ghost && tileElement->IsGhost()) continue; return tileElement->AsEntrance(); @@ -1954,7 +1951,7 @@ EntranceElement* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, b if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_EXIT) continue; - if ((ghost == false) && (tileElement->IsGhost())) + if (!ghost && tileElement->IsGhost()) continue; return tileElement->AsEntrance(); diff --git a/src/openrct2/world/Sprite.cpp b/src/openrct2/world/Sprite.cpp index 83be386cdf..319cd61b43 100644 --- a/src/openrct2/world/Sprite.cpp +++ b/src/openrct2/world/Sprite.cpp @@ -715,10 +715,7 @@ static bool litter_can_be_at(int32_t x, int32_t y, int32_t z) if (pathZ < z || pathZ >= z + 32) continue; - if (tile_element_is_underground(tileElement)) - return false; - - return true; + return !tile_element_is_underground(tileElement); } while (!(tileElement++)->IsLastForTile()); return false; }