forked from mirror/OpenTTD
Codechange: use std::string to cache engine/group/vehicle names
This commit is contained in:
@@ -145,19 +145,18 @@ static EngineID _last_engine[2] = { INVALID_ENGINE, INVALID_ENGINE };
|
||||
*/
|
||||
static bool EngineNameSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
|
||||
{
|
||||
static char last_name[2][64] = { "", "" };
|
||||
static std::string last_name[2] = { {}, {} };
|
||||
|
||||
if (a.engine_id != _last_engine[0]) {
|
||||
_last_engine[0] = a.engine_id;
|
||||
SetDParam(0, PackEngineNameDParam(a.engine_id, EngineNameContext::PurchaseList));
|
||||
|
||||
GetString(last_name[0], STR_ENGINE_NAME, lastof(last_name[0]));
|
||||
last_name[0] = GetString(STR_ENGINE_NAME);
|
||||
}
|
||||
|
||||
if (b.engine_id != _last_engine[1]) {
|
||||
_last_engine[1] = b.engine_id;
|
||||
SetDParam(0, PackEngineNameDParam(b.engine_id, EngineNameContext::PurchaseList));
|
||||
GetString(last_name[1], STR_ENGINE_NAME, lastof(last_name[1]));
|
||||
last_name[1] = GetString(STR_ENGINE_NAME);
|
||||
}
|
||||
|
||||
int r = StrNaturalCompare(last_name[0], last_name[1]); // Sort by name (natural sorting).
|
||||
|
Reference in New Issue
Block a user