diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index dc5283456b..4d7821300a 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2884,7 +2884,6 @@ static rct_string_id window_ride_get_status(rct_window* w, void* arguments) static void window_ride_main_paint(rct_window* w, rct_drawpixelinfo* dpi) { rct_widget* widget; - rct_string_id stringId; window_draw_widgets(w, dpi); window_ride_draw_tab_images(dpi, w); @@ -2902,21 +2901,24 @@ static void window_ride_main_paint(rct_window* w, rct_drawpixelinfo* dpi) if (ride == nullptr) return; - stringId = STR_OVERALL_VIEW; + auto ft = Formatter::Common(); if (w->ride.view != 0) { - stringId = RideComponentNames[RideTypeDescriptors[ride->type].NameConvention.vehicle].number; if (w->ride.view > ride->num_vehicles) { - set_format_arg(2, uint16_t, w->ride.view - ride->num_vehicles); - stringId = RideComponentNames[RideTypeDescriptors[ride->type].NameConvention.station].number; + ft.Add(RideComponentNames[RideTypeDescriptors[ride->type].NameConvention.station].number); + ft.Add(w->ride.view - ride->num_vehicles); } else { - set_format_arg(2, uint16_t, w->ride.view); + ft.Add(RideComponentNames[RideTypeDescriptors[ride->type].NameConvention.vehicle].number); + ft.Add(w->ride.view); } } - set_format_arg(0, uint16_t, stringId); + else + { + ft.Add(STR_OVERALL_VIEW); + } widget = &window_ride_main_widgets[WIDX_VIEW]; gfx_draw_string_centred( @@ -3105,33 +3107,33 @@ static void window_ride_vehicle_invalidate(rct_window* w) window_ride_vehicle_widgets[WIDX_VEHICLE_CARS_PER_TRAIN_DECREASE].type = WWT_EMPTY; } - set_format_arg(6, uint16_t, carsPerTrain); + auto ft = Formatter::Common(); + ft.Increment(6); + ft.Add(carsPerTrain); RIDE_COMPONENT_TYPE vehicleType = RideTypeDescriptors[ride->type].NameConvention.vehicle; stringId = RideComponentNames[vehicleType].count; if (ride->num_vehicles > 1) { stringId = RideComponentNames[vehicleType].count_plural; } - set_format_arg(8, rct_string_id, stringId); - set_format_arg(10, uint16_t, ride->num_vehicles); + ft.Add(stringId); + ft.Add(ride->num_vehicles); stringId = RideComponentNames[vehicleType].count; if (ride->max_trains > 1) { stringId = RideComponentNames[vehicleType].count_plural; } - set_format_arg(12, rct_string_id, stringId); - set_format_arg(14, uint16_t, ride->max_trains); - - set_format_arg(16, uint16_t, std::max(1, ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars); + ft.Add(stringId); + ft.Add(ride->max_trains); + ft.Add(std::max(1, ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars); stringId = RideComponentNames[RIDE_COMPONENT_TYPE_CAR].singular; if ((ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars > 1) { stringId = RideComponentNames[RIDE_COMPONENT_TYPE_CAR].plural; } - - set_format_arg(18, rct_string_id, stringId); + ft.Add(stringId); window_ride_anchor_border_widgets(w); window_align_tabs(w, WIDX_TAB_1, WIDX_TAB_10); @@ -3664,7 +3666,9 @@ static void window_ride_operating_invalidate(rct_window* w) window_ride_operating_widgets[WIDX_LIFT_HILL_SPEED].type = WWT_SPINNER; window_ride_operating_widgets[WIDX_LIFT_HILL_SPEED_INCREASE].type = WWT_BUTTON; window_ride_operating_widgets[WIDX_LIFT_HILL_SPEED_DECREASE].type = WWT_BUTTON; - set_format_arg(20, uint16_t, ride->lift_hill_speed); + auto ft = Formatter::Common(); + ft.Increment(20); + ft.Add(ride->lift_hill_speed); } else { @@ -3681,7 +3685,9 @@ static void window_ride_operating_invalidate(rct_window* w) window_ride_operating_widgets[WIDX_OPERATE_NUMBER_OF_CIRCUITS].type = WWT_SPINNER; window_ride_operating_widgets[WIDX_OPERATE_NUMBER_OF_CIRCUITS_INCREASE].type = WWT_BUTTON; window_ride_operating_widgets[WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE].type = WWT_BUTTON; - set_format_arg(22, uint16_t, ride->num_circuits); + auto ft = Formatter::Common(); + ft.Increment(22); + ft.Add(ride->num_circuits); } else { @@ -3745,10 +3751,12 @@ static void window_ride_operating_invalidate(rct_window* w) window_ride_operating_widgets[WIDX_MAXIMUM_LENGTH_INCREASE].type = WWT_BUTTON; window_ride_operating_widgets[WIDX_MAXIMUM_LENGTH_DECREASE].type = WWT_BUTTON; - set_format_arg(10, rct_string_id, STR_FORMAT_SECONDS); - set_format_arg(12, uint16_t, ride->min_waiting_time); - set_format_arg(14, rct_string_id, STR_FORMAT_SECONDS); - set_format_arg(16, uint16_t, ride->max_waiting_time); + auto ft = Formatter::Common(); + ft.Increment(10); + ft.Add(STR_FORMAT_SECONDS); + ft.Add(ride->min_waiting_time); + ft.Add(STR_FORMAT_SECONDS); + ft.Add(ride->max_waiting_time); if (ride->depart_flags & RIDE_DEPART_WAIT_FOR_LOAD) w->pressed_widgets |= (1 << WIDX_LOAD_CHECKBOX); @@ -3780,26 +3788,31 @@ static void window_ride_operating_invalidate(rct_window* w) w->pressed_widgets |= (1 << WIDX_MAXIMUM_LENGTH_CHECKBOX); // Mode specific functionality - set_format_arg(18, uint16_t, ride->operation_option); + auto ft = Formatter::Common(); + ft.Increment(18); + ft.Add(ride->operation_option); switch (ride->mode) { case RIDE_MODE_POWERED_LAUNCH_PASSTROUGH: case RIDE_MODE_POWERED_LAUNCH: case RIDE_MODE_UPWARD_LAUNCH: case RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED: - set_format_arg(18, uint16_t, (ride->launch_speed * 9) / 4); + ft.Increment(-ft.NumBytes() + 18); + ft.Add((ride->launch_speed * 9) / 4); format = STR_RIDE_MODE_SPEED_VALUE; caption = STR_LAUNCH_SPEED; tooltip = STR_LAUNCH_SPEED_TIP; break; case RIDE_MODE_STATION_TO_STATION: - set_format_arg(18, uint16_t, (ride->speed * 9) / 4); + ft.Increment(-ft.NumBytes() + 18); + ft.Add((ride->speed * 9) / 4); format = STR_RIDE_MODE_SPEED_VALUE; caption = STR_SPEED; tooltip = STR_SPEED_TIP; break; case RIDE_MODE_RACE: - set_format_arg(18, uint16_t, ride->num_laps); + ft.Increment(-ft.NumBytes() + 18); + ft.Add(ride->num_laps); format = STR_NUMBER_OF_LAPS_VALUE; caption = STR_NUMBER_OF_LAPS; tooltip = STR_NUMBER_OF_LAPS_TIP; @@ -3836,7 +3849,9 @@ static void window_ride_operating_invalidate(rct_window* w) { uint16_t arg; std::memcpy(&arg, gCommonFormatArgs + 18, sizeof(uint16_t)); - set_format_arg(18, uint16_t, arg * 3); + ft = Formatter::Common(); + ft.Increment(18); + ft.Add(arg * 3); } window_ride_operating_widgets[WIDX_MODE_TWEAK_LABEL].type = WWT_LABEL; @@ -5750,8 +5765,9 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi { // Excitement rct_string_id ratingName = get_rating_name(ride->excitement); - set_format_arg(0, uint32_t, ride->excitement); - set_format_arg(4, rct_string_id, ratingName); + auto ft = Formatter::Common(); + ft.Add(ride->excitement); + ft.Add(ratingName); rct_string_id stringId = ride->excitement == RIDE_RATING_UNDEFINED ? STR_EXCITEMENT_RATING_NOT_YET_AVAILABLE : STR_EXCITEMENT_RATING; gfx_draw_string_left(dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, x, y); @@ -5759,8 +5775,9 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi // Intensity ratingName = get_rating_name(ride->intensity); - set_format_arg(0, uint32_t, ride->intensity); - set_format_arg(4, rct_string_id, ratingName); + ft = Formatter::Common(); + ft.Add(ride->intensity); + ft.Add(ratingName); stringId = STR_INTENSITY_RATING; if (ride->excitement == RIDE_RATING_UNDEFINED) @@ -5773,8 +5790,9 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi // Nausea ratingName = get_rating_name(ride->nausea); - set_format_arg(0, uint32_t, ride->nausea); - set_format_arg(4, rct_string_id, ratingName); + ft = Formatter::Common(); + ft.Add(ride->nausea); + ft.Add(ratingName); stringId = ride->excitement == RIDE_RATING_UNDEFINED ? STR_NAUSEA_RATING_NOT_YET_AVAILABLE : STR_NAUSEA_RATING; gfx_draw_string_left(dpi, stringId, gCommonFormatArgs, COLOUR_BLACK, x, y); y += 2 * LIST_ROW_HEIGHT; @@ -5804,38 +5822,42 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi y += LIST_ROW_HEIGHT; // Ride time + ft = Formatter::Common(); int32_t numTimes = 0; for (int32_t i = 0; i < ride->num_stations; i++) { time = ride->stations[numTimes].SegmentTime; if (time != 0) { - set_format_arg(0 + (numTimes * 4), uint16_t, STR_RIDE_TIME_ENTRY_WITH_SEPARATOR); - set_format_arg(2 + (numTimes * 4), uint16_t, time); + ft.Add(STR_RIDE_TIME_ENTRY_WITH_SEPARATOR); + ft.Add(time); numTimes++; } } if (numTimes == 0) { - set_format_arg(0, rct_string_id, STR_RIDE_TIME_ENTRY); - set_format_arg(2, uint16_t, 0); + ft.Add(STR_RIDE_TIME_ENTRY); + ft.Add(0); numTimes++; } else { // sadly, STR_RIDE_TIME_ENTRY_WITH_SEPARATOR are defined with the separator AFTER an entry // therefore we set the last entry to use the no-separator format now, post-format - set_format_arg(0 + ((numTimes - 1) * 4), uint16_t, STR_RIDE_TIME_ENTRY); + ft.Increment(-ft.NumBytes() + ((numTimes - 1) * 4)); + ft.Add(STR_RIDE_TIME_ENTRY); } - set_format_arg(0 + (numTimes * 4), uint16_t, 0); - set_format_arg(2 + (numTimes * 4), uint16_t, 0); - set_format_arg(4 + (numTimes * 4), uint16_t, 0); - set_format_arg(6 + (numTimes * 4), uint16_t, 0); + ft.Increment(-ft.NumBytes() + (numTimes * 4)); + ft.Add(0); + ft.Add(0); + ft.Add(0); + ft.Add(0); gfx_draw_string_left_clipped(dpi, STR_RIDE_TIME, gCommonFormatArgs, COLOUR_BLACK, { x, y }, 308); y += LIST_ROW_HEIGHT; } // Ride length + ft = Formatter::Common(); int32_t numLengths = 0; for (int32_t i = 0; i < ride->num_stations; i++) { @@ -5843,27 +5865,29 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi if (length != 0) { length >>= 16; - set_format_arg(0 + (numLengths * 4), uint16_t, STR_RIDE_LENGTH_ENTRY_WITH_SEPARATOR); - set_format_arg(2 + (numLengths * 4), uint16_t, (length & 0xFFFF)); + ft.Add(STR_RIDE_LENGTH_ENTRY_WITH_SEPARATOR); + ft.Add(length & 0xFFFF); numLengths++; } } if (numLengths == 0) { - set_format_arg(0, rct_string_id, STR_RIDE_LENGTH_ENTRY); - set_format_arg(2, uint16_t, 0); + ft.Add(STR_RIDE_LENGTH_ENTRY); + ft.Add(0); numLengths++; } else { // sadly, STR_RIDE_LENGTH_ENTRY_WITH_SEPARATOR are defined with the separator AFTER an entry // therefore we set the last entry to use the no-separator format now, post-format - set_format_arg(0 + ((numLengths - 1) * 4), rct_string_id, STR_RIDE_LENGTH_ENTRY); + ft.Increment(-ft.NumBytes() + ((numLengths - 1) * 4)); + ft.Add(STR_RIDE_LENGTH_ENTRY); } - set_format_arg(0 + (numLengths * 4), uint16_t, 0); - set_format_arg(2 + (numLengths * 4), uint16_t, 0); - set_format_arg(4 + (numLengths * 4), uint16_t, 0); - set_format_arg(6 + (numLengths * 4), uint16_t, 0); + ft.Increment(-ft.NumBytes() + (numLengths * 4)); + ft.Add(0); + ft.Add(0); + ft.Add(0); + ft.Add(0); gfx_draw_string_left_clipped(dpi, STR_RIDE_LENGTH, gCommonFormatArgs, COLOUR_BLACK, { x, y }, 308); y += LIST_ROW_HEIGHT; @@ -6708,7 +6732,9 @@ static void window_ride_income_invalidate(rct_window* w) window_ride_income_widgets[WIDX_PRIMARY_PRICE].text = STR_ARG_6_CURRENCY2DP; money16 ridePrimaryPrice = ride_get_price(ride); - set_format_arg(6, money32, ridePrimaryPrice); + auto ft = Formatter::Common(); + ft.Increment(6); + ft.Add(ridePrimaryPrice); if (ridePrimaryPrice == 0) window_ride_income_widgets[WIDX_PRIMARY_PRICE].text = STR_FREE; @@ -6758,7 +6784,7 @@ static void window_ride_income_invalidate(rct_window* w) // Set secondary item price window_ride_income_widgets[WIDX_SECONDARY_PRICE].text = STR_RIDE_SECONDARY_PRICE_VALUE; - set_format_arg(10, money32, ride->price[1]); + ft.Add(ride->price[1]); if (ride->price[1] == 0) window_ride_income_widgets[WIDX_SECONDARY_PRICE].text = STR_FREE; } diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index 9230132738..454431c503 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -609,6 +609,8 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 0, y - 1 }, 159); // Ride information + auto ft = Formatter::Common(); + ft.Increment(2); auto formatSecondaryEnabled = true; rct_string_id formatSecondary = 0; switch (_window_ride_list_information_type) @@ -628,7 +630,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, if (ride->popularity != 255) { formatSecondary = STR_POPULARITY_LABEL; - set_format_arg(2, uint16_t, ride->popularity * 4); + ft.Add(ride->popularity * 4); } break; case INFORMATION_TYPE_SATISFACTION: @@ -636,7 +638,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, if (ride->satisfaction != 255) { formatSecondary = STR_SATISFACTION_LABEL; - set_format_arg(2, uint16_t, ride->satisfaction * 5); + ft.Add(ride->satisfaction * 5); } break; case INFORMATION_TYPE_PROFIT: @@ -644,24 +646,24 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, if (ride->profit != MONEY32_UNDEFINED) { formatSecondary = STR_PROFIT_LABEL; - set_format_arg(2, int32_t, ride->profit); + ft.Add(ride->profit); } break; case INFORMATION_TYPE_TOTAL_CUSTOMERS: formatSecondary = STR_RIDE_LIST_TOTAL_CUSTOMERS_LABEL; - set_format_arg(2, uint32_t, ride->total_customers); + ft.Add(ride->total_customers); break; case INFORMATION_TYPE_TOTAL_PROFIT: formatSecondary = 0; if (ride->total_profit != MONEY32_UNDEFINED) { formatSecondary = STR_RIDE_LIST_TOTAL_PROFIT_LABEL; - set_format_arg(2, int32_t, ride->total_profit); + ft.Add(ride->total_profit); } break; case INFORMATION_TYPE_CUSTOMERS: formatSecondary = STR_RIDE_LIST_CUSTOMERS_PER_HOUR_LABEL; - set_format_arg(2, uint32_t, ride_customers_per_hour(ride)); + ft.Add(ride_customers_per_hour(ride)); break; case INFORMATION_TYPE_AGE: { @@ -678,7 +680,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, formatSecondary = STR_RIDE_LIST_BUILT_X_YEARS_AGO_LABEL; break; } - set_format_arg(2, int16_t, age); + ft.Add(age); break; } case INFORMATION_TYPE_INCOME: @@ -686,7 +688,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, if (ride->income_per_hour != MONEY32_UNDEFINED) { formatSecondary = STR_RIDE_LIST_INCOME_LABEL; - set_format_arg(2, int32_t, ride->income_per_hour); + ft.Add(ride->income_per_hour); } break; case INFORMATION_TYPE_RUNNING_COST: @@ -694,11 +696,11 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, if (ride->upkeep_cost != MONEY16_UNDEFINED) { formatSecondary = STR_RIDE_LIST_RUNNING_COST_LABEL; - set_format_arg(2, int32_t, ride->upkeep_cost * 16); + ft.Add(ride->upkeep_cost * 16); } break; case INFORMATION_TYPE_QUEUE_LENGTH: - set_format_arg(2, uint16_t, ride->GetTotalQueueLength()); + ft.Add(ride->GetTotalQueueLength()); formatSecondary = STR_QUEUE_EMPTY; { uint16_t arg; @@ -711,7 +713,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, } break; case INFORMATION_TYPE_QUEUE_TIME: - set_format_arg(2, uint16_t, ride->GetMaxQueueTime()); + ft.Add(ride->GetMaxQueueTime()); formatSecondary = STR_QUEUE_TIME_LABEL; { uint16_t arg; @@ -722,18 +724,18 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, } break; case INFORMATION_TYPE_RELIABILITY: - set_format_arg(2, uint16_t, ride->reliability_percentage); + ft.Add(ride->reliability_percentage); formatSecondary = STR_RELIABILITY_LABEL; break; case INFORMATION_TYPE_DOWN_TIME: - set_format_arg(2, uint16_t, ride->downtime); + ft.Add(ride->downtime); formatSecondary = STR_DOWN_TIME_LABEL; break; case INFORMATION_TYPE_GUESTS_FAVOURITE: formatSecondary = 0; if (ride->IsRide()) { - set_format_arg(2, uint16_t, ride->guests_favourite); + ft.Add(ride->guests_favourite); formatSecondary = ride->guests_favourite == 1 ? STR_GUESTS_FAVOURITE_LABEL : STR_GUESTS_FAVOURITE_PLURAL_LABEL; } @@ -742,7 +744,8 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, if (formatSecondaryEnabled) { - set_format_arg(0, rct_string_id, formatSecondary); + ft.Increment(-ft.NumBytes()); + ft.Add(formatSecondary); } gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { 160, y - 1 }, 157); y += SCROLLABLE_ROW_HEIGHT; diff --git a/src/openrct2-ui/windows/TitleEditor.cpp b/src/openrct2-ui/windows/TitleEditor.cpp index 352f49d7cc..8aab3c9089 100644 --- a/src/openrct2-ui/windows/TitleEditor.cpp +++ b/src/openrct2-ui/windows/TitleEditor.cpp @@ -897,7 +897,8 @@ static void window_title_editor_scrollpaint_saves(rct_window* w, rct_drawpixelin } char buffer[256]; - set_format_arg(0, uintptr_t, _editingTitleSequence->Saves[i]); + auto ft = Formatter::Common(); + ft.Add(_editingTitleSequence->Saves[i]); if (selected || hover) { format_string(buffer, 256, STR_STRING, gCommonFormatArgs); @@ -907,7 +908,8 @@ static void window_title_editor_scrollpaint_saves(rct_window* w, rct_drawpixelin format_string(buffer + 1, 255, STR_STRING, gCommonFormatArgs); buffer[0] = static_cast(static_cast(FORMAT_BLACK)); } - set_format_arg(0, uintptr_t, &buffer); + ft = Formatter::Common(); + ft.Add(&buffer); gfx_draw_string_left(dpi, STR_STRING, gCommonFormatArgs, w->colours[1], x + 5, y); } } @@ -946,6 +948,7 @@ static void window_title_editor_scrollpaint_commands(rct_window* w, rct_drawpixe ColourMapA[w->colours[1]].lighter | 0x1000000); } + auto ft = Formatter::Common(); rct_string_id commandName = STR_NONE; switch (command->Type) { @@ -958,25 +961,25 @@ static void window_title_editor_scrollpaint_commands(rct_window* w, rct_drawpixe } else { - set_format_arg(0, uintptr_t, _editingTitleSequence->Saves[command->SaveIndex]); + ft.Add(_editingTitleSequence->Saves[command->SaveIndex]); } break; case TITLE_SCRIPT_LOCATION: commandName = STR_TITLE_EDITOR_COMMAND_LOCATION; - set_format_arg(0, uint16_t, command->X); - set_format_arg(2, uint16_t, command->Y); + ft.Add(command->X); + ft.Add(command->Y); break; case TITLE_SCRIPT_ROTATE: commandName = STR_TITLE_EDITOR_COMMAND_ROTATE; - set_format_arg(0, uint16_t, command->Rotations); + ft.Add(command->Rotations); break; case TITLE_SCRIPT_ZOOM: commandName = STR_TITLE_EDITOR_COMMAND_ZOOM; - set_format_arg(0, uint16_t, command->Zoom); + ft.Add(command->Zoom); break; case TITLE_SCRIPT_SPEED: commandName = STR_TITLE_EDITOR_COMMAND_SPEED; - set_format_arg(0, rct_string_id, SpeedNames[command->Speed - 1]); + ft.Add(SpeedNames[command->Speed - 1]); break; case TITLE_SCRIPT_FOLLOW: commandName = STR_TITLE_EDITOR_COMMAND_FOLLOW; @@ -986,12 +989,12 @@ static void window_title_editor_scrollpaint_commands(rct_window* w, rct_drawpixe } else { - set_format_arg(0, uintptr_t, reinterpret_cast(command->SpriteName)); + ft.Add(reinterpret_cast(command->SpriteName)); } break; case TITLE_SCRIPT_WAIT: commandName = STR_TITLE_EDITOR_COMMAND_WAIT; - set_format_arg(0, uint16_t, command->Milliseconds); + ft.Add(command->Milliseconds); break; case TITLE_SCRIPT_RESTART: commandName = STR_TITLE_EDITOR_RESTART; @@ -1016,7 +1019,7 @@ static void window_title_editor_scrollpaint_commands(rct_window* w, rct_drawpixe { commandName = STR_TITLE_EDITOR_COMMAND_LOAD_MISSING_SCENARIO; } - set_format_arg(0, uintptr_t, name); + ft.Add(name); break; } default: @@ -1033,7 +1036,8 @@ static void window_title_editor_scrollpaint_commands(rct_window* w, rct_drawpixe format_string(buffer + 1, 255, commandName, gCommonFormatArgs); buffer[0] = static_cast(error ? ((selected || hover) ? FORMAT_LIGHTPINK : FORMAT_RED) : FORMAT_BLACK); } - set_format_arg(0, uintptr_t, &buffer); + ft = Formatter::Common(); + ft.Add(&buffer); gfx_draw_string_left(dpi, STR_STRING, gCommonFormatArgs, w->colours[1], x + 5, y); } } diff --git a/src/openrct2/localisation/Localisation.h b/src/openrct2/localisation/Localisation.h index cf113487d9..a8dcc93687 100644 --- a/src/openrct2/localisation/Localisation.h +++ b/src/openrct2/localisation/Localisation.h @@ -85,19 +85,6 @@ extern const rct_string_id DateGameShortMonthNames[MONTH_COUNT]; std::memcpy(args + offset, &value, size); } -template void constexpr set_format_arg(uint8_t* args, size_t offset, uintptr_t value) -{ - static_assert(sizeof(T) <= sizeof(uintptr_t), "Type too large"); - set_format_arg_body(args, offset, value, sizeof(T)); -} - -#define set_format_arg(offset, type, value) \ - do \ - { \ - static_assert(sizeof(type) <= sizeof(uintptr_t), "Type too large"); \ - set_format_arg_body(gCommonFormatArgs, offset, (uintptr_t)(value), sizeof(type)); \ - } while (false) - class Formatter { const uint8_t* StartBuf; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 8bb8904aa7..b9dd90769b 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -1254,10 +1254,13 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActionResult& } break; case TILE_ELEMENT_TYPE_SMALL_SCENERY: + { sceneryEntry = tileElement->AsSmallScenery()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; - set_format_arg(res.ErrorMessageArgs.data(), 0, sceneryEntry->name); + auto ft = Formatter(res.ErrorMessageArgs.data()); + ft.Add(sceneryEntry->name); break; + } case TILE_ELEMENT_TYPE_ENTRANCE: switch (tileElement->AsEntrance()->GetEntranceType()) { @@ -1273,15 +1276,21 @@ void map_obstruction_set_error_text(TileElement* tileElement, GameActionResult& } break; case TILE_ELEMENT_TYPE_WALL: + { sceneryEntry = tileElement->AsWall()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; - set_format_arg(res.ErrorMessageArgs.data(), 0, sceneryEntry->name); + auto ft = Formatter(res.ErrorMessageArgs.data()); + ft.Add(sceneryEntry->name); break; + } case TILE_ELEMENT_TYPE_LARGE_SCENERY: + { sceneryEntry = tileElement->AsLargeScenery()->GetEntry(); res.ErrorMessage = STR_X_IN_THE_WAY; - set_format_arg(res.ErrorMessageArgs.data(), 0, sceneryEntry->name); + auto ft = Formatter(res.ErrorMessageArgs.data()); + ft.Add(sceneryEntry->name); break; + } } }