diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index ecda60450b..b22218dbe8 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -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). diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 23967879fd..6a4d6b457b 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -721,18 +721,18 @@ private: /* Sort the groups by their name */ const Group *last_group[2] = { nullptr, nullptr }; - char last_name[2][64] = { "", "" }; + std::string last_name[2] = { {}, {} }; list.Sort([&](const Group * const &a, const Group * const &b) -> bool { if (a != last_group[0]) { last_group[0] = a; SetDParam(0, a->index); - GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0])); + last_name[0] = GetString(STR_GROUP_NAME); } if (b != last_group[1]) { last_group[1] = b; SetDParam(0, b->index); - GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[1])); + last_name[1] = GetString(STR_GROUP_NAME); } int r = StrNaturalCompare(last_name[0], last_name[1]); // Sort by name (natural sorting). diff --git a/src/group_gui.cpp b/src/group_gui.cpp index d2ddf10b0e..38c719e7e1 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -177,18 +177,18 @@ private: /* Sort the groups by their name */ const Group *last_group[2] = { nullptr, nullptr }; - char last_name[2][64] = { "", "" }; + std::string last_name[2] = { {}, {} }; list.Sort([&](const Group * const &a, const Group * const &b) { if (a != last_group[0]) { last_group[0] = a; SetDParam(0, a->index); - GetString(last_name[0], STR_GROUP_NAME, lastof(last_name[0])); + last_name[0] = GetString(STR_GROUP_NAME); } if (b != last_group[1]) { last_group[1] = b; SetDParam(0, b->index); - GetString(last_name[1], STR_GROUP_NAME, lastof(last_name[1])); + last_name[1] = GetString(STR_GROUP_NAME); } int r = StrNaturalCompare(last_name[0], last_name[1]); // Sort by name (natural sorting). diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 240083e211..7e16099f1d 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -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).