1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Fix #10932: Extensive warnings in console when placing an entrance or exit (#13114)

Co-authored-by: Simon Jarrett <mwnciau@users.noreply.github.com>
This commit is contained in:
Simon J
2022-11-20 12:03:08 +00:00
committed by GitHub
parent 5396368274
commit f4e0480cba

View File

@@ -48,13 +48,8 @@ void RideEntranceExitRemoveAction::Serialise(DataSerialiser& stream)
static TileElement* FindEntranceElement(
const CoordsXY& loc, RideId rideIndex, StationIndex stationNum, int32_t entranceType, uint32_t flags)
{
const bool isGhost = flags & GAME_COMMAND_FLAG_GHOST;
for (auto* entranceElement : TileElementsView<EntranceElement>(loc))
{
// If we are removing ghost elements
if (isGhost && entranceElement->IsGhost() == false)
continue;
if (entranceElement->GetRideIndex() != rideIndex)
continue;
@@ -96,7 +91,12 @@ GameActions::Result RideEntranceExitRemoveAction::Query() const
auto* entranceElement = FindEntranceElement(
_loc, _rideIndex, _stationNum, _isExit ? ENTRANCE_TYPE_RIDE_EXIT : ENTRANCE_TYPE_RIDE_ENTRANCE, GetFlags());
if (entranceElement == nullptr)
// If we are trying to remove a ghost and the element we found is real, return an error, but don't log a warning
if (entranceElement != nullptr && (GetFlags() & GAME_COMMAND_FLAG_GHOST) && !(entranceElement->IsGhost()))
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE);
}
else if (entranceElement == nullptr)
{
log_warning(
"Track Element not found. x = %d, y = %d, ride = %u, station = %u", _loc.x, _loc.y, _rideIndex.ToUnderlying(),
@@ -127,7 +127,12 @@ GameActions::Result RideEntranceExitRemoveAction::Execute() const
auto* entranceElement = FindEntranceElement(
_loc, _rideIndex, _stationNum, _isExit ? ENTRANCE_TYPE_RIDE_EXIT : ENTRANCE_TYPE_RIDE_ENTRANCE, GetFlags());
if (entranceElement == nullptr)
// If we are trying to remove a ghost and the element we found is real, return an error, but don't log a warning
if (entranceElement != nullptr && isGhost && !(entranceElement->IsGhost()))
{
return GameActions::Result(GameActions::Status::InvalidParameters, STR_NONE, STR_NONE);
}
else if (entranceElement == nullptr)
{
log_warning(
"Track Element not found. x = %d, y = %d, ride = %u, station = %d", _loc.x, _loc.y, _rideIndex.ToUnderlying(),