0x00456EEB
| 289 | |
| 290 | // 0x00456EEB |
| 291 | bool updateIndustryAnimation2(const Animation& anim) |
| 292 | { |
| 293 | auto tile = TileManager::get(anim.pos); |
| 294 | for (auto& el : tile) |
| 295 | { |
| 296 | auto* elIndustry = el.as<IndustryElement>(); |
| 297 | if (elIndustry == nullptr) |
| 298 | { |
| 299 | continue; |
| 300 | } |
| 301 | if (elIndustry->baseZ() != anim.baseZ) |
| 302 | { |
| 303 | continue; |
| 304 | } |
| 305 | if (!(elIndustry->var_6_003F() & (1 << 5))) |
| 306 | { |
| 307 | continue; |
| 308 | } |
| 309 | |
| 310 | auto* industry = elIndustry->industry(); |
| 311 | const auto* indObj = industry->getObject(); |
| 312 | const auto type = elIndustry->buildingType(); |
| 313 | const auto buildingParts = indObj->getBuildingParts(type); |
| 314 | const auto buildingPartAnims = indObj->getBuildingPartAnimations(); |
| 315 | // Guaranteed power of 2 |
| 316 | auto animLength = indObj->getAnimationSequence(elIndustry->var_6_003F() & 0x3).size(); |
| 317 | const auto isMultiTile = indObj->buildingSizeFlags & (1 << type); |
| 318 | |
| 319 | for (auto& part : buildingParts) |
| 320 | { |
| 321 | auto& partAnim = buildingPartAnims[part]; |
| 322 | if (partAnim.numFrames == 0) |
| 323 | { |
| 324 | const auto animSpeed = partAnim.animationSpeed & ~(1 << 7); |
| 325 | const auto speedMask = animLength - 1; |
| 326 | if (elIndustry->var_6_003F() & (1 << 4)) |
| 327 | { |
| 328 | if ((speedMask & (ScenarioManager::getScenarioTicks() >> animSpeed)) == 0) |
| 329 | { |
| 330 | applyToMultiTile(*elIndustry, anim.pos, isMultiTile, [](World::IndustryElement& elIndustry, const World::Pos2& pos) { |
| 331 | Ui::ViewportManager::invalidate(pos, elIndustry.baseHeight(), elIndustry.clearHeight(), ZoomLevel::quarter); |
| 332 | elIndustry.setVar_6_003F(elIndustry.var_6_003F() & ~(1 << 5)); |
| 333 | }); |
| 334 | return true; |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | const auto speedMask2 = (1 << animSpeed) - 1; |
| 339 | if (!(speedMask2 & ScenarioManager::getScenarioTicks())) |
| 340 | { |
| 341 | applyToMultiTile(*elIndustry, anim.pos, isMultiTile, [](World::IndustryElement& elIndustry, const World::Pos2& pos) { |
| 342 | Ui::ViewportManager::invalidate(pos, elIndustry.baseHeight(), elIndustry.clearHeight(), ZoomLevel::quarter); |
| 343 | }); |
| 344 | } |
| 345 | return false; |
| 346 | } |
| 347 | } |
| 348 | else |
no test coverage detected