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

Function GetProducedCargoOfHouse

src/town_gui.cpp:1620–1643  ·  view source on GitHub ↗

* Get the cargo types produced by a house. * @param hs HouseSpec of the house. * @returns Mask of cargo types produced by the house. */

Source from the content-addressed store, hash-verified

1618 * @returns Mask of cargo types produced by the house.
1619 */
1620static CargoTypes GetProducedCargoOfHouse(const HouseSpec *hs)
1621{
1622 CargoTypes produced{};
1623 if (hs->callback_mask.Test(HouseCallbackMask::ProduceCargo)) {
1624 for (uint i = 0; i < 256; i++) {
1625 uint16_t callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, 0, hs->Index(), nullptr, INVALID_TILE, {}, true);
1626
1627 if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break;
1628
1629 CargoType cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grf_prop.grffile);
1630 if (!IsValidCargoType(cargo)) continue;
1631
1632 uint amt = GB(callback, 0, 8);
1633 if (amt == 0) continue;
1634
1635 SetBit(produced, cargo);
1636 }
1637 } else {
1638 /* Cargo is not controlled by NewGRF, town production effect is used instead. */
1639 for (const CargoSpec *cs : CargoSpec::town_production_cargoes[TPE_PASSENGERS]) SetBit(produced, cs->Index());
1640 for (const CargoSpec *cs : CargoSpec::town_production_cargoes[TPE_MAIL]) SetBit(produced, cs->Index());
1641 }
1642 return produced;
1643}
1644
1645struct BuildHouseWindow : public PickerWindow {
1646 std::string house_info{};

Callers 1

GetHouseInformationMethod · 0.85

Calls 7

GetHouseCallbackFunction · 0.85
GetCargoTranslationFunction · 0.85
GBFunction · 0.85
IsValidCargoTypeFunction · 0.85
SetBitFunction · 0.85
TestMethod · 0.80
IndexMethod · 0.45

Tested by

no test coverage detected