From 2779e82cede7f6781ec91b2ed53d05d07ef21256 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 27 May 2023 14:24:56 +0200 Subject: [PATCH] Return a full error message when the object cannot be found --- src/openrct2/actions/BannerPlaceAction.cpp | 6 ++++-- src/openrct2/actions/FootpathAdditionPlaceAction.cpp | 6 ++++-- src/openrct2/actions/LargeSceneryPlaceAction.cpp | 6 ++++-- src/openrct2/actions/LargeSceneryRemoveAction.cpp | 2 +- src/openrct2/actions/RideCreateAction.cpp | 3 ++- src/openrct2/actions/SmallSceneryPlaceAction.cpp | 6 ++++-- src/openrct2/actions/SurfaceSetStyleAction.cpp | 6 ++++-- src/openrct2/actions/TrackPlaceAction.cpp | 4 ++-- src/openrct2/actions/WallPlaceAction.cpp | 4 ++-- 9 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/openrct2/actions/BannerPlaceAction.cpp b/src/openrct2/actions/BannerPlaceAction.cpp index d0d7a8d53a..f81d598993 100644 --- a/src/openrct2/actions/BannerPlaceAction.cpp +++ b/src/openrct2/actions/BannerPlaceAction.cpp @@ -99,7 +99,8 @@ GameActions::Result BannerPlaceAction::Query() const if (bannerEntry == nullptr) { LOG_ERROR("Invalid banner object type. bannerType = ", _bannerType); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } res.Cost = bannerEntry->price; @@ -126,7 +127,8 @@ GameActions::Result BannerPlaceAction::Execute() const if (bannerEntry == nullptr) { LOG_ERROR("Invalid banner object type. bannerType = ", _bannerType); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } auto banner = CreateBanner(); diff --git a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp b/src/openrct2/actions/FootpathAdditionPlaceAction.cpp index fc3f78000a..1664456bf0 100644 --- a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp +++ b/src/openrct2/actions/FootpathAdditionPlaceAction.cpp @@ -97,7 +97,8 @@ GameActions::Result FootpathAdditionPlaceAction::Query() const auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry(_entryIndex); if (pathAdditionEntry == nullptr) { - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } uint16_t sceneryFlags = pathAdditionEntry->flags; @@ -164,7 +165,8 @@ GameActions::Result FootpathAdditionPlaceAction::Execute() const auto* pathAdditionEntry = OpenRCT2::ObjectManager::GetObjectEntry(_entryIndex); if (pathAdditionEntry == nullptr) { - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } res.Cost = pathAdditionEntry->price; diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp index f20732993d..c196d2e397 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp @@ -85,7 +85,8 @@ GameActions::Result LargeSceneryPlaceAction::Query() const if (sceneryEntry == nullptr) { LOG_ERROR("Invalid game command for scenery placement, sceneryType = %u", _sceneryType); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } uint32_t totalNumTiles = GetTotalNumTiles(sceneryEntry->tiles); @@ -197,7 +198,8 @@ GameActions::Result LargeSceneryPlaceAction::Execute() const if (sceneryEntry == nullptr) { LOG_ERROR("Invalid game command for scenery placement, sceneryType = %u", _sceneryType); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } if (sceneryEntry->tiles == nullptr) diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.cpp b/src/openrct2/actions/LargeSceneryRemoveAction.cpp index 3d0edbe080..1e230e6a7b 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.cpp +++ b/src/openrct2/actions/LargeSceneryRemoveAction.cpp @@ -72,7 +72,7 @@ GameActions::Result LargeSceneryRemoveAction::Query() const auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); // If we have a bugged scenery entry, do not touch the tile element. if (sceneryEntry == nullptr) - return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REMOVE_THIS, STR_NONE); + return GameActions::Result(GameActions::Status::Unknown, STR_CANT_REMOVE_THIS, STR_UNKNOWN_OBJECT_TYPE); auto rotatedOffsets = CoordsXYZ{ CoordsXY{ sceneryEntry->tiles[_tileIndex].x_offset, sceneryEntry->tiles[_tileIndex].y_offset }.Rotate(_loc.direction), diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/RideCreateAction.cpp index eff9a6507a..b3ec046f05 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/RideCreateAction.cpp @@ -100,7 +100,8 @@ GameActions::Result RideCreateAction::Query() const const auto* rideEntry = GetRideEntryByIndex(rideEntryIndex); if (rideEntry == nullptr) { - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_CREATE_NEW_RIDE_ATTRACTION, STR_UNKNOWN_OBJECT_TYPE); } const auto* presetList = rideEntry->vehicle_preset_list; diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp index fc41ed17f0..3f084cfdd0 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp @@ -116,7 +116,8 @@ GameActions::Result SmallSceneryPlaceAction::Query() const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry(_sceneryType); if (sceneryEntry == nullptr) { - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } auto quadrant = _quadrant; @@ -308,7 +309,8 @@ GameActions::Result SmallSceneryPlaceAction::Execute() const auto* sceneryEntry = OpenRCT2::ObjectManager::GetObjectEntry(_sceneryType); if (sceneryEntry == nullptr) { - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_POSITION_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } auto quadrant = _quadrant; diff --git a/src/openrct2/actions/SurfaceSetStyleAction.cpp b/src/openrct2/actions/SurfaceSetStyleAction.cpp index e71dfbc02c..217667c29e 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.cpp +++ b/src/openrct2/actions/SurfaceSetStyleAction.cpp @@ -56,7 +56,8 @@ GameActions::Result SurfaceSetStyleAction::Query() const if (surfaceObj == nullptr) { LOG_ERROR("Invalid surface style."); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE, STR_UNKNOWN_OBJECT_TYPE); } } @@ -67,7 +68,8 @@ GameActions::Result SurfaceSetStyleAction::Query() const if (edgeObj == nullptr) { LOG_ERROR("Invalid edge style."); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE, STR_NONE); + return GameActions::Result( + GameActions::Status::InvalidParameters, STR_CANT_CHANGE_LAND_TYPE, STR_UNKNOWN_OBJECT_TYPE); } } diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index f333d66724..c9960a7f7b 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -79,7 +79,7 @@ GameActions::Result TrackPlaceAction::Query() const { LOG_WARNING("Invalid ride subtype for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); return GameActions::Result( - GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); + GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } if (!DirectionValid(_origin.direction)) @@ -422,7 +422,7 @@ GameActions::Result TrackPlaceAction::Execute() const { LOG_WARNING("Invalid ride subtype for track placement, rideIndex = %d", _rideIndex.ToUnderlying()); return GameActions::Result( - GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NONE); + GameActions::Status::InvalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } auto res = GameActions::Result(); diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/WallPlaceAction.cpp index 4dd23dcb79..6e59bc6155 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/WallPlaceAction.cpp @@ -222,7 +222,7 @@ GameActions::Result WallPlaceAction::Query() const if (wallEntry == nullptr) { LOG_ERROR("Wall Type not found %d", _wallType); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_NONE); + return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } if (wallEntry->scrolling_mode != SCROLLING_MODE_NONE) @@ -312,7 +312,7 @@ GameActions::Result WallPlaceAction::Execute() const if (wallEntry == nullptr) { LOG_ERROR("Wall Type not found %d", _wallType); - return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_NONE); + return GameActions::Result(GameActions::Status::InvalidParameters, STR_CANT_BUILD_THIS_HERE, STR_UNKNOWN_OBJECT_TYPE); } uint8_t clearanceHeight = targetHeight / COORDS_Z_STEP;