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

Method update

src/OpenLoco/src/Map/BuildingElement.cpp:61–192  ·  view source on GitHub ↗

0x0042DF8B

Source from the content-addressed store, hash-verified

59
60 // 0x0042DF8B
61 bool BuildingElement::update(const World::Pos2& loc)
62 {
63 // Only update from tile index 0 of multi tile buildings
64 if (sequenceIndex())
65 {
66 return true;
67 }
68
69 if (isGhost())
70 {
71 return true;
72 }
73
74 const auto* buildingObj = getObject();
75 const auto isMultiTile = buildingObj->hasFlags(BuildingObjectFlags::largeTile);
76
77 if (!isConstructed())
78 {
79 auto newUnk5u = unk5u();
80 auto newAge = age();
81 auto isConstructed = false;
82 if (unk5u() != 7)
83 {
84 newUnk5u++;
85 }
86 else
87 {
88 auto parts = buildingObj->getBuildingParts(variation());
89 if (static_cast<uint32_t>(age() + 1) != parts.size())
90 {
91 newUnk5u = 0;
92 newAge++;
93 }
94 else
95 {
96 auto totalHeight = 3;
97 const auto partHeights = buildingObj->getBuildingPartHeights();
98 for (auto part : parts)
99 {
100 totalHeight += partHeights[part];
101 }
102
103 const auto newClearHeight = baseZ() + totalHeight / 4;
104
105 applyToMultiTile(*this, loc, isMultiTile, [newClearHeight](World::BuildingElement& elBuilding2, const World::Pos2& pos) {
106 Ui::ViewportManager::invalidate(pos, elBuilding2.baseHeight(), elBuilding2.clearHeight(), ZoomLevel::quarter);
107 elBuilding2.setClearZ(newClearHeight);
108 });
109
110 if (buildingObj->numElevatorSequences != 0)
111 {
112 AnimationManager::createAnimation(5, loc, baseZ());
113 }
114
115 TownManager::updateTownInfo(loc, buildingObj->producedQuantity[0], 0, 0, 0);
116
117 newUnk5u = 0;
118 newAge = 0;

Callers

nothing calls this directly

Calls 15

createAnimationFunction · 0.85
updateTownInfoFunction · 0.85
isEditorModeFunction · 0.85
getClosestTownAndDensityFunction · 0.85
baseHeightMethod · 0.80
clearHeightMethod · 0.80
setClearZMethod · 0.80
setConstructedMethod · 0.80
setUnk5uMethod · 0.80
setAgeMethod · 0.80
applyToMultiTileFunction · 0.70

Tested by

no test coverage detected