Fix: Use clear() to clear std::string. (#12471)

This commit is contained in:
Peter Nelson 2024-04-10 18:27:30 +01:00 committed by GitHub
parent 21b640b5ff
commit 144bcbbaf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -165,14 +165,14 @@ static inline void GetAllCargoSuffixes(CargoSuffixInOut use_input, CargoSuffixTy
uint cargotype = local_id << 16 | use_input; uint cargotype = local_id << 16 | use_input;
GetCargoSuffix(cargotype, cst, ind, ind_type, indspec, suffixes[j]); GetCargoSuffix(cargotype, cst, ind, ind_type, indspec, suffixes[j]);
} else { } else {
suffixes[j].text[0] = '\0'; suffixes[j].text.clear();
suffixes[j].display = CSD_CARGO; suffixes[j].display = CSD_CARGO;
} }
} }
} else { } else {
/* Compatible behaviour with old 3-in-2-out scheme */ /* Compatible behaviour with old 3-in-2-out scheme */
for (uint j = 0; j < lengthof(suffixes); j++) { for (uint j = 0; j < lengthof(suffixes); j++) {
suffixes[j].text[0] = '\0'; suffixes[j].text.clear();
suffixes[j].display = CSD_CARGO; suffixes[j].display = CSD_CARGO;
} }
switch (use_input) { switch (use_input) {
@ -204,7 +204,7 @@ static inline void GetAllCargoSuffixes(CargoSuffixInOut use_input, CargoSuffixTy
*/ */
void GetCargoSuffix(CargoSuffixInOut use_input, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, CargoID cargo, uint8_t slot, CargoSuffix &suffix) void GetCargoSuffix(CargoSuffixInOut use_input, CargoSuffixType cst, const Industry *ind, IndustryType ind_type, const IndustrySpec *indspec, CargoID cargo, uint8_t slot, CargoSuffix &suffix)
{ {
suffix.text[0] = '\0'; suffix.text.clear();
suffix.display = CSD_CARGO; suffix.display = CSD_CARGO;
if (!IsValidCargoID(cargo)) return; if (!IsValidCargoID(cargo)) return;
if (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) { if (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) {