From 53c22c9b4bae8b8ed907271dbbe3944f9a8d4d7e Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Fri, 24 Sep 2021 20:05:50 +0200 Subject: [PATCH] Check for nullptr explicitly (#15458) --- src/openrct2/Editor.cpp | 10 ++-- src/openrct2/GameStateSnapshots.cpp | 2 +- src/openrct2/ReplayManager.cpp | 4 +- src/openrct2/actions/GameAction.cpp | 2 +- src/openrct2/actions/PeepPickupAction.cpp | 6 +-- src/openrct2/actions/SignSetStyleAction.cpp | 2 +- src/openrct2/audio/Audio.cpp | 2 +- src/openrct2/drawing/LightFX.cpp | 4 +- src/openrct2/drawing/TTFSDLPort.cpp | 10 ++-- src/openrct2/interface/Viewport.cpp | 4 +- src/openrct2/interface/Window.cpp | 2 +- src/openrct2/network/NetworkBase.cpp | 48 +++++++++---------- src/openrct2/paint/Paint.cpp | 4 +- .../paint/tile_element/Paint.Path.cpp | 4 +- src/openrct2/peep/Guest.cpp | 2 +- src/openrct2/peep/GuestPathfinding.cpp | 2 +- src/openrct2/peep/Peep.cpp | 6 +-- src/openrct2/rct2/S6Exporter.cpp | 4 +- src/openrct2/ride/TrainManager.cpp | 2 +- src/openrct2/ride/Vehicle.cpp | 8 ++-- .../ride/transport/MiniatureRailway.cpp | 4 +- src/openrct2/world/Map.cpp | 4 +- src/openrct2/world/MapHelpers.cpp | 2 +- src/openrct2/world/TileInspector.cpp | 2 +- 24 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 37ec3865ee..cbc88b6d31 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -377,12 +377,12 @@ namespace Editor switch (gEditorStep) { case EditorStep::ObjectSelection: - if (window_find_by_class(WC_EDITOR_OBJECT_SELECTION)) + if (window_find_by_class(WC_EDITOR_OBJECT_SELECTION) != nullptr) { return; } - if (window_find_by_class(WC_INSTALL_TRACK)) + if (window_find_by_class(WC_INSTALL_TRACK) != nullptr) { return; } @@ -395,7 +395,7 @@ namespace Editor context_open_window(WC_EDITOR_OBJECT_SELECTION); break; case EditorStep::InventionsListSetUp: - if (window_find_by_class(WC_EDITOR_INVENTION_LIST)) + if (window_find_by_class(WC_EDITOR_INVENTION_LIST) != nullptr) { return; } @@ -403,7 +403,7 @@ namespace Editor context_open_window(WC_EDITOR_INVENTION_LIST); break; case EditorStep::OptionsSelection: - if (window_find_by_class(WC_EDITOR_SCENARIO_OPTIONS)) + if (window_find_by_class(WC_EDITOR_SCENARIO_OPTIONS) != nullptr) { return; } @@ -411,7 +411,7 @@ namespace Editor context_open_window(WC_EDITOR_SCENARIO_OPTIONS); break; case EditorStep::ObjectiveSelection: - if (window_find_by_class(WC_EDITOR_OBJECTIVE_OPTIONS)) + if (window_find_by_class(WC_EDITOR_OBJECTIVE_OPTIONS) != nullptr) { return; } diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 0090e08e09..bde55168e2 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -745,7 +745,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots auto outputBuffer = GetCompareDataText(cmpData); FILE* fp = fopen(fileName.c_str(), "wt"); - if (!fp) + if (fp == nullptr) return false; fputs(outputBuffer.c_str(), fp); diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index ad17d560f7..d2090aa077 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -321,7 +321,7 @@ namespace OpenRCT2 const std::string& outFile = _currentRecording->filePath; FILE* fp = fopen(outFile.c_str(), "wb"); - if (fp) + if (fp != nullptr) { const auto& fileStream = fileSerialiser.GetStream(); fwrite(fileStream.GetData(), 1, fileStream.GetLength(), fp); @@ -554,7 +554,7 @@ namespace OpenRCT2 bool ReadReplayFromFile(const std::string& file, MemoryStream& stream) { FILE* fp = fopen(file.c_str(), "rb"); - if (!fp) + if (fp == nullptr) return false; char buffer[128]; diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index bc63e30825..0856d018a3 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -502,7 +502,7 @@ namespace GameActions bool commandExecutes = (flags & GAME_COMMAND_FLAG_GHOST) == 0 && (flags & GAME_COMMAND_FLAG_NO_SPEND) == 0; bool recordAction = false; - if (replayManager) + if (replayManager != nullptr) { if (replayManager->IsRecording() && commandExecutes) recordAction = true; diff --git a/src/openrct2/actions/PeepPickupAction.cpp b/src/openrct2/actions/PeepPickupAction.cpp index db89689ddd..ef29ca21e8 100644 --- a/src/openrct2/actions/PeepPickupAction.cpp +++ b/src/openrct2/actions/PeepPickupAction.cpp @@ -67,7 +67,7 @@ GameActions::Result::Ptr PeepPickupAction::Query() const return MakeResult(GameActions::Status::Disallowed, STR_ERR_CANT_PLACE_PERSON_HERE); } Peep* existing = network_get_pickup_peep(_owner); - if (existing) + if (existing != nullptr) { // already picking up a peep PeepPickupAction existingPickupAction{ @@ -122,7 +122,7 @@ GameActions::Result::Ptr PeepPickupAction::Execute() const res->Position = { peep->x, peep->y, peep->z }; Peep* existing = network_get_pickup_peep(_owner); - if (existing) + if (existing != nullptr) { // already picking up a peep PeepPickupAction existingPickupAction{ @@ -151,7 +151,7 @@ GameActions::Result::Ptr PeepPickupAction::Execute() const res->Position = { peep->x, peep->y, peep->z }; Peep* const pickedUpPeep = network_get_pickup_peep(_owner); - if (pickedUpPeep) + if (pickedUpPeep != nullptr) { pickedUpPeep->PickupAbort(_loc.x); } diff --git a/src/openrct2/actions/SignSetStyleAction.cpp b/src/openrct2/actions/SignSetStyleAction.cpp index e38319c71d..60599db6aa 100644 --- a/src/openrct2/actions/SignSetStyleAction.cpp +++ b/src/openrct2/actions/SignSetStyleAction.cpp @@ -64,7 +64,7 @@ GameActions::Result::Ptr SignSetStyleAction::Query() const { WallElement* wallElement = banner_get_scrolling_wall_tile_element(_bannerIndex); - if (!wallElement) + if (wallElement == nullptr) { log_warning("Invalid game command for setting sign style, banner id '%d' not found", _bannerIndex); return MakeResult(GameActions::Status::InvalidParameters, STR_CANT_REPAINT_THIS); diff --git a/src/openrct2/audio/Audio.cpp b/src/openrct2/audio/Audio.cpp index 454a81dd1f..6fb3c4f673 100644 --- a/src/openrct2/audio/Audio.cpp +++ b/src/openrct2/audio/Audio.cpp @@ -207,7 +207,7 @@ namespace OpenRCT2::Audio params.pan = 0; auto element = map_get_surface_element_at(location); - if (element && (element->GetBaseZ()) - 5 > location.z) + if (element != nullptr && (element->GetBaseZ()) - 5 > location.z) { volumeDown = 10; } diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index 837742d48b..0b8f31751b 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -331,7 +331,7 @@ void lightfx_prepare_light_list() int32_t minDist = 0; int32_t baseHeight = (-999) * COORDS_Z_STEP; - if (interactionType != ViewportInteractionItem::Entity && tileElement) + if (interactionType != ViewportInteractionItem::Entity && tileElement != nullptr) { baseHeight = tileElement->GetBaseZ(); } @@ -440,7 +440,7 @@ void lightfx_swap_buffers() void lightfx_update_viewport_settings() { rct_window* mainWindow = window_get_main(); - if (mainWindow) + if (mainWindow != nullptr) { rct_viewport* viewport = window_get_viewport(mainWindow); _current_view_x_back = viewport->viewPos.x; diff --git a/src/openrct2/drawing/TTFSDLPort.cpp b/src/openrct2/drawing/TTFSDLPort.cpp index 030bb3aeef..0df6e8697c 100644 --- a/src/openrct2/drawing/TTFSDLPort.cpp +++ b/src/openrct2/drawing/TTFSDLPort.cpp @@ -550,12 +550,12 @@ static void Flush_Glyph(c_glyph* glyph) { glyph->stored = 0; glyph->index = 0; - if (glyph->bitmap.buffer) + if (glyph->bitmap.buffer != nullptr) { free(glyph->bitmap.buffer); glyph->bitmap.buffer = 0; } - if (glyph->pixmap.buffer) + if (glyph->pixmap.buffer != nullptr) { free(glyph->pixmap.buffer); glyph->pixmap.buffer = 0; @@ -754,7 +754,7 @@ static FT_Error Load_Glyph(TTF_Font* font, uint16_t ch, c_glyph* cached, int wan if (dst->rows != 0) { dst->buffer = static_cast(malloc(dst->pitch * dst->rows)); - if (!dst->buffer) + if (dst->buffer == nullptr) { return FT_Err_Out_Of_Memory; } @@ -1236,12 +1236,12 @@ int TTF_SizeUTF8(TTF_Font* font, const char* text, int* w, int* h) } /* Fill the bounds rectangle */ - if (w) + if (w != nullptr) { /* Add outline extra width */ *w = (maxx - minx) + outline_delta; } - if (h) + if (h != nullptr) { /* Some fonts descend below font height (FletcherGothicFLF) */ /* Add outline extra height */ diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 28cab048bd..a3d53b70d7 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -559,7 +559,7 @@ void viewport_update_position(rct_window* window) window_event_resize_call(window); rct_viewport* viewport = window->viewport; - if (!viewport) + if (viewport == nullptr) return; if (window->viewport_smart_follow_sprite != SPRITE_INDEX_NULL) @@ -656,7 +656,7 @@ void viewport_update_position(rct_window* window) void viewport_update_sprite_follow(rct_window* window) { - if (window->viewport_target_sprite != SPRITE_INDEX_NULL && window->viewport) + if (window->viewport_target_sprite != SPRITE_INDEX_NULL && window->viewport != nullptr) { auto* sprite = GetEntity(window->viewport_target_sprite); if (sprite == nullptr) diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 42bf213b8a..5bd3668607 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -806,7 +806,7 @@ void window_scroll_to_location(rct_window* w, const CoordsXYZ& coords) { assert(w != nullptr); window_unfollow_sprite(w); - if (w->viewport) + if (w->viewport != nullptr) { int16_t height = tile_element_height(coords); if (coords.z < height - 16) diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 137ef0c030..ee2555fdc6 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -700,7 +700,7 @@ const char* NetworkBase::FormatChat(NetworkPlayer* fromplayer, const char* text) static std::string formatted; formatted.clear(); formatted += "{OUTLINE}"; - if (fromplayer) + if (fromplayer != nullptr) { formatted += "{BABYBLUE}"; formatted += fromplayer->Name; @@ -934,7 +934,7 @@ uint8_t NetworkBase::GetDefaultGroup() void NetworkBase::SetDefaultGroup(uint8_t id) { - if (GetGroupByID(id)) + if (GetGroupByID(id) != nullptr) { default_group = id; } @@ -1336,7 +1336,7 @@ NetworkStats_t NetworkBase::GetStats() const void NetworkBase::Server_Send_AUTH(NetworkConnection& connection) { uint8_t new_playerid = 0; - if (connection.Player) + if (connection.Player != nullptr) { new_playerid = connection.Player->Id; } @@ -1356,7 +1356,7 @@ void NetworkBase::Server_Send_AUTH(NetworkConnection& connection) void NetworkBase::Server_Send_MAP(NetworkConnection* connection) { std::vector objects; - if (connection) + if (connection != nullptr) { objects = connection->RequestedObjects; } @@ -1372,7 +1372,7 @@ void NetworkBase::Server_Send_MAP(NetworkConnection* connection) auto header = save_for_network(objects); if (header.empty()) { - if (connection) + if (connection != nullptr) { connection->SetLastDisconnectReason(STR_MULTIPLAYER_CONNECTION_CLOSED); connection->Disconnect(); @@ -1386,7 +1386,7 @@ void NetworkBase::Server_Send_MAP(NetworkConnection* connection) NetworkPacket packet(NetworkCommand::Map); packet << static_cast(header.size()) << static_cast(i); packet.Write(&header[i], datasize); - if (connection) + if (connection != nullptr) { connection->QueuePacket(std::move(packet)); } @@ -1844,7 +1844,7 @@ void NetworkBase::ProcessPlayerList() { // Add new player. player = AddPlayer("", ""); - if (player) + if (player != nullptr) { *player = pendingPlayer; if (player->Flags & NETWORK_PLAYER_FLAG_ISSERVER) @@ -1965,7 +1965,7 @@ void NetworkBase::ServerClientDisconnected(std::unique_ptr& c connection_player->Name.c_str(), connection->GetLastDisconnectReason(), }; - if (has_disconnected_args[1]) + if (has_disconnected_args[1] != nullptr) { format_string(text, 256, STR_MULTIPLAYER_PLAYER_HAS_DISCONNECTED_WITH_REASON, has_disconnected_args); } @@ -1976,7 +1976,7 @@ void NetworkBase::ServerClientDisconnected(std::unique_ptr& c chat_history_add(text); Peep* pickup_peep = network_get_pickup_peep(connection_player->Id); - if (pickup_peep) + if (pickup_peep != nullptr) { PeepPickupAction pickupAction{ PeepPickupType::Cancel, pickup_peep->sprite_index, @@ -2181,7 +2181,7 @@ void NetworkBase::Server_Handle_REQUEST_GAMESTATE(NetworkConnection& connection, IGameStateSnapshots* snapshots = GetContext().GetGameStateSnapshots(); const GameStateSnapshot_t* snapshot = snapshots->GetLinkedSnapshot(tick); - if (snapshot) + if (snapshot != nullptr) { MemoryStream snapshotMemory; DataSerialiser ds(true, snapshotMemory); @@ -2426,7 +2426,7 @@ void NetworkBase::Client_Handle_GAMESTATE(NetworkConnection& connection, Network snapshots->SerialiseSnapshot(serverSnapshot, ds); const GameStateSnapshot_t* desyncSnapshot = snapshots->GetLinkedSnapshot(tick); - if (desyncSnapshot) + if (desyncSnapshot != nullptr) { GameStateCompareData_t cmpData = snapshots->Compare(serverSnapshot, *desyncSnapshot); @@ -2468,7 +2468,7 @@ void NetworkBase::Server_Handle_MAPREQUEST(NetworkConnection& connection, Networ connection.SetLastDisconnectReason(STR_MULTIPLAYER_CLIENT_INVALID_REQUEST); connection.Disconnect(); std::string playerName = "(unknown)"; - if (connection.Player) + if (connection.Player != nullptr) { playerName = connection.Player->Name; } @@ -2880,10 +2880,10 @@ void NetworkBase::Server_Handle_CHAT(NetworkConnection& connection, NetworkPacke if (szText.empty()) return; - if (connection.Player) + if (connection.Player != nullptr) { NetworkGroup* group = GetGroupByID(connection.Player->Group); - if (!group || !group->CanPerformCommand(GameCommand::Chat)) + if (group == nullptr || !group->CanPerformCommand(GameCommand::Chat)) { return; } @@ -3084,7 +3084,7 @@ void NetworkBase::Server_Handle_PING(NetworkConnection& connection, [[maybe_unus { ping = 0; } - if (connection.Player) + if (connection.Player != nullptr) { connection.Player->Ping = ping; window_invalidate_by_number(WC_PLAYER, connection.Player->Id); @@ -3101,7 +3101,7 @@ void NetworkBase::Client_Handle_PINGLIST([[maybe_unused]] NetworkConnection& con uint16_t ping; packet >> id >> ping; NetworkPlayer* player = GetPlayerByID(id); - if (player) + if (player != nullptr) { player->Ping = ping; } @@ -3510,7 +3510,7 @@ GameActions::Result::Ptr network_set_player_group( return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS); } - if (!network.GetGroupByID(groupId)) + if (network.GetGroupByID(groupId) == nullptr) { return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_DO_THIS); } @@ -3521,7 +3521,7 @@ GameActions::Result::Ptr network_set_player_group( GameActions::Status::InvalidParameters, STR_CANT_CHANGE_GROUP_THAT_THE_HOST_BELONGS_TO); } - if (groupId == 0 && fromgroup && fromgroup->Id != 0) + if (groupId == 0 && fromgroup != nullptr && fromgroup->Id != 0) { return std::make_unique(GameActions::Status::InvalidParameters, STR_CANT_SET_TO_THIS_GROUP); } @@ -3701,7 +3701,7 @@ GameActions::Result::Ptr network_kick_player(NetworkPlayerId_t playerId, bool is return std::make_unique(GameActions::Status::Unknown, STR_NONE); } - if (player && player->Flags & NETWORK_PLAYER_FLAG_ISSERVER) + if (player->Flags & NETWORK_PLAYER_FLAG_ISSERVER) { return std::make_unique(GameActions::Status::Disallowed, STR_CANT_KICK_THE_HOST); } @@ -3768,7 +3768,7 @@ void network_set_pickup_peep(uint8_t playerid, Peep* peep) else { NetworkPlayer* player = network.GetPlayerByID(playerid); - if (player) + if (player != nullptr) { player->PickupPeep = peep; } @@ -3784,7 +3784,7 @@ Peep* network_get_pickup_peep(uint8_t playerid) } NetworkPlayer* player = network.GetPlayerByID(playerid); - if (player) + if (player != nullptr) { return player->PickupPeep; } @@ -3801,7 +3801,7 @@ void network_set_pickup_peep_old_x(uint8_t playerid, int32_t x) else { NetworkPlayer* player = network.GetPlayerByID(playerid); - if (player) + if (player != nullptr) { player->PickupPeepOldX = x; } @@ -3817,7 +3817,7 @@ int32_t network_get_pickup_peep_old_x(uint8_t playerid) } NetworkPlayer* player = network.GetPlayerByID(playerid); - if (player) + if (player != nullptr) { return player->PickupPeepOldX; } @@ -3828,7 +3828,7 @@ int32_t network_get_current_player_group_index() { auto& network = OpenRCT2::GetContext()->GetNetwork(); NetworkPlayer* player = network.GetPlayerByID(network.GetPlayerID()); - if (player) + if (player != nullptr) { return network_get_group_index(player->Group); } diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 862a5a8b10..aab007274d 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -525,7 +525,7 @@ void PaintDrawStructs(paint_session* session) { paint_struct* ps = &session->PaintHead; - for (ps = ps->next_quadrant_ps; ps;) + for (ps = ps->next_quadrant_ps; ps != nullptr;) { PaintDrawStruct(session, ps); @@ -541,7 +541,7 @@ void PaintDrawStructs(paint_session* session) static void PaintAttachedPS(rct_drawpixelinfo* dpi, paint_struct* ps, uint32_t viewFlags) { attached_paint_struct* attached_ps = ps->attached_ps; - for (; attached_ps; attached_ps = attached_ps->next) + for (; attached_ps != nullptr; attached_ps = attached_ps->next) { auto screenCoords = ScreenCoordsXY{ attached_ps->x + ps->x, attached_ps->y + ps->y }; diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index c11d0991e3..24625f0bc0 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -1061,7 +1061,7 @@ void path_paint_box_support( // If we are on the same tile as a straight track, add the offset 2 so we // can clip above gravel part of the track sprite - if (session->TrackElementOnSameHeight) + if (session->TrackElementOnSameHeight != nullptr) { if (session->TrackElementOnSameHeight->AsTrack()->GetTrackType() == TrackElemType::Flat) { @@ -1199,7 +1199,7 @@ void path_paint_pole_support( // If we are on the same tile as a straight track, add the offset 2 so we // can clip above gravel part of the track sprite - if (session->TrackElementOnSameHeight) + if (session->TrackElementOnSameHeight != nullptr) { if (session->TrackElementOnSameHeight->AsTrack()->GetTrackType() == TrackElemType::Flat) { diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 9895036e18..33cea3719d 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -1407,7 +1407,7 @@ void Guest::CheckCantFindRide() GuestHeadingToRideId = RIDE_ID_NULL; rct_window* w = window_find_by_number(WC_PEEP, sprite_index); - if (w) + if (w != nullptr) { window_event_invalidate_call(w); } diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 2f27e93843..8eb9dbced2 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -88,7 +88,7 @@ static TileElement* get_banner_on_path(TileElement* path_element) if (bannerElement->IsLastForTile()) return nullptr; - } while (bannerElement++); + } while (bannerElement++ != nullptr); return nullptr; } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 4a36e8622b..288b096b81 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -573,12 +573,12 @@ std::unique_ptr Peep::Place(const TileCoordsXYZ& location, { auto* pathElement = map_get_path_element_at(location); TileElement* tileElement = reinterpret_cast(pathElement); - if (!pathElement) + if (pathElement == nullptr) { tileElement = reinterpret_cast(map_get_surface_element_at(location.ToCoordsXYZ())); } - if (!tileElement) + if (tileElement == nullptr) return std::make_unique(GameActions::Status::InvalidParameters, STR_ERR_CANT_PLACE_PERSON_HERE); // Set the coordinate of destination to be exactly @@ -2056,7 +2056,7 @@ static void peep_interact_with_path(Peep* peep, const CoordsXYE& coords) auto* guest = peep->As(); if (map_is_location_owned({ coords, z })) { - if (guest && guest->OutsideOfPark) + if (guest != nullptr && guest->OutsideOfPark) { peep_return_to_centre_of_tile(guest); return; diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 7ef6c5f03e..7015d66994 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1148,7 +1148,7 @@ constexpr RCT12EntityLinkListOffset GetRCT2LinkListOffset(const EntityBase* src) case EntityType::Vehicle: { auto veh = src->As(); - if (veh && veh->IsHead()) + if (veh != nullptr && veh->IsHead()) { output = RCT12EntityLinkListOffset::TrainHead; } @@ -1863,7 +1863,7 @@ void S6Exporter::ExportTileElement(RCT12TileElement* dst, const TileElement* src // This has to be done last, since the maze entry shares fields with the colour and sequence fields. auto ride = get_ride(static_cast(dst2->GetRideIndex())); - if (ride) + if (ride != nullptr) { if (ride->type == RIDE_TYPE_MAZE) { diff --git a/src/openrct2/ride/TrainManager.cpp b/src/openrct2/ride/TrainManager.cpp index 52b6e75028..eea7d347ef 100644 --- a/src/openrct2/ride/TrainManager.cpp +++ b/src/openrct2/ride/TrainManager.cpp @@ -22,7 +22,7 @@ namespace TrainManager while (iter != end && Entity == nullptr) { Entity = GetEntity(*iter++); - if (Entity && !Entity->IsHead()) + if (Entity != nullptr && !Entity->IsHead()) { Entity = nullptr; } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 44e8a8cfd7..014527677b 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -9802,7 +9802,7 @@ void Vehicle::UpdateCrossings() const frontVehicle->TrackLocation, frontVehicle->GetTrackType(), 0) }; int32_t curZ = frontVehicle->TrackLocation.z; - if (xyElement.element && status != Vehicle::Status::Arriving) + if (xyElement.element != nullptr && status != Vehicle::Status::Arriving) { int16_t autoReserveAhead = 4 + abs(velocity) / 150000; int16_t crossingBonus = 0; @@ -9822,7 +9822,7 @@ void Vehicle::UpdateCrossings() const // Many New Element parks have invisible rides hacked into the path. // Limit path blocking to rides actually supporting level crossings to prevent peeps getting stuck everywhere. - if (pathElement && curRide != nullptr + if (pathElement != nullptr && curRide != nullptr && GetRideTypeDescriptor(curRide->type).HasFlag(RIDE_TYPE_FLAG_SUPPORTS_LEVEL_CROSSINGS)) { if (!playedClaxon && !pathElement->IsBlockedByVehicle()) @@ -9873,7 +9873,7 @@ void Vehicle::UpdateCrossings() const map_get_track_element_at_of_type_seq(backVehicle->TrackLocation, backVehicle->GetTrackType(), 0) }; curZ = backVehicle->TrackLocation.z; - if (xyElement.element) + if (xyElement.element != nullptr) { uint8_t freeCount = travellingForwards ? 3 : 1; @@ -9890,7 +9890,7 @@ void Vehicle::UpdateCrossings() const } auto* pathElement = map_get_path_element_at(TileCoordsXYZ(CoordsXYZ{ xyElement, xyElement.element->GetBaseZ() })); - if (pathElement) + if (pathElement != nullptr) { pathElement->SetIsBlockedByVehicle(false); } diff --git a/src/openrct2/ride/transport/MiniatureRailway.cpp b/src/openrct2/ride/transport/MiniatureRailway.cpp index 3acb96aa18..613e90d8d5 100644 --- a/src/openrct2/ride/transport/MiniatureRailway.cpp +++ b/src/openrct2/ride/transport/MiniatureRailway.cpp @@ -558,7 +558,7 @@ static uint32_t miniature_railway_track_to_grooved(uint32_t imageId) static uint32_t miniature_railway_track_to_grooved_indent( uint32_t imageId, const TileElement* path, uint8_t direction, uint8_t rotation) { - if (!path) + if (path == nullptr) { return 0; } @@ -598,7 +598,7 @@ static void paint_miniature_railway_track_flat( bool paintAsGravel = false; bool paintGrooved = false; - if (session->PathElementOnSameHeight) + if (session->PathElementOnSameHeight != nullptr) { paintAsGravel = true; paintGrooved = true; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index cda70e0a21..7f9be950eb 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1691,7 +1691,7 @@ void map_extend_boundary_surface() existingTileElement = map_get_surface_element_at(TileCoordsXY{ x, y - 1 }.ToCoordsXY()); newTileElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY()); - if (existingTileElement && newTileElement) + if (existingTileElement != nullptr && newTileElement != nullptr) { map_extend_boundary_surface_extend_tile(*existingTileElement, *newTileElement); } @@ -1705,7 +1705,7 @@ void map_extend_boundary_surface() existingTileElement = map_get_surface_element_at(TileCoordsXY{ x - 1, y }.ToCoordsXY()); newTileElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY()); - if (existingTileElement && newTileElement) + if (existingTileElement != nullptr && newTileElement != nullptr) { map_extend_boundary_surface_extend_tile(*existingTileElement, *newTileElement); } diff --git a/src/openrct2/world/MapHelpers.cpp b/src/openrct2/world/MapHelpers.cpp index 0fc73a2221..b8857f6302 100644 --- a/src/openrct2/world/MapHelpers.cpp +++ b/src/openrct2/world/MapHelpers.cpp @@ -17,7 +17,7 @@ static uint8_t getBaseHeightOrZero(int32_t x, int32_t y) { auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY()); - return surfaceElement ? surfaceElement->base_height : 0; + return surfaceElement != nullptr ? surfaceElement->base_height : 0; } /** diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index e032676314..56c5613875 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -212,7 +212,7 @@ namespace OpenRCT2::TileInspector } auto largeScenery = tileElement->AsLargeScenery(); - if (largeScenery) + if (largeScenery != nullptr) { // Only delete the banner entry if there are no other parts of the large scenery to delete if (numLargeScenerySequences(loc, largeScenery) == 1)