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

Function updateNonIndustrialSurface

src/OpenLoco/src/Map/SurfaceElement.cpp:32–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30 }
31
32 static void updateNonIndustrialSurface(SurfaceElement& elSurface, const World::Pos2 loc)
33 {
34 auto* landObj = ObjectManager::get<LandObject>(elSurface.terrain());
35 if (!landObj->hasFlags(LandObjectFlags::hasGrowthStages))
36 {
37 return;
38 }
39 elSurface.setUpdateTimer(elSurface.getUpdateTimer() + 1);
40 if (elSurface.getUpdateTimer() != 0)
41 {
42 return;
43 }
44 if (elSurface.water())
45 {
46 SmallZ waterZ = elSurface.water() * kMicroToSmallZStep;
47 if (elSurface.slope())
48 {
49 waterZ -= 4;
50 }
51 if (waterZ > elSurface.baseZ())
52 {
53 if (elSurface.getGrowthStage())
54 {
55 elSurface.setGrowthStage(0);
56 Ui::ViewportManager::invalidate(loc, elSurface.baseHeight(), elSurface.baseHeight());
57 }
58 return;
59 }
60 }
61
62 if (elSurface.getGrowthStage() + 1 < landObj->numGrowthStages)
63 {
64 elSurface.setGrowthStage(elSurface.getGrowthStage() + 1);
65 Ui::ViewportManager::invalidate(loc, elSurface.baseHeight(), elSurface.baseHeight());
66 }
67 }
68
69 // 0x004C49E9
70 static WallElement* getWallElement(const World::Pos2 loc, SmallZ baseZ, SmallZ clearZ, uint8_t direction)

Callers 1

updateSurfaceFunction · 0.85

Calls 11

terrainMethod · 0.80
setUpdateTimerMethod · 0.80
getUpdateTimerMethod · 0.80
waterMethod · 0.80
slopeMethod · 0.80
baseZMethod · 0.80
getGrowthStageMethod · 0.80
setGrowthStageMethod · 0.80
baseHeightMethod · 0.80
invalidateFunction · 0.50
hasFlagsMethod · 0.45

Tested by

no test coverage detected