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

Method GetHouseInformation

src/town_gui.cpp:1700–1733  ·  view source on GitHub ↗

* Get information string for a house. * @param hs HouseSpec to get information string for. * @return Formatted string with information for house. */

Source from the content-addressed store, hash-verified

1698 * @return Formatted string with information for house.
1699 */
1700 static std::string GetHouseInformation(const HouseSpec *hs)
1701 {
1702 std::stringstream line;
1703
1704 line << GetString(STR_HOUSE_PICKER_NAME, GetHouseName(hs));
1705 line << "\n";
1706
1707 line << GetString(STR_HOUSE_PICKER_POPULATION, hs->population);
1708 line << "\n";
1709
1710 line << GetHouseYear(hs->min_year, hs->max_year);
1711 line << "\n";
1712
1713 uint8_t size = 0;
1714 if (hs->building_flags.Test(BuildingFlag::Size1x1)) size = 0x11;
1715 if (hs->building_flags.Test(BuildingFlag::Size2x1)) size = 0x21;
1716 if (hs->building_flags.Test(BuildingFlag::Size1x2)) size = 0x12;
1717 if (hs->building_flags.Test(BuildingFlag::Size2x2)) size = 0x22;
1718 line << GetString(STR_HOUSE_PICKER_SIZE, GB(size, 0, 4), GB(size, 4, 4));
1719
1720 auto cargo_string = BuildCargoAcceptanceString(GetAcceptedCargoOfHouse(hs), STR_HOUSE_PICKER_CARGO_ACCEPTED);
1721 if (cargo_string.has_value()) {
1722 line << "\n";
1723 line << *cargo_string;
1724 }
1725
1726 CargoTypes produced = GetProducedCargoOfHouse(hs);
1727 if (produced != 0) {
1728 line << "\n";
1729 line << GetString(STR_HOUSE_PICKER_CARGO_PRODUCED, produced);
1730 }
1731
1732 return line.str();
1733 }
1734
1735 void OnInit() override
1736 {

Callers

nothing calls this directly

Calls 8

GetHouseNameFunction · 0.85
GBFunction · 0.85
GetAcceptedCargoOfHouseFunction · 0.85
GetProducedCargoOfHouseFunction · 0.85
TestMethod · 0.80
GetStringFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected