Codechange: use std::string to cache engine/group/vehicle names

This commit is contained in:
Rubidium
2023-05-31 18:02:50 +02:00
committed by rubidium42
parent d9f8a4c380
commit f29606fd14
4 changed files with 12 additions and 13 deletions

View File

@@ -1332,18 +1332,18 @@ static bool VehicleNumberSorter(const Vehicle * const &a, const Vehicle * const
/** Sort vehicles by their name */
static bool VehicleNameSorter(const Vehicle * const &a, const Vehicle * const &b)
{
static char last_name[2][64];
static std::string last_name[2] = { {}, {} };
if (a != _last_vehicle[0]) {
_last_vehicle[0] = a;
SetDParam(0, a->index);
GetString(last_name[0], STR_VEHICLE_NAME, lastof(last_name[0]));
last_name[0] = GetString(STR_VEHICLE_NAME);
}
if (b != _last_vehicle[1]) {
_last_vehicle[1] = b;
SetDParam(0, b->index);
GetString(last_name[1], STR_VEHICLE_NAME, lastof(last_name[1]));
last_name[1] = GetString(STR_VEHICLE_NAME);
}
int r = StrNaturalCompare(last_name[0], last_name[1]); // Sort by name (natural sorting).