| 169 | } |
| 170 | |
| 171 | static bool canIndustryObjBeCreated(const IndustryObject& indObj) |
| 172 | { |
| 173 | if (getCurrentYear() < indObj.designedYear) |
| 174 | { |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | if (getCurrentYear() >= indObj.obsoleteYear) |
| 179 | { |
| 180 | return false; |
| 181 | } |
| 182 | |
| 183 | // If industry is a self producer i.e. no requirements to produce |
| 184 | if (indObj.requiredCargoType[0] == 0xFF) |
| 185 | { |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | if (indObj.hasFlags(IndustryObjectFlags::requiresAllCargo)) |
| 190 | { |
| 191 | // All required cargo must be producable in world |
| 192 | for (auto i = 0; i < 3; ++i) |
| 193 | { |
| 194 | if (indObj.requiredCargoType[i] == 0xFF) |
| 195 | { |
| 196 | continue; |
| 197 | } |
| 198 | if (!canCargoTypeBeProducedInWorld(indObj.requiredCargoType[i])) |
| 199 | { |
| 200 | return false; |
| 201 | } |
| 202 | } |
| 203 | return true; |
| 204 | } |
| 205 | else |
| 206 | { |
| 207 | // At least one required cargo must be producable in world |
| 208 | for (auto i = 0; i < 3; ++i) |
| 209 | { |
| 210 | if (indObj.requiredCargoType[i] == 0xFF) |
| 211 | { |
| 212 | continue; |
| 213 | } |
| 214 | if (canCargoTypeBeProducedInWorld(indObj.requiredCargoType[i])) |
| 215 | { |
| 216 | return true; |
| 217 | } |
| 218 | } |
| 219 | return false; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // 0x00459A05 |
| 224 | static bool isTooCloseToNearbyIndustries(const World::Pos2& loc) |
no test coverage detected