forked from rosebudai/OpenRCT2-Web
Do not use user strings for peep names
This commit is contained in:
1 parent
61d64ab8c5
commit
40d49b93d3
27 files changed
+282
-323
No files matched your search
@@ -582,8 +582,7 @@ static void window_guest_common_invalidate(rct_window* w)
|
||||
w->pressed_widgets |= 1ULL << (w->page + WIDX_TAB_1);
|
||||
|
||||
auto peep = GET_PEEP(w->number);
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
|
||||
w->widgets[WIDX_BACKGROUND].right = w->width - 1;
|
||||
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
||||
@@ -714,9 +713,11 @@ void window_guest_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex)
|
||||
}
|
||||
break;
|
||||
case WIDX_RENAME:
|
||||
window_text_input_open(
|
||||
w, widgetIndex, STR_GUEST_RENAME_TITLE, STR_GUEST_RENAME_PROMPT, peep->name_string_idx, peep->id, 32);
|
||||
{
|
||||
auto peepName = peep->GetName();
|
||||
window_text_input_raw_open(w, widgetIndex, STR_GUEST_RENAME_TITLE, STR_GUEST_RENAME_PROMPT, peepName.c_str(), 32);
|
||||
break;
|
||||
}
|
||||
case WIDX_LOCATE:
|
||||
window_scroll_to_viewport(w);
|
||||
break;
|
||||
|
||||
@@ -775,8 +775,7 @@ static void window_guest_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
||||
}
|
||||
|
||||
// Guest name
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, 0, y, 113);
|
||||
|
||||
switch (_window_guest_list_selected_view)
|
||||
@@ -1052,14 +1051,14 @@ static bool guest_should_be_visible(Peep* peep)
|
||||
|
||||
if (_window_guest_list_filter_name[0] != '\0')
|
||||
{
|
||||
char formatted[256];
|
||||
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
format_string(formatted, sizeof(formatted), peep->name_string_idx, gCommonFormatArgs);
|
||||
|
||||
if (strcasestr(formatted, _window_guest_list_filter_name) == nullptr)
|
||||
char name[256]{};
|
||||
uint8_t args[32]{};
|
||||
peep->FormatNameTo(args);
|
||||
format_string(name, sizeof(name), STR_STRINGID, args);
|
||||
if (strcasestr(name, _window_guest_list_filter_name) == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -2692,15 +2692,11 @@ static rct_string_id window_ride_get_status_overall_view(rct_window* w, void* ar
|
||||
auto ride = get_ride(w->number);
|
||||
if (ride != nullptr)
|
||||
{
|
||||
rct_string_id formatSecondary;
|
||||
int32_t argument;
|
||||
ride_get_status(ride, &formatSecondary, &argument);
|
||||
std::memcpy(arguments, &formatSecondary, sizeof(formatSecondary));
|
||||
std::memcpy((void*)((uintptr_t)arguments + 2), &argument, sizeof(argument));
|
||||
stringId = STR_RED_OUTLINED_STRING;
|
||||
if (formatSecondary != STR_BROKEN_DOWN && formatSecondary != STR_CRASHED)
|
||||
ride->FormatStatusTo(arguments);
|
||||
stringId = STR_BLACK_STRING;
|
||||
if ((ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) || (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED))
|
||||
{
|
||||
stringId = STR_BLACK_STRING;
|
||||
stringId = STR_RED_OUTLINED_STRING;
|
||||
}
|
||||
}
|
||||
return stringId;
|
||||
@@ -4279,8 +4275,7 @@ static void window_ride_maintenance_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
auto peep = (&(get_sprite(ride->mechanic)->peep))->AsStaff();
|
||||
if (peep != nullptr && peep->IsMechanic())
|
||||
{
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x + 4, y, 280, stringId, COLOUR_BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ static void window_ride_list_paint(rct_window* w, rct_drawpixelinfo* dpi)
|
||||
*/
|
||||
static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
|
||||
{
|
||||
int32_t i, y, argument;
|
||||
int32_t i, y;
|
||||
rct_string_id format, formatSecondary;
|
||||
Ride* ride;
|
||||
|
||||
@@ -616,8 +616,13 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
||||
switch (_window_ride_list_information_type)
|
||||
{
|
||||
case INFORMATION_TYPE_STATUS:
|
||||
ride_get_status(ride, &formatSecondary, &argument);
|
||||
set_format_arg(2, int32_t, argument);
|
||||
ride->FormatStatusTo(gCommonFormatArgs);
|
||||
|
||||
// Make test red and bold if broken down or crashed
|
||||
if ((ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN) || (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED))
|
||||
{
|
||||
format = STR_RED_OUTLINED_STRING;
|
||||
}
|
||||
break;
|
||||
case INFORMATION_TYPE_POPULARITY:
|
||||
formatSecondary = STR_POPULARITY_UNKNOWN_LABEL;
|
||||
@@ -736,10 +741,6 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi,
|
||||
break;
|
||||
}
|
||||
|
||||
// Make test red and bold if broken down or crashed
|
||||
if (formatSecondary == STR_BROKEN_DOWN || formatSecondary == STR_CRASHED)
|
||||
format = STR_RED_OUTLINED_STRING;
|
||||
|
||||
set_format_arg(0, rct_string_id, formatSecondary);
|
||||
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, 160, y - 1, 157);
|
||||
y += SCROLLABLE_ROW_HEIGHT;
|
||||
|
||||
@@ -486,10 +486,12 @@ void window_staff_overview_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||
break;
|
||||
}
|
||||
case WIDX_RENAME:
|
||||
window_text_input_open(
|
||||
w, widgetIndex, STR_STAFF_TITLE_STAFF_MEMBER_NAME, STR_STAFF_PROMPT_ENTER_NAME, peep->name_string_idx, peep->id,
|
||||
32);
|
||||
{
|
||||
auto peepName = peep->GetName();
|
||||
window_text_input_raw_open(
|
||||
w, widgetIndex, STR_STAFF_TITLE_STAFF_MEMBER_NAME, STR_STAFF_PROMPT_ENTER_NAME, peepName.c_str(), 32);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -778,8 +780,7 @@ void window_staff_stats_invalidate(rct_window* w)
|
||||
|
||||
Peep* peep = GET_PEEP(w->number);
|
||||
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
|
||||
window_staff_stats_widgets[WIDX_BACKGROUND].right = w->width - 1;
|
||||
window_staff_stats_widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
||||
@@ -813,8 +814,7 @@ void window_staff_options_invalidate(rct_window* w)
|
||||
|
||||
Peep* peep = GET_PEEP(w->number);
|
||||
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
|
||||
switch (peep->staff_type)
|
||||
{
|
||||
@@ -891,8 +891,7 @@ void window_staff_overview_invalidate(rct_window* w)
|
||||
|
||||
Peep* peep = GET_PEEP(w->number);
|
||||
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
|
||||
window_staff_overview_widgets[WIDX_BACKGROUND].right = w->width - 1;
|
||||
window_staff_overview_widgets[WIDX_BACKGROUND].bottom = w->height - 1;
|
||||
|
||||
@@ -127,8 +127,7 @@ static void window_staff_fire_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
|
||||
Peep* peep = &get_sprite(w->number)->peep;
|
||||
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
|
||||
int32_t x = w->x + WW / 2;
|
||||
int32_t y = w->y + (WH / 2) - 3;
|
||||
|
||||
@@ -693,8 +693,7 @@ void window_staff_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_
|
||||
format = (_quick_fire_mode ? STR_LIGHTPINK_STRINGID : STR_WINDOW_COLOUR_2_STRINGID);
|
||||
}
|
||||
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, 0, y, nameColumnSize);
|
||||
|
||||
peep->FormatActionTo(gCommonFormatArgs);
|
||||
|
||||
@@ -623,8 +623,13 @@ static void window_title_command_editor_tool_down(rct_window* w, rct_widgetindex
|
||||
if (spriteIdentifier == SPRITE_IDENTIFIER_PEEP)
|
||||
{
|
||||
validSprite = true;
|
||||
Peep* peep = GET_PEEP(spriteIndex);
|
||||
format_string(command.SpriteName, USER_STRING_MAX_LENGTH, peep->name_string_idx, &peep->id);
|
||||
auto peep = GET_PEEP(spriteIndex);
|
||||
if (peep != nullptr)
|
||||
{
|
||||
uint8_t formatArgs[32]{};
|
||||
peep->FormatNameTo(formatArgs);
|
||||
format_string(command.SpriteName, USER_STRING_MAX_LENGTH, STR_STRINGID, &peep->id);
|
||||
}
|
||||
}
|
||||
else if (spriteIdentifier == SPRITE_IDENTIFIER_VEHICLE)
|
||||
{
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace Editor
|
||||
auto peep = get_sprite(i)->AsPeep();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
user_string_free(peep->name_string_idx);
|
||||
peep->SetName({});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -644,10 +644,8 @@ void game_fix_save_vars()
|
||||
continue;
|
||||
}
|
||||
set_format_arg(0, uint32_t, peep->id);
|
||||
utf8* curName = gCommonStringFormatBuffer;
|
||||
rct_string_id curId = peep->name_string_idx;
|
||||
format_string(curName, 256, curId, gCommonFormatArgs);
|
||||
log_warning("Peep %u (%s) has invalid ride station = %u for ride %u.", spriteIndex, curName, srcStation, rideIdx);
|
||||
auto curName = peep->GetName();
|
||||
log_warning("Peep %u (%s) has invalid ride station = %u for ride %u.", spriteIndex, curName.c_str(), srcStation, rideIdx);
|
||||
int8_t station = ride_get_first_valid_station_exit(get_ride(rideIdx));
|
||||
if (station == -1)
|
||||
{
|
||||
|
||||
@@ -202,7 +202,6 @@ struct GameStateSnapshots : public IGameStateSnapshots
|
||||
|
||||
void CompareSpriteDataPeep(const Peep& spriteBase, const Peep& spriteCmp, GameStateSpriteChange_t& changeData) const
|
||||
{
|
||||
COMPARE_FIELD(Peep, name_string_idx);
|
||||
COMPARE_FIELD(Peep, next_x);
|
||||
COMPARE_FIELD(Peep, next_y);
|
||||
COMPARE_FIELD(Peep, next_z);
|
||||
|
||||
@@ -56,60 +56,35 @@ public:
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE);
|
||||
}
|
||||
|
||||
if (_name.empty())
|
||||
{
|
||||
return std::make_unique<GameActionResult>(
|
||||
GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_ERR_INVALID_NAME_FOR_GUEST);
|
||||
}
|
||||
|
||||
Peep* peep = GET_PEEP(_spriteIndex);
|
||||
auto peep = GET_PEEP(_spriteIndex);
|
||||
if (peep->type != PEEP_TYPE_GUEST)
|
||||
{
|
||||
log_warning("Invalid game command for sprite %u", _spriteIndex);
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE);
|
||||
}
|
||||
|
||||
rct_string_id newUserStringId = user_string_allocate(
|
||||
USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
|
||||
if (newUserStringId == 0)
|
||||
{
|
||||
// TODO: Probably exhausted, introduce new error.
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, gGameCommandErrorText);
|
||||
}
|
||||
user_string_free(newUserStringId);
|
||||
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Execute() const override
|
||||
{
|
||||
rct_string_id newUserStringId = user_string_allocate(
|
||||
USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
|
||||
if (newUserStringId == 0)
|
||||
{
|
||||
// TODO: Probably exhausted, introduce new error.
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, gGameCommandErrorText);
|
||||
}
|
||||
|
||||
Peep* peep = GET_PEEP(_spriteIndex);
|
||||
auto peep = GET_PEEP(_spriteIndex);
|
||||
if (peep->type != PEEP_TYPE_GUEST)
|
||||
{
|
||||
log_warning("Invalid game command for sprite %u", _spriteIndex);
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE);
|
||||
}
|
||||
|
||||
set_format_arg(0, uint32_t, peep->id);
|
||||
utf8* curName = gCommonStringFormatBuffer;
|
||||
rct_string_id curId = peep->name_string_idx;
|
||||
format_string(curName, 256, curId, gCommonFormatArgs);
|
||||
|
||||
if (strcmp(curName, _name.c_str()) == 0)
|
||||
auto curName = peep->GetName();
|
||||
if (curName == _name)
|
||||
{
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::OK, STR_NONE);
|
||||
}
|
||||
|
||||
user_string_free(peep->name_string_idx);
|
||||
peep->name_string_idx = newUserStringId;
|
||||
if (!peep->SetName(_name))
|
||||
{
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, STR_NONE);
|
||||
}
|
||||
|
||||
peep_update_name_sort(peep);
|
||||
|
||||
|
||||
@@ -53,18 +53,6 @@ public:
|
||||
log_warning("Invalid game command for setting sign name, banner id = %d", _bannerIndex);
|
||||
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE);
|
||||
}
|
||||
|
||||
// Ensure user string space.
|
||||
rct_string_id string_id = user_string_allocate(USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
|
||||
if (string_id != 0)
|
||||
{
|
||||
user_string_free(string_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_ERR_CANT_SET_BANNER_TEXT);
|
||||
}
|
||||
|
||||
return MakeResult();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,13 +26,6 @@
|
||||
#include "../world/Sprite.h"
|
||||
#include "GameAction.h"
|
||||
|
||||
static constexpr const rct_string_id staffNames[] = {
|
||||
STR_HANDYMAN_X,
|
||||
STR_MECHANIC_X,
|
||||
STR_SECURITY_GUARD_X,
|
||||
STR_ENTERTAINER_X,
|
||||
};
|
||||
|
||||
/* rct2: 0x009929FC */
|
||||
static constexpr const PeepSpriteType spriteTypes[] = {
|
||||
PEEP_SPRITE_TYPE_HANDYMAN,
|
||||
@@ -217,7 +210,7 @@ private:
|
||||
{
|
||||
spriteType = static_cast<PeepSpriteType>(PEEP_SPRITE_TYPE_ENTERTAINER_PANDA + _entertainerType);
|
||||
}
|
||||
newPeep->name_string_idx = staffNames[_staffType];
|
||||
newPeep->name = nullptr;
|
||||
newPeep->sprite_type = spriteType;
|
||||
|
||||
const rct_sprite_bounds* spriteBounds = g_peep_animation_entries[spriteType].sprite_bounds;
|
||||
|
||||
@@ -58,12 +58,7 @@ public:
|
||||
GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
|
||||
}
|
||||
|
||||
if (_name.empty())
|
||||
{
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER);
|
||||
}
|
||||
|
||||
Peep* peep = GET_PEEP(_spriteIndex);
|
||||
auto peep = GET_PEEP(_spriteIndex);
|
||||
if (peep->type != PEEP_TYPE_STAFF)
|
||||
{
|
||||
log_warning("Invalid game command for sprite %u", _spriteIndex);
|
||||
@@ -71,31 +66,12 @@ public:
|
||||
GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
|
||||
}
|
||||
|
||||
rct_string_id newUserStringId = user_string_allocate(
|
||||
USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
|
||||
if (newUserStringId == 0)
|
||||
{
|
||||
// TODO: Probably exhausted, introduce new error.
|
||||
return std::make_unique<GameActionResult>(
|
||||
GA_ERROR::UNKNOWN, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, gGameCommandErrorText);
|
||||
}
|
||||
user_string_free(newUserStringId);
|
||||
|
||||
return std::make_unique<GameActionResult>();
|
||||
}
|
||||
|
||||
GameActionResult::Ptr Execute() const override
|
||||
{
|
||||
rct_string_id newUserStringId = user_string_allocate(
|
||||
USER_STRING_HIGH_ID_NUMBER | USER_STRING_DUPLICATION_PERMITTED, _name.c_str());
|
||||
if (newUserStringId == 0)
|
||||
{
|
||||
// TODO: Probably exhausted, introduce new error.
|
||||
return std::make_unique<GameActionResult>(
|
||||
GA_ERROR::UNKNOWN, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, gGameCommandErrorText);
|
||||
}
|
||||
|
||||
Peep* peep = GET_PEEP(_spriteIndex);
|
||||
auto peep = GET_PEEP(_spriteIndex);
|
||||
if (peep->type != PEEP_TYPE_STAFF)
|
||||
{
|
||||
log_warning("Invalid game command for sprite %u", _spriteIndex);
|
||||
@@ -103,18 +79,16 @@ public:
|
||||
GA_ERROR::INVALID_PARAMETERS, STR_STAFF_ERROR_CANT_NAME_STAFF_MEMBER, STR_NONE);
|
||||
}
|
||||
|
||||
set_format_arg(0, uint32_t, peep->id);
|
||||
utf8* curName = gCommonStringFormatBuffer;
|
||||
rct_string_id curId = peep->name_string_idx;
|
||||
format_string(curName, 256, curId, gCommonFormatArgs);
|
||||
|
||||
if (strcmp(curName, _name.c_str()) == 0)
|
||||
auto curName = peep->GetName();
|
||||
if (curName == _name)
|
||||
{
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::OK, STR_NONE);
|
||||
}
|
||||
|
||||
user_string_free(peep->name_string_idx);
|
||||
peep->name_string_idx = newUserStringId;
|
||||
if (!peep->SetName(_name))
|
||||
{
|
||||
return std::make_unique<GameActionResult>(GA_ERROR::UNKNOWN, STR_CANT_NAME_GUEST, STR_NONE);
|
||||
}
|
||||
|
||||
peep_update_name_sort(peep);
|
||||
|
||||
|
||||
@@ -443,10 +443,9 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv)
|
||||
int32_t i;
|
||||
FOR_ALL_STAFF (i, peep)
|
||||
{
|
||||
char name[128];
|
||||
format_string(name, 128, peep->name_string_idx, &peep->id);
|
||||
auto name = peep->GetName();
|
||||
console.WriteFormatLine(
|
||||
"staff id %03d type: %02u energy %03u name %s", i, peep->staff_type, peep->energy, name);
|
||||
"staff id %03d type: %02u energy %03u name %s", i, peep->staff_type, peep->energy, name.c_str());
|
||||
}
|
||||
}
|
||||
else if (argv[0] == "set")
|
||||
|
||||
@@ -1280,8 +1280,6 @@ static void format_string_part(utf8** dest, size_t* size, rct_string_id format,
|
||||
format_push_char(real_name_initials[(realNameIndex >> 10) % std::size(real_name_initials)]);
|
||||
format_push_char('.');
|
||||
*(*dest) = '\0';
|
||||
|
||||
*args += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -422,10 +422,12 @@ namespace Twitch
|
||||
Peep* peep;
|
||||
FOR_ALL_GUESTS (spriteIndex, peep)
|
||||
{
|
||||
if (is_user_string_id(peep->name_string_idx))
|
||||
if (peep->name != nullptr)
|
||||
{
|
||||
utf8 buffer[256];
|
||||
format_string(buffer, 256, peep->name_string_idx, nullptr);
|
||||
uint8_t args[32]{};
|
||||
char buffer[256]{};
|
||||
peep->FormatNameTo(args);
|
||||
format_string(buffer, sizeof(buffer), STR_STRINGID, args);
|
||||
|
||||
AudienceMember* member = nullptr;
|
||||
for (AudienceMember& m : members)
|
||||
@@ -503,13 +505,14 @@ namespace Twitch
|
||||
}
|
||||
|
||||
AudienceMember* member = &members[memberIndex];
|
||||
if (!is_user_string_id(peep->name_string_idx) && !(peep->peep_flags & PEEP_FLAGS_LEAVING_PARK))
|
||||
if (peep->name == nullptr && !(peep->peep_flags & PEEP_FLAGS_LEAVING_PARK))
|
||||
{
|
||||
// Rename peep and add flags
|
||||
rct_string_id newStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER, member->Name);
|
||||
if (newStringId != 0)
|
||||
auto memLen = std::strlen(member->Name) + 1;
|
||||
peep->name = (char*)std::malloc(memLen);
|
||||
if (peep->name != nullptr)
|
||||
{
|
||||
peep->name_string_idx = newStringId;
|
||||
std::memcpy(peep->name, member->Name, memLen);
|
||||
|
||||
uint32_t flags = peep->peep_flags | PEEP_FLAGS_TWITCH;
|
||||
if (member->ShouldTrack)
|
||||
|
||||
+15
-13
@@ -537,9 +537,11 @@ void Guest::UpdateEasterEggInteractions()
|
||||
|
||||
int32_t Guest::GetEasterEggNameId() const
|
||||
{
|
||||
char buffer[256];
|
||||
uint8_t args[32]{};
|
||||
char buffer[256]{};
|
||||
|
||||
format_string(buffer, 256, this->name_string_idx, &this->id);
|
||||
FormatNameTo(args);
|
||||
format_string(buffer, sizeof(buffer), STR_STRINGID, args);
|
||||
|
||||
for (uint32_t i = 0; i < std::size(gPeepEasterEggNames); i++)
|
||||
if (_stricmp(buffer, gPeepEasterEggNames[i]) == 0)
|
||||
@@ -682,9 +684,12 @@ void Guest::HandleEasterEggName()
|
||||
*/
|
||||
int32_t Guest::CheckEasterEggName(int32_t index) const
|
||||
{
|
||||
char buffer[256];
|
||||
uint8_t args[32]{};
|
||||
char buffer[256]{};
|
||||
|
||||
FormatNameTo(args);
|
||||
format_string(buffer, sizeof(buffer), STR_STRINGID, args);
|
||||
|
||||
format_string(buffer, 256, this->name_string_idx, &this->id);
|
||||
return _stricmp(buffer, gPeepEasterEggNames[index]) == 0;
|
||||
}
|
||||
|
||||
@@ -1688,9 +1693,8 @@ loc_69B221:
|
||||
UpdateSpriteType();
|
||||
if (peep_flags & PEEP_FLAGS_TRACKING)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, name_string_idx);
|
||||
set_format_arg(2, uint32_t, id);
|
||||
set_format_arg(6, rct_string_id, ShopItems[shopItem].Naming.Indefinite);
|
||||
auto nameArgLen = FormatNameTo(gCommonFormatArgs);
|
||||
set_format_arg(nameArgLen, rct_string_id, ShopItems[shopItem].Naming.Indefinite);
|
||||
if (gConfigNotifications.guest_bought_item)
|
||||
{
|
||||
news_item_add_to_queue(2, STR_PEEP_TRACKING_NOTIFICATION_BOUGHT_X, sprite_index);
|
||||
@@ -4010,9 +4014,8 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride* ride)
|
||||
|
||||
if (peep_flags & PEEP_FLAGS_TRACKING)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, name_string_idx);
|
||||
set_format_arg(2, uint32_t, id);
|
||||
ride->FormatNameTo(gCommonFormatArgs + 6);
|
||||
auto nameArgLen = FormatNameTo(gCommonFormatArgs);
|
||||
ride->FormatNameTo(gCommonFormatArgs + nameArgLen);
|
||||
|
||||
rct_string_id msg_string;
|
||||
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE))
|
||||
@@ -5165,9 +5168,8 @@ void Guest::UpdateRideLeaveExit()
|
||||
|
||||
if (peep_flags & PEEP_FLAGS_TRACKING)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, name_string_idx);
|
||||
set_format_arg(2, uint32_t, id);
|
||||
ride->FormatNameTo(gCommonFormatArgs + 6);
|
||||
auto nameArgLen = FormatNameTo(gCommonFormatArgs);
|
||||
ride->FormatNameTo(gCommonFormatArgs + nameArgLen);
|
||||
|
||||
if (gConfigNotifications.guest_left_ride)
|
||||
{
|
||||
|
||||
+108
-81
@@ -79,7 +79,6 @@ static TileElement* _peepRideEntranceExitElement;
|
||||
static void* _crowdSoundChannel = nullptr;
|
||||
|
||||
static void peep_128_tick_update(Peep* peep, int32_t index);
|
||||
static void peep_give_real_name(Peep* peep);
|
||||
static void peep_release_balloon(Guest* peep, int16_t spawn_height);
|
||||
// clang-format off
|
||||
|
||||
@@ -899,8 +898,7 @@ void Peep::UpdateFalling()
|
||||
|
||||
if (gConfigNotifications.guest_died)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, name_string_idx);
|
||||
set_format_arg(2, uint32_t, id);
|
||||
FormatNameTo(gCommonFormatArgs);
|
||||
news_item_add_to_queue(NEWS_ITEM_BLANK, STR_NEWS_ITEM_GUEST_DROWNED, actionX | (actionY << 16));
|
||||
}
|
||||
|
||||
@@ -1750,7 +1748,7 @@ Peep* Peep::Generate(const CoordsXYZ coords)
|
||||
peep->no_of_rides = 0;
|
||||
std::fill_n(peep->ride_types_been_on, 16, 0x00);
|
||||
peep->id = gNextGuestNumber++;
|
||||
peep->name_string_idx = STR_GUEST_X;
|
||||
peep->name = nullptr;
|
||||
|
||||
money32 cash = (scenario_rand() & 0x3) * 100 - 100 + gGuestInitialCash;
|
||||
if (cash < 0)
|
||||
@@ -1808,10 +1806,6 @@ Peep* Peep::Generate(const CoordsXYZ coords)
|
||||
peep->energy = energy;
|
||||
peep->energy_target = energy;
|
||||
|
||||
if (gParkFlags & PARK_FLAGS_SHOW_REAL_GUEST_NAMES)
|
||||
{
|
||||
peep_give_real_name(peep);
|
||||
}
|
||||
peep_update_name_sort(peep);
|
||||
|
||||
increment_guests_heading_for_park();
|
||||
@@ -1999,6 +1993,81 @@ void Peep::FormatActionTo(void* argsV) const
|
||||
}
|
||||
}
|
||||
|
||||
size_t Peep::FormatNameTo(void* argsV) const
|
||||
{
|
||||
auto args = (uint8_t*)argsV;
|
||||
if (name == nullptr)
|
||||
{
|
||||
if (type == PeepType::PEEP_TYPE_STAFF)
|
||||
{
|
||||
static constexpr const rct_string_id staffNames[] = {
|
||||
STR_HANDYMAN_X,
|
||||
STR_MECHANIC_X,
|
||||
STR_SECURITY_GUARD_X,
|
||||
STR_ENTERTAINER_X,
|
||||
};
|
||||
|
||||
auto staffNameIndex = staff_type;
|
||||
if (staffNameIndex > sizeof(staffNames))
|
||||
{
|
||||
staffNameIndex = 0;
|
||||
}
|
||||
|
||||
set_format_arg_on(args, 0, rct_string_id, staffNames[staffNameIndex]);
|
||||
set_format_arg_on(args, 2, uint32_t, id);
|
||||
return sizeof(rct_string_id) + sizeof(uint32_t);
|
||||
}
|
||||
else if (gParkFlags & PARK_FLAGS_SHOW_REAL_GUEST_NAMES)
|
||||
{
|
||||
auto realNameStringId = get_real_name_string_id_from_id(id);
|
||||
set_format_arg_on(args, 0, rct_string_id, realNameStringId);
|
||||
return sizeof(rct_string_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_GUEST_X);
|
||||
set_format_arg_on(args, 2, uint32_t, id);
|
||||
return sizeof(rct_string_id) + sizeof(uint32_t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_STRING);
|
||||
set_format_arg_on(args, 2, const char*, name);
|
||||
return sizeof(rct_string_id) + sizeof(const char*);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Peep::GetName() const
|
||||
{
|
||||
uint8_t args[32]{};
|
||||
FormatNameTo(args);
|
||||
return format_string(STR_STRINGID, args);
|
||||
}
|
||||
|
||||
bool Peep::SetName(const std::string_view& value)
|
||||
{
|
||||
if (value.empty())
|
||||
{
|
||||
std::free(name);
|
||||
name = nullptr;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto newNameMemory = (char*)std::malloc(value.size() + 1);
|
||||
if (newNameMemory != nullptr)
|
||||
{
|
||||
std::memcpy(newNameMemory, value.data(), value.size());
|
||||
newNameMemory[value.size()] = '\0';
|
||||
std::free(name);
|
||||
name = newNameMemory;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x00698342
|
||||
* thought.item (eax)
|
||||
@@ -2181,16 +2250,14 @@ void peep_set_map_tooltip(Peep* peep)
|
||||
set_map_tooltip_format_arg(
|
||||
0, rct_string_id, (peep->peep_flags & PEEP_FLAGS_TRACKING) ? STR_TRACKED_GUEST_MAP_TIP : STR_GUEST_MAP_TIP);
|
||||
set_map_tooltip_format_arg(2, uint32_t, get_peep_face_sprite_small(peep));
|
||||
set_map_tooltip_format_arg(6, rct_string_id, peep->name_string_idx);
|
||||
set_map_tooltip_format_arg(8, uint32_t, peep->id);
|
||||
peep->FormatActionTo(gMapTooltipFormatArgs + 12);
|
||||
auto nameArgLen = peep->FormatNameTo(gMapTooltipFormatArgs + 6);
|
||||
peep->FormatActionTo(gMapTooltipFormatArgs + 6 + nameArgLen);
|
||||
}
|
||||
else
|
||||
{
|
||||
set_map_tooltip_format_arg(0, rct_string_id, STR_STAFF_MAP_TIP);
|
||||
set_map_tooltip_format_arg(2, rct_string_id, peep->name_string_idx);
|
||||
set_map_tooltip_format_arg(4, uint32_t, peep->id);
|
||||
peep->FormatActionTo(gMapTooltipFormatArgs + 8);
|
||||
auto nameArgLen = peep->FormatNameTo(gMapTooltipFormatArgs + 2);
|
||||
peep->FormatActionTo(gMapTooltipFormatArgs + 2 + nameArgLen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2392,9 +2459,8 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl
|
||||
peep->time_in_queue = 0;
|
||||
if (peep->peep_flags & PEEP_FLAGS_TRACKING)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
ride->FormatNameTo(gCommonFormatArgs + 6);
|
||||
auto nameArgLen = peep->FormatNameTo(gCommonFormatArgs);
|
||||
ride->FormatNameTo(gCommonFormatArgs + nameArgLen);
|
||||
if (gConfigNotifications.guest_queuing_for_ride)
|
||||
{
|
||||
news_item_add_to_queue(NEWS_ITEM_PEEP_ON_RIDE, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, peep->sprite_index);
|
||||
@@ -2457,8 +2523,7 @@ static void peep_interact_with_entrance(Peep* peep, int16_t x, int16_t y, TileEl
|
||||
peep->var_37 = 0;
|
||||
if (peep->peep_flags & PEEP_FLAGS_TRACKING)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
peep->FormatNameTo(gCommonFormatArgs);
|
||||
if (gConfigNotifications.guest_left_park)
|
||||
{
|
||||
news_item_add_to_queue(NEWS_ITEM_PEEP_ON_RIDE, STR_PEEP_TRACKING_LEFT_PARK, peep->sprite_index);
|
||||
@@ -2835,9 +2900,8 @@ static void peep_interact_with_path(Peep* peep, int16_t x, int16_t y, TileElemen
|
||||
peep->time_in_queue = 0;
|
||||
if (peep->peep_flags & PEEP_FLAGS_TRACKING)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
ride->FormatNameTo(gCommonFormatArgs + 6);
|
||||
auto nameArgLen = peep->FormatNameTo(gCommonFormatArgs);
|
||||
ride->FormatNameTo(gCommonFormatArgs + nameArgLen);
|
||||
if (gConfigNotifications.guest_queuing_for_ride)
|
||||
{
|
||||
news_item_add_to_queue(
|
||||
@@ -2944,9 +3008,8 @@ static bool peep_interact_with_shop(Peep* peep, int16_t x, int16_t y, TileElemen
|
||||
ride->cur_num_customers++;
|
||||
if (peep->peep_flags & PEEP_FLAGS_TRACKING)
|
||||
{
|
||||
set_format_arg(0, rct_string_id, peep->name_string_idx);
|
||||
set_format_arg(2, uint32_t, peep->id);
|
||||
ride->FormatNameTo(gCommonFormatArgs + 6);
|
||||
auto nameArgLen = peep->FormatNameTo(gCommonFormatArgs);
|
||||
ride->FormatNameTo(gCommonFormatArgs + nameArgLen);
|
||||
rct_string_id string_id = ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IN_RIDE) ? STR_PEEP_TRACKING_PEEP_IS_IN_X
|
||||
: STR_PEEP_TRACKING_PEEP_IS_ON_X;
|
||||
if (gConfigNotifications.guest_used_facility)
|
||||
@@ -3196,14 +3259,10 @@ int32_t Peep::GetZOnSlope(int32_t tile_x, int32_t tile_y)
|
||||
return height + map_height_from_slope({ tile_x, tile_y }, slope, GetNextIsSloped());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0069C483
|
||||
*/
|
||||
static void peep_give_real_name(Peep* peep)
|
||||
rct_string_id get_real_name_string_id_from_id(uint32_t id)
|
||||
{
|
||||
// Generate a name_string_idx from the peep id using bit twiddling
|
||||
uint16_t ax = (uint16_t)(peep->id + 0xF0B);
|
||||
uint16_t ax = (uint16_t)(id + 0xF0B);
|
||||
uint16_t dx = 0;
|
||||
static constexpr uint16_t twiddlingBitOrder[] = { 4, 9, 3, 7, 5, 8, 2, 1, 6, 0, 12, 11, 13, 10 };
|
||||
for (size_t i = 0; i < std::size(twiddlingBitOrder); i++)
|
||||
@@ -3220,7 +3279,7 @@ static void peep_give_real_name(Peep* peep)
|
||||
}
|
||||
dx /= 4;
|
||||
dx += REAL_NAME_START;
|
||||
peep->name_string_idx = dx;
|
||||
return dx;
|
||||
}
|
||||
|
||||
static int32_t peep_compare(const void* sprite_index_a, const void* sprite_index_b)
|
||||
@@ -3234,46 +3293,30 @@ static int32_t peep_compare(const void* sprite_index_a, const void* sprite_index
|
||||
return peep_a->type - peep_b->type;
|
||||
}
|
||||
|
||||
// Simple ID comparison for when both peeps use a number or a generated name
|
||||
const bool both_numbers
|
||||
= (peep_a->name_string_idx >= 767 && peep_a->name_string_idx <= 771 && peep_b->name_string_idx >= 767
|
||||
&& peep_b->name_string_idx <= 771);
|
||||
if (both_numbers)
|
||||
if (peep_a->name == nullptr && peep_b->name == nullptr)
|
||||
{
|
||||
return peep_a->id - peep_b->id;
|
||||
}
|
||||
const bool both_have_generated_names
|
||||
= (peep_a->name_string_idx >= REAL_NAME_START && peep_a->name_string_idx <= REAL_NAME_END
|
||||
&& peep_b->name_string_idx >= REAL_NAME_START && peep_b->name_string_idx <= REAL_NAME_END);
|
||||
if (both_have_generated_names)
|
||||
{
|
||||
rct_string_id peep_a_format = peep_a->name_string_idx + REAL_NAME_START;
|
||||
rct_string_id peep_b_format = peep_b->name_string_idx + REAL_NAME_START;
|
||||
|
||||
uint16_t peep_a_name = (peep_a_format % std::size(real_names));
|
||||
uint16_t peep_b_name = (peep_b_format % std::size(real_names));
|
||||
|
||||
if (peep_a_name == peep_b_name)
|
||||
if (gParkFlags & PARK_FLAGS_SHOW_REAL_GUEST_NAMES)
|
||||
{
|
||||
uint16_t peep_a_initial = ((peep_a_format >> 10) % std::size(real_name_initials));
|
||||
uint16_t peep_b_initial = ((peep_b_format >> 10) % std::size(real_name_initials));
|
||||
return peep_a_initial - peep_b_initial;
|
||||
// Potentially could find a more optional way of sorting dynamic real names
|
||||
}
|
||||
else
|
||||
{
|
||||
return peep_a_name - peep_b_name;
|
||||
// Simple ID comparison for when both peeps use a number or a generated name
|
||||
return peep_a->id - peep_b->id;
|
||||
}
|
||||
}
|
||||
|
||||
// At least one of them has a custom name assigned
|
||||
// Compare their names as strings
|
||||
utf8 name_a[256];
|
||||
utf8 name_b[256];
|
||||
uint32_t peepIndex = peep_a->id;
|
||||
format_string(name_a, 256, peep_a->name_string_idx, &peepIndex);
|
||||
peepIndex = peep_b->id;
|
||||
format_string(name_b, 256, peep_b->name_string_idx, &peepIndex);
|
||||
return strlogicalcmp(name_a, name_b);
|
||||
uint8_t args[32]{};
|
||||
|
||||
char nameA[256]{};
|
||||
peep_a->FormatNameTo(args);
|
||||
format_string(nameA, sizeof(nameA), STR_STRINGID, args);
|
||||
|
||||
char nameB[256]{};
|
||||
peep_b->FormatNameTo(args);
|
||||
format_string(nameB, sizeof(nameB), STR_STRINGID, args);
|
||||
return strlogicalcmp(nameA, nameB);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3401,28 +3444,12 @@ void peep_update_names(bool realNames)
|
||||
if (realNames)
|
||||
{
|
||||
gParkFlags |= PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
Peep* peep;
|
||||
uint16_t spriteIndex;
|
||||
FOR_ALL_GUESTS (spriteIndex, peep)
|
||||
{
|
||||
if (peep->name_string_idx == STR_GUEST_X)
|
||||
{
|
||||
peep_give_real_name(peep);
|
||||
}
|
||||
}
|
||||
// Peep names are now dynamic
|
||||
}
|
||||
else
|
||||
{
|
||||
gParkFlags &= ~PARK_FLAGS_SHOW_REAL_GUEST_NAMES;
|
||||
Peep* peep;
|
||||
uint16_t spriteIndex;
|
||||
FOR_ALL_GUESTS (spriteIndex, peep)
|
||||
{
|
||||
if (peep->name_string_idx >= REAL_NAME_START && peep->name_string_idx <= REAL_NAME_END)
|
||||
{
|
||||
peep->name_string_idx = STR_GUEST_X;
|
||||
}
|
||||
}
|
||||
// Peep names are now dynamic
|
||||
}
|
||||
|
||||
peep_sort();
|
||||
|
||||
@@ -538,7 +538,7 @@ struct Staff;
|
||||
|
||||
struct Peep : rct_sprite_common
|
||||
{
|
||||
rct_string_id name_string_idx; // 0x22
|
||||
char* name;
|
||||
uint16_t next_x; // 0x24
|
||||
uint16_t next_y; // 0x26
|
||||
uint8_t next_z; // 0x28
|
||||
@@ -719,6 +719,9 @@ public: // Peep
|
||||
void RemoveFromRide();
|
||||
void InsertNewThought(PeepThoughtType thought_type, uint8_t thought_arguments);
|
||||
void FormatActionTo(void* args) const;
|
||||
size_t FormatNameTo(void* args) const;
|
||||
std::string GetName() const;
|
||||
bool SetName(const std::string_view& value);
|
||||
|
||||
// TODO: Make these private again when done refactoring
|
||||
public: // Peep
|
||||
@@ -852,6 +855,8 @@ private:
|
||||
void UpdateHeadingToInspect();
|
||||
};
|
||||
|
||||
static_assert(sizeof(Peep) <= 256);
|
||||
|
||||
struct rct_sprite_bounds
|
||||
{
|
||||
uint8_t sprite_width; // 0x00
|
||||
@@ -1002,4 +1007,6 @@ void increment_guests_heading_for_park();
|
||||
void decrement_guests_in_park();
|
||||
void decrement_guests_heading_for_park();
|
||||
|
||||
rct_string_id get_real_name_string_id_from_id(uint32_t id);
|
||||
|
||||
#endif
|
||||
@@ -1432,18 +1432,9 @@ private:
|
||||
dst->sprite_direction = src->sprite_direction;
|
||||
|
||||
// Peep name
|
||||
dst->name_string_idx = src->name_string_idx;
|
||||
if (is_user_string_id(src->name_string_idx))
|
||||
{
|
||||
std::string peepName = GetUserString(src->name_string_idx);
|
||||
if (!peepName.empty())
|
||||
{
|
||||
rct_string_id peepNameStringId = user_string_allocate(USER_STRING_HIGH_ID_NUMBER, peepName.c_str());
|
||||
if (peepNameStringId != 0)
|
||||
{
|
||||
dst->name_string_idx = peepNameStringId;
|
||||
}
|
||||
}
|
||||
dst->SetName(GetUserString(src->name_string_idx));
|
||||
}
|
||||
|
||||
dst->outside_of_park = src->outside_of_park;
|
||||
|
||||
@@ -983,7 +983,39 @@ void S6Exporter::ExportSpriteVehicle(RCT2SpriteVehicle* dst, const rct_vehicle*
|
||||
void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src)
|
||||
{
|
||||
ExportSpriteCommonProperties(dst, (const rct_sprite_common*)src);
|
||||
dst->name_string_idx = src->name_string_idx;
|
||||
|
||||
auto generateName = true;
|
||||
if (src->name != nullptr)
|
||||
{
|
||||
auto stringId = user_string_allocate(USER_STRING_DUPLICATION_PERMITTED, src->name);
|
||||
if (stringId != 0)
|
||||
{
|
||||
dst->name_string_idx = stringId;
|
||||
generateName = false;
|
||||
}
|
||||
}
|
||||
if (generateName)
|
||||
{
|
||||
if (src->type == PeepType::PEEP_TYPE_STAFF)
|
||||
{
|
||||
static constexpr const rct_string_id staffNames[] = {
|
||||
STR_HANDYMAN_X,
|
||||
STR_MECHANIC_X,
|
||||
STR_SECURITY_GUARD_X,
|
||||
STR_ENTERTAINER_X,
|
||||
};
|
||||
dst->name_string_idx = staffNames[src->staff_type % sizeof(staffNames)];
|
||||
}
|
||||
else if (gParkFlags & PARK_FLAGS_SHOW_REAL_GUEST_NAMES)
|
||||
{
|
||||
dst->name_string_idx = get_real_name_string_id_from_id(src->id);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst->name_string_idx = STR_GUEST_X;
|
||||
}
|
||||
}
|
||||
|
||||
dst->next_x = src->next_x;
|
||||
dst->next_y = src->next_y;
|
||||
dst->next_z = src->next_z;
|
||||
|
||||
@@ -1296,7 +1296,10 @@ public:
|
||||
void ImportSpritePeep(Peep* dst, const RCT2SpritePeep* src)
|
||||
{
|
||||
ImportSpriteCommonProperties((rct_sprite_common*)dst, src);
|
||||
dst->name_string_idx = src->name_string_idx;
|
||||
if (is_user_string_id(src->name_string_idx))
|
||||
{
|
||||
dst->SetName(GetUserString(src->name_string_idx));
|
||||
}
|
||||
dst->next_x = src->next_x;
|
||||
dst->next_y = src->next_y;
|
||||
dst->next_z = src->next_z;
|
||||
|
||||
+37
-64
@@ -835,80 +835,63 @@ int32_t ride_find_track_gap(const Ride* ride, CoordsXYE* input, CoordsXYE* outpu
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006AF561
|
||||
*/
|
||||
void ride_get_status(const Ride* ride, rct_string_id* formatSecondary, int32_t* argument)
|
||||
void Ride::FormatStatusTo(void* argsV) const
|
||||
{
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_CRASHED)
|
||||
{
|
||||
*formatSecondary = STR_CRASHED;
|
||||
return;
|
||||
}
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)
|
||||
{
|
||||
*formatSecondary = STR_BROKEN_DOWN;
|
||||
return;
|
||||
}
|
||||
if (ride->status == RIDE_STATUS_CLOSED)
|
||||
{
|
||||
*formatSecondary = STR_CLOSED;
|
||||
auto args = (uint8_t*)argsV;
|
||||
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP))
|
||||
if (lifecycle_flags & RIDE_LIFECYCLE_CRASHED)
|
||||
{
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_CRASHED);
|
||||
}
|
||||
else if (lifecycle_flags & RIDE_LIFECYCLE_BROKEN_DOWN)
|
||||
{
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_BROKEN_DOWN);
|
||||
}
|
||||
else if (status == RIDE_STATUS_CLOSED)
|
||||
{
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_CLOSED);
|
||||
if (!ride_type_has_flag(type, RIDE_TYPE_FLAG_IS_SHOP))
|
||||
{
|
||||
*argument = ride->num_riders;
|
||||
|
||||
if (*argument == 1)
|
||||
if (num_riders != 0)
|
||||
{
|
||||
*formatSecondary = STR_CLOSED_WITH_PERSON;
|
||||
}
|
||||
else if (*argument > 1)
|
||||
{
|
||||
*formatSecondary = STR_CLOSED_WITH_PEOPLE;
|
||||
set_format_arg_on(args, 0, rct_string_id, num_riders == 1 ? STR_CLOSED_WITH_PERSON : STR_CLOSED_WITH_PEOPLE);
|
||||
set_format_arg_on(args, 2, uint16_t, num_riders);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (ride->status == RIDE_STATUS_SIMULATING)
|
||||
else if (status == RIDE_STATUS_SIMULATING)
|
||||
{
|
||||
*formatSecondary = STR_SIMULATING;
|
||||
return;
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_SIMULATING);
|
||||
}
|
||||
else if (ride->status == RIDE_STATUS_TESTING)
|
||||
else if (status == RIDE_STATUS_TESTING)
|
||||
{
|
||||
*formatSecondary = STR_TEST_RUN;
|
||||
return;
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_TEST_RUN);
|
||||
}
|
||||
if (ride->mode == RIDE_MODE_RACE && !(ride->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING)
|
||||
&& ride->race_winner != SPRITE_INDEX_NULL && (GET_PEEP(ride->race_winner))->sprite_identifier == SPRITE_IDENTIFIER_PEEP)
|
||||
else if (
|
||||
mode == RIDE_MODE_RACE && !(lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING)
|
||||
&& race_winner != SPRITE_INDEX_NULL)
|
||||
{
|
||||
Peep* peep = GET_PEEP(ride->race_winner);
|
||||
if (peep->name_string_idx == STR_GUEST_X)
|
||||
auto sprite = get_sprite(race_winner);
|
||||
if (sprite != nullptr)
|
||||
{
|
||||
*argument = peep->id;
|
||||
*formatSecondary = STR_RACE_WON_BY_GUEST;
|
||||
auto peep = sprite->AsPeep();
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_RACE_WON_BY);
|
||||
peep->FormatNameTo(args + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
*argument = peep->name_string_idx;
|
||||
*formatSecondary = STR_RACE_WON_BY;
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_RACE_WON_BY);
|
||||
set_format_arg_on(args, 2, rct_string_id, STR_NONE);
|
||||
}
|
||||
}
|
||||
else if (!ride_type_has_flag(type, RIDE_TYPE_FLAG_IS_SHOP))
|
||||
{
|
||||
set_format_arg_on(args, 0, rct_string_id, num_riders == 1 ? STR_PERSON_ON_RIDE : STR_PEOPLE_ON_RIDE);
|
||||
set_format_arg_on(args, 2, uint16_t, num_riders);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP))
|
||||
{
|
||||
*argument = ride->num_riders;
|
||||
*formatSecondary = STR_PERSON_ON_RIDE;
|
||||
if (*argument != 1)
|
||||
*formatSecondary = STR_PEOPLE_ON_RIDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
*formatSecondary = STR_OPEN;
|
||||
}
|
||||
set_format_arg_on(args, 0, rct_string_id, STR_OPEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7948,13 +7931,3 @@ size_t Ride::FormatNameTo(void* argsV) const
|
||||
return sizeof(rct_string_id) + sizeof(rct_string_id) + sizeof(uint16_t);
|
||||
}
|
||||
}
|
||||
|
||||
void Ride::FormatStatusTo(void* argsV) const
|
||||
{
|
||||
auto args = (uint8_t*)argsV;
|
||||
rct_string_id stringId{};
|
||||
int32_t arg32{};
|
||||
ride_get_status(this, &stringId, &arg32);
|
||||
set_format_arg_on(args, 0, rct_string_id, stringId);
|
||||
set_format_arg_on(args, 2, uint32_t, arg32);
|
||||
}
|
||||
@@ -1054,7 +1054,6 @@ void ride_construct(Ride* ride);
|
||||
int32_t ride_modify(CoordsXYE* input);
|
||||
void ride_remove_peeps(Ride* ride);
|
||||
void ride_clear_blocked_tiles(Ride* ride);
|
||||
void ride_get_status(const Ride* ride, rct_string_id* formatSecondary, int32_t* argument);
|
||||
Staff* ride_get_mechanic(Ride* ride);
|
||||
Staff* ride_get_assigned_mechanic(Ride* ride);
|
||||
int32_t ride_get_total_length(Ride* ride);
|
||||
|
||||
@@ -679,7 +679,7 @@ void sprite_remove(rct_sprite* sprite)
|
||||
auto peep = sprite->AsPeep();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
user_string_free(peep->name_string_idx);
|
||||
peep->SetName({});
|
||||
}
|
||||
|
||||
move_sprite_to_list(sprite, SPRITE_LIST_FREE);
|
||||
|
||||
Reference in new issue
Block a user