MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / resetBuildingsInfluence

Function resetBuildingsInfluence

src/OpenLoco/src/World/TownManager.cpp:359–418  ·  view source on GitHub ↗

0x00497348

Source from the content-addressed store, hash-verified

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 }

Callers 2

initialiseTownFunction · 0.85
removeTownFunction · 0.85

Calls 14

townsFunction · 0.85
beginFunction · 0.85
endFunction · 0.85
getWorldRangeFunction · 0.85
updateTownInfoFunction · 0.85
toWorldSpaceFunction · 0.85
enumValueFunction · 0.85
invalidateScreenFunction · 0.85
isMiscBuildingMethod · 0.80
getFunction · 0.70
isGhostMethod · 0.45
sequenceIndexMethod · 0.45

Tested by

no test coverage detected