0x00497348
| 357 | |
| 358 | // 0x00497348 |
| 359 | void resetBuildingsInfluence() |
| 360 | { |
| 361 | for (auto& town : towns()) |
| 362 | { |
| 363 | town.numBuildings = 0; |
| 364 | town.population = 0; |
| 365 | town.populationCapacity = 0; |
| 366 | std::fill(std::begin(town.amenityCounts), std::end(town.amenityCounts), 0); |
| 367 | } |
| 368 | |
| 369 | for (const auto& tilePos : World::getWorldRange()) |
| 370 | { |
| 371 | auto tile = World::TileManager::get(tilePos); |
| 372 | for (auto& element : tile) |
| 373 | { |
| 374 | auto* building = element.as<World::BuildingElement>(); |
| 375 | if (building == nullptr) |
| 376 | { |
| 377 | continue; |
| 378 | } |
| 379 | |
| 380 | if (building->isGhost()) |
| 381 | { |
| 382 | continue; |
| 383 | } |
| 384 | |
| 385 | if (building->isMiscBuilding()) |
| 386 | { |
| 387 | continue; |
| 388 | } |
| 389 | |
| 390 | if (building->sequenceIndex() != 0) |
| 391 | { |
| 392 | continue; |
| 393 | } |
| 394 | |
| 395 | auto objectId = building->objectId(); |
| 396 | auto* buildingObj = ObjectManager::get<BuildingObject>(objectId); |
| 397 | auto producedQuantity = buildingObj->producedQuantity[0]; |
| 398 | uint32_t population; |
| 399 | if (!building->isConstructed()) |
| 400 | { |
| 401 | population = 0; |
| 402 | } |
| 403 | else |
| 404 | { |
| 405 | population = producedQuantity; |
| 406 | } |
| 407 | auto* town = updateTownInfo(World::toWorldSpace(tilePos), population, producedQuantity, 0, 1); |
| 408 | if (town != nullptr) |
| 409 | { |
| 410 | if (buildingObj->townAmenityCategory != TownAmenityCategory::none) |
| 411 | { |
| 412 | town->amenityCounts[enumValue(buildingObj->townAmenityCategory)] += 1; |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | } |
no test coverage detected