* Get the cargo types produced by a house. * @param hs HouseSpec of the house. * @returns Mask of cargo types produced by the house. */
| 1618 | * @returns Mask of cargo types produced by the house. |
| 1619 | */ |
| 1620 | static 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 | |
| 1645 | struct BuildHouseWindow : public PickerWindow { |
| 1646 | std::string house_info{}; |
no test coverage detected