Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placing track designs at locations blocked by anything results in wrong error message #15620

Closed
ZehMatt opened this issue Oct 20, 2021 · 6 comments · Fixed by #15816
Closed
Labels
bug Something went wrong.

Comments

@ZehMatt
Copy link
Member

ZehMatt commented Oct 20, 2021

Operating System

OpenRCT2 build

OpenRCT v0.3.4.1

Describe the issue

Instead of saying "Can't construct here, blocked by xyz" it always says "Land not owned".

Looks like it was introduced in 0.3.4(.1)

Area(s) with issue?

No response

Steps to reproduce

  1. Pick any prebuilt coaster.
  2. Place somewhere where it would normally say its blocked.

Attachments

openrct2_2021-10-20_21-57-579c7740a3c554466fa

@hjort96
Copy link
Contributor

hjort96 commented Oct 28, 2021

It used to say "Can't construct here, blocked by xyz"?
I've managed to make it not say "Land not owned by park!" when the land is owned by the park. The reason I'm asking is because I can't find an ID for a string that says "Can't construct here, blocked by xyz".

@Broxzier
Copy link
Member

@hjort96 Have a look at map_obstruction_set_error_text. Here the strings are getting formatted.

void map_obstruction_set_error_text(TileElement* tileElement, GameActions::Result& res)
{
Ride* ride;
res.ErrorMessage = STR_OBJECT_IN_THE_WAY;
switch (tileElement->GetType())
{
case TILE_ELEMENT_TYPE_SURFACE:
res.ErrorMessage = STR_RAISE_OR_LOWER_LAND_FIRST;
break;
case TILE_ELEMENT_TYPE_PATH:
res.ErrorMessage = STR_FOOTPATH_IN_THE_WAY;
break;
case TILE_ELEMENT_TYPE_TRACK:
ride = get_ride(tileElement->AsTrack()->GetRideIndex());
if (ride != nullptr)
{
res.ErrorMessage = STR_X_IN_THE_WAY;
Formatter ft(res.ErrorMessageArgs.data());
ride->FormatNameTo(ft);
}
break;
case TILE_ELEMENT_TYPE_SMALL_SCENERY:
{
auto* sceneryEntry = tileElement->AsSmallScenery()->GetEntry();
res.ErrorMessage = STR_X_IN_THE_WAY;
auto ft = Formatter(res.ErrorMessageArgs.data());
rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast<rct_string_id>(STR_EMPTY);
ft.Add<rct_string_id>(stringId);
break;
}
case TILE_ELEMENT_TYPE_ENTRANCE:
switch (tileElement->AsEntrance()->GetEntranceType())
{
case ENTRANCE_TYPE_RIDE_ENTRANCE:
res.ErrorMessage = STR_RIDE_ENTRANCE_IN_THE_WAY;
break;
case ENTRANCE_TYPE_RIDE_EXIT:
res.ErrorMessage = STR_RIDE_EXIT_IN_THE_WAY;
break;
case ENTRANCE_TYPE_PARK_ENTRANCE:
res.ErrorMessage = STR_PARK_ENTRANCE_IN_THE_WAY;
break;
}
break;
case TILE_ELEMENT_TYPE_WALL:
{
auto* wallEntry = tileElement->AsWall()->GetEntry();
res.ErrorMessage = STR_X_IN_THE_WAY;
auto ft = Formatter(res.ErrorMessageArgs.data());
rct_string_id stringId = wallEntry != nullptr ? wallEntry->name : static_cast<rct_string_id>(STR_EMPTY);
ft.Add<rct_string_id>(stringId);
break;
}
case TILE_ELEMENT_TYPE_LARGE_SCENERY:
{
auto* sceneryEntry = tileElement->AsLargeScenery()->GetEntry();
res.ErrorMessage = STR_X_IN_THE_WAY;
auto ft = Formatter(res.ErrorMessageArgs.data());
rct_string_id stringId = sceneryEntry != nullptr ? sceneryEntry->name : static_cast<rct_string_id>(STR_EMPTY);
ft.Add<rct_string_id>(stringId);
break;
}
}
}

@duncanspumpkin
Copy link
Contributor

Can't construct here, is an error title. The rest of it is an error message. So the message is getting a bit messed up. This happens quite easily due to all the globals involved

@ZehMatt
Copy link
Member Author

ZehMatt commented Oct 28, 2021

One of the reasons this is happening is becaue of this:

gGameCommandErrorText = STR_LAND_NOT_OWNED_BY_PARK;

Basically anyone who calls map_is_location_owned overwrites the last set error text.

@hjort96
Copy link
Contributor

hjort96 commented Oct 29, 2021

Thanks @Broxzier!

Seems like after #15815 was merged no error message was displayed, just the title. However, assigning

gGameCommandErrorText = std::get<1>(res->ErrorMessage);

after res is assigned in this part of TrackDesign.cpp

gGameCommandErrorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE;
auto trackPlaceAction = TrackPlaceAction(
_currentRideIndex, trackType, { newCoords, tempZ, static_cast<uint8_t>(rotation) }, brakeSpeed, trackColour,
seatRotation, liftHillAndAlternativeState, true);
trackPlaceAction.SetFlags(flags);
auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&trackPlaceAction)
: GameActions::QueryNested(&trackPlaceAction);
money32 cost = res->Error == GameActions::Status::Ok ? res->Cost : MONEY32_UNDEFINED;
totalCost += cost;
if (cost == MONEY32_UNDEFINED)
{
return std::nullopt;
}
break;

seems to give (some) correct error messages.
I don't think this is an incorrect overwriting of gGameCommandErrorText because this seems to be last place we can determine what the error was before displaying the message, since after returning from this function the only information we have is that cost == MONEY32_UNDEFINED.

@duncanspumpkin
Copy link
Contributor

@ZehMatt is doing a large refactor to track designs to fix the issue once and for all (and redesign some of the bad design). Just hold tight.

@ZehMatt ZehMatt linked a pull request Oct 29, 2021 that will close this issue
Gymnasiast added a commit to Gymnasiast/OpenRCT2 that referenced this issue Nov 21, 2021
- Improved: [OpenRCT2#12825, OpenRCT2#12869] The Tile Inspector window’s layout has been tweaked slightly.
- Change: [OpenRCT2#15899] Weird bonus for path 0 - likely intended as a queue bonus (original bug).
- Fix: [OpenRCT2#15138] Sometimes small scenery stays when building through it.
- Fix: [OpenRCT2#15620] Placing track designs at locations blocked by anything results in wrong error message.
- Fix: [OpenRCT2#15843] Tile Inspector can be resized too small.
- Fix: [OpenRCT2#15844] Tile Inspector has inconsistent text colours.
- Fix: [OpenRCT2#15878] Crash when opening a ride window for a corrupted vehicle.
- Fix: [OpenRCT2#15908] Crash when track elements have no ride assigned.
- Fix: [OpenRCT2#15919] Research status incorrectly considered for scenery when in editor modes.
- Fix: [OpenRCT2#15938] Track designs of some ride types are incorrectly exported to TD6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something went wrong.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants