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

Method update

src/OpenLoco/src/Vehicles/VehicleHead.cpp:180–232  ·  view source on GitHub ↗

0x004A8B81

Source from the content-addressed store, hash-verified

178
179 // 0x004A8B81
180 bool VehicleHead::update()
181 {
182 Vehicle train(head);
183
184 const auto initialStatus = status;
185 updateDrivingSounds();
186
187 Vehicle2* veh2 = train.veh2;
188 auto& distances = getVehicleUpdateDistances();
189 distances.unkDistance1 = veh2->currentSpeed.getRaw() >> 7;
190 distances.unkDistance2 = veh2->currentSpeed.getRaw() >> 7;
191
192 if (var_5C != 0)
193 {
194 var_5C--;
195 }
196
197 if (tileX == -1)
198 {
199 if (!train.cars.empty())
200 {
201 return false;
202 }
203
204 train.tail->trainDanglingTimeout++;
205 if (train.tail->trainDanglingTimeout < 960)
206 {
207 return false;
208 }
209 VehicleManager::deleteTrain(*this);
210 return false;
211 }
212 updateBreakdown();
213 bool continueUpdating = true;
214 switch (mode)
215 {
216 case TransportMode::rail:
217 case TransportMode::road:
218 continueUpdating = updateLand();
219 break;
220 case TransportMode::air:
221 continueUpdating = updateAir();
222 break;
223 case TransportMode::water:
224 continueUpdating = updateWater();
225 break;
226 }
227 if (continueUpdating)
228 {
229 tryCreateInitialMovementSound(initialStatus);
230 }
231 return continueUpdating;
232 }
233
234 // 0x004C3C65
235 void VehicleHead::updateMonthly()

Callers 1

updateVehicleMethod · 0.45

Calls 3

deleteTrainFunction · 0.85
getRawMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected