MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / MakeCargoListString

Method MakeCargoListString

src/industry_gui.cpp:366–383  ·  view source on GitHub ↗

* Build a string of cargo names with suffixes attached. * This is distinct from the CARGO_LIST string formatting code in two ways: * - This cargo list uses the order defined by the industry, rather than alphabetic. * - NewGRF-supplied suffix strings can be attached to each cargo. * * @param cargolist Array of CargoType to display * @param cargo_suffix Array of suffixes to attach t

Source from the content-addressed store, hash-verified

364 * @return A formatted raw string
365 */
366 std::string MakeCargoListString(const std::span<const CargoType> cargolist, const std::span<const CargoSuffix> cargo_suffix, StringID prefixstr) const
367 {
368 assert(cargolist.size() == cargo_suffix.size());
369
370 std::string cargostring;
371 std::string_view list_separator = GetListSeparator();
372
373 for (size_t j = 0; j < cargolist.size(); j++) {
374 if (!IsValidCargoType(cargolist[j])) continue;
375
376 if (!cargostring.empty()) cargostring += list_separator;
377 auto params = MakeParameters(CargoSpec::Get(cargolist[j])->name, cargo_suffix[j].text);
378 AppendStringWithArgsInPlace(cargostring, STR_INDUSTRY_VIEW_CARGO_LIST_EXTENSION, params);
379 }
380
381 if (cargostring.empty()) AppendStringInPlace(cargostring, STR_JUST_NOTHING);
382 return GetString(prefixstr, cargostring);
383 }
384
385public:
386 BuildIndustryWindow() : Window(_build_industry_desc)

Callers 2

UpdateWidgetSizeMethod · 0.95
DrawWidgetMethod · 0.95

Calls 8

GetListSeparatorFunction · 0.85
IsValidCargoTypeFunction · 0.85
MakeParametersFunction · 0.85
AppendStringInPlaceFunction · 0.85
GetStringFunction · 0.70
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected