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

Method updateVehicle

src/OpenLoco/src/Vehicles/VehicleHead.cpp:134–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 static WaterPathingResult waterPathfind(const VehicleHead& head);
133
134 void VehicleHead::updateVehicle()
135 {
136 Vehicle train(*this);
137 if (!train.head->update())
138 {
139 return;
140 }
141 if (!train.veh1->update())
142 {
143 return;
144 }
145 if (!train.veh2->update())
146 {
147 return;
148 }
149 // The car order may have changed during the previous updates
150 train.refreshCars();
151 for (auto& car : train.cars)
152 {
153 for (auto& carComponent : car)
154 {
155 CarUpdateState carUpdateState{ carComponent.front, carComponent.back, false };
156 const auto initialFrontPos = carComponent.front->position;
157 if (!carComponent.front->update())
158 {
159 return;
160 }
161 carUpdateState.hasBogieMoved |= carComponent.front->position != initialFrontPos;
162
163 const auto initialBackPos = carComponent.front->position;
164 if (!carComponent.back->update())
165 {
166 return;
167 }
168 carUpdateState.hasBogieMoved |= carComponent.back->position != initialBackPos;
169
170 if (!carComponent.body->update(carUpdateState))
171 {
172 return;
173 }
174 }
175 }
176 train.tail->update();
177 }
178
179 // 0x004A8B81
180 bool VehicleHead::update()

Callers 1

updateFunction · 0.80

Calls 2

refreshCarsMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected