Codechange: replace strnatcmp with C++ string capable version

This commit is contained in:
Rubidium
2023-04-27 15:39:10 +02:00
committed by rubidium42
parent df19673fbd
commit c829930440
22 changed files with 47 additions and 54 deletions

View File

@@ -156,13 +156,10 @@ span<const CargoSpec *> _sorted_standard_cargo_specs; ///< Standard cargo specif
/** Sort cargo specifications by their name. */
static bool CargoSpecNameSorter(const CargoSpec * const &a, const CargoSpec * const &b)
{
static char a_name[64];
static char b_name[64];
std::string a_name = GetString(a->name);
std::string b_name = GetString(b->name);
GetString(a_name, a->name, lastof(a_name));
GetString(b_name, b->name, lastof(b_name));
int res = strnatcmp(a_name, b_name); // Sort by name (natural sorting).
int res = StrNaturalCompare(a_name, b_name); // Sort by name (natural sorting).
/* If the names are equal, sort by cargo bitnum. */
return (res != 0) ? res < 0 : (a->bitnum < b->bitnum);