Fix compile errors and ride entry null edge case

This commit is contained in:
Ted John 2019-07-21 13:50:01 +01:00
parent 1d4c1958dd
commit eb4c9acb08
3 changed files with 31 additions and 52 deletions

View File

@ -234,12 +234,12 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
if (ride->status == RIDE_STATUS_CLOSED)
{
set_map_tooltip_format_arg(0, rct_string_id, STR_MAP_TOOLTIP_STRINGID_CLICK_TO_MODIFY);
set_map_tooltip_format_arg(2, rct_string_id, ride->name);
set_map_tooltip_format_arg(4, uint32_t, ride->name_arguments);
ride->FormatNameTo(gMapTooltipFormatArgs + 2);
}
return info->type;
case VIEWPORT_INTERACTION_ITEM_RIDE:
{
if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH)
@ -298,15 +298,13 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
return info->type = VIEWPORT_INTERACTION_ITEM_NONE;
}
set_map_tooltip_format_arg(2, rct_string_id, ride->name);
set_map_tooltip_format_arg(4, uint32_t, ride->name_arguments);
ride->FormatNameTo(gMapTooltipFormatArgs + 2);
return info->type;
}
set_map_tooltip_format_arg(4, rct_string_id, ride->name);
set_map_tooltip_format_arg(6, uint32_t, ride->name_arguments);
auto nameArgLen = ride->FormatNameTo(gMapTooltipFormatArgs + 4);
set_map_tooltip_format_arg(
10, rct_string_id, RideComponentNames[RideNameConvention[ride->type].station].capitalised);
4 + nameArgLen, rct_string_id, RideComponentNames[RideNameConvention[ride->type].station].capitalised);
if (tileElement->GetType() == TILE_ELEMENT_TYPE_ENTRANCE)
stationIndex = tileElement->AsEntrance()->GetStationIndex();
@ -317,9 +315,9 @@ int32_t viewport_interaction_get_item_right(int32_t x, int32_t y, viewport_inter
if (ride->stations[i].Start.xy == RCT_XY8_UNDEFINED)
stationIndex--;
stationIndex++;
set_map_tooltip_format_arg(12, uint16_t, stationIndex);
set_map_tooltip_format_arg(4 + nameArgLen + 2, uint16_t, stationIndex);
return info->type;
}
case VIEWPORT_INTERACTION_ITEM_WALL:
sceneryEntry = tileElement->AsWall()->GetEntry();
if (sceneryEntry->wall.scrolling_mode != SCROLLING_MODE_NONE)

View File

@ -218,22 +218,16 @@ static void window_ride_demolish_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
window_draw_widgets(w, dpi);
Ride* ride = get_ride(w->number);
set_format_arg(0, rct_string_id, ride->name);
set_format_arg(2, uint32_t, ride->name_arguments);
set_format_arg(6, money32, _demolishRideCost);
int32_t x = w->x + WW / 2;
int32_t y = w->y + (WH / 2) - 3;
if (gParkFlags & PARK_FLAGS_NO_MONEY)
auto ride = get_ride(w->number);
if (ride != nullptr)
{
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, STR_DEMOLISH_RIDE_ID, COLOUR_BLACK);
}
else
{
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, STR_DEMOLISH_RIDE_ID_MONEY, COLOUR_BLACK);
auto stringId = (gParkFlags & PARK_FLAGS_NO_MONEY) ? STR_DEMOLISH_RIDE_ID : STR_DEMOLISH_RIDE_ID_MONEY;
auto nameArgLen = ride->FormatNameTo(gCommonFormatArgs);
set_format_arg(nameArgLen, money32, _demolishRideCost);
int32_t x = w->x + WW / 2;
int32_t y = w->y + (WH / 2) - 3;
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, stringId, COLOUR_BLACK);
}
}
@ -241,21 +235,15 @@ static void window_ride_refurbish_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
window_draw_widgets(w, dpi);
Ride* ride = get_ride(w->number);
set_format_arg(0, rct_string_id, ride->name);
set_format_arg(2, uint32_t, ride->name_arguments);
set_format_arg(6, money32, _demolishRideCost / 2);
int32_t x = w->x + WW / 2;
int32_t y = w->y + (WH / 2) - 3;
if (gParkFlags & PARK_FLAGS_NO_MONEY)
auto ride = get_ride(w->number);
if (ride != nullptr)
{
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, STR_REFURBISH_RIDE_ID_NO_MONEY, COLOUR_BLACK);
}
else
{
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, STR_REFURBISH_RIDE_ID_MONEY, COLOUR_BLACK);
auto stringId = (gParkFlags & PARK_FLAGS_NO_MONEY) ? STR_REFURBISH_RIDE_ID_NO_MONEY : STR_REFURBISH_RIDE_ID_MONEY;
auto nameArgLen = ride->FormatNameTo(gCommonFormatArgs);
set_format_arg(nameArgLen, money32, _demolishRideCost / 2);
int32_t x = w->x + WW / 2;
int32_t y = w->y + (WH / 2) - 3;
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, stringId, COLOUR_BLACK);
}
}

View File

@ -7921,7 +7921,7 @@ size_t Ride::FormatNameTo(void* argsV) const
}
else
{
rct_string_id rideTypeName{};
auto rideTypeName = RideNaming[type].name;
if (RideGroupManager::RideTypeIsIndependent(type))
{
auto rideEntry = GetRideEntry();
@ -7930,20 +7930,13 @@ size_t Ride::FormatNameTo(void* argsV) const
rideTypeName = rideEntry->naming.name;
}
}
else
else if (RideGroupManager::RideTypeHasRideGroups(type))
{
if (RideGroupManager::RideTypeHasRideGroups(type))
auto rideEntry = GetRideEntry();
if (rideEntry != nullptr)
{
auto rideEntry = GetRideEntry();
if (rideEntry != nullptr)
{
auto rideGroup = RideGroupManager::GetRideGroup(type, rideEntry);
rideTypeName = rideGroup->Naming.name;
}
}
else
{
rideTypeName = RideNaming[type].name;
auto rideGroup = RideGroupManager::GetRideGroup(type, rideEntry);
rideTypeName = rideGroup->Naming.name;
}
}
set_format_arg_on(args, 0, rct_string_id, 1);