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

Function updateTreeElement

src/OpenLoco/src/Map/TreeElement.cpp:140–348  ·  view source on GitHub ↗

0x004BD52B

Source from the content-addressed store, hash-verified

138
139 // 0x004BD52B
140 bool updateTreeElement(TreeElement& elTree, const World::Pos2 loc)
141 {
142 if (elTree.unk7l() != 7)
143 {
144 elTree.setUnk7l(elTree.unk7l() + 1);
145 invalidateTree(elTree, loc);
146 return true;
147 }
148
149 auto* treeObj = ObjectManager::get<TreeObject>(elTree.treeObjectId());
150 if (elTree.isDying())
151 {
152 const auto unk = kSeasonDeathSequence[elTree.season()];
153 if (unk == 0xFFU)
154 {
155 invalidateTree(elTree, loc);
156 TileManager::removeElement(reinterpret_cast<TileElement&>(elTree));
157 return false;
158 }
159 else
160 {
161 elTree.setSeason(unk);
162 elTree.setUnk7l(0);
163 invalidateTree(elTree, loc);
164 return true;
165 }
166 }
167
168 if (!SceneManager::isEditorMode())
169 {
170 elTree.setUnk5h(elTree.unk5h() + 1);
171 if (elTree.unk5h() != 0)
172 {
173 return true;
174 }
175 }
176
177 const auto isBelowSnowLine = elTree.baseZ() - 4 <= Scenario::getCurrentSnowLine();
178 if (isBelowSnowLine)
179 {
180 if (elTree.hasSnow())
181 {
182 elTree.setSnow(false);
183 invalidateTree(elTree, loc);
184 }
185 }
186 else
187 {
188 if (treeObj->hasFlags(TreeObjectFlags::hasSnowVariation))
189 {
190 if (!elTree.hasSnow())
191 {
192 elTree.setSnow(true);
193 invalidateTree(elTree, loc);
194 }
195 }
196 else
197 {

Callers 1

updateFunction · 0.85

Calls 15

invalidateTreeFunction · 0.85
isEditorModeFunction · 0.85
getCurrentSnowLineFunction · 0.85
killTreeFunction · 0.85
enumValueFunction · 0.85
getCurrentSeasonFunction · 0.85
canConstructAtFunction · 0.85
hasObstructionsTooNearFunction · 0.85
validCoordsFunction · 0.85
toTileSpaceFunction · 0.85
getHeightFunction · 0.85

Tested by

no test coverage detected