| 163 | } |
| 164 | |
| 165 | bool SWTypeExt::ExtData::IsAvailable(HouseClass* pHouse) const |
| 166 | { |
| 167 | const auto pThis = this->OwnerObject(); |
| 168 | |
| 169 | // check whether the optional aux building exists |
| 170 | if (pThis->AuxBuilding && pHouse->CountOwnedAndPresent(pThis->AuxBuilding) <= 0) |
| 171 | return false; |
| 172 | |
| 173 | // allow only certain houses, disallow forbidden houses |
| 174 | const auto OwnerBits = 1u << pHouse->Type->ArrayIndex; |
| 175 | |
| 176 | if (!(this->SW_RequiredHouses & OwnerBits) || (this->SW_ForbiddenHouses & OwnerBits)) |
| 177 | return false; |
| 178 | |
| 179 | // check that any aux building exist and no neg building |
| 180 | auto IsBuildingPresent = [pHouse](BuildingTypeClass* pType) |
| 181 | { |
| 182 | return pType && pHouse->CountOwnedAndPresent(pType) > 0; |
| 183 | }; |
| 184 | |
| 185 | const auto& Aux = this->SW_AuxBuildings; |
| 186 | |
| 187 | if (!Aux.empty() && std::none_of(Aux.begin(), Aux.end(), IsBuildingPresent)) |
| 188 | return false; |
| 189 | |
| 190 | const auto& Neg = this->SW_NegBuildings; |
| 191 | |
| 192 | if (std::any_of(Neg.begin(), Neg.end(), IsBuildingPresent)) |
| 193 | return false; |
| 194 | |
| 195 | return true; |
| 196 | } |
| 197 | |
| 198 | std::vector<BuildingClass*> SWTypeExt::ExtData::GetEMPulseCannons(HouseClass* pOwner, const CellStruct& cell) const |
| 199 | { |
no test coverage detected