MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateAcceleration

Method UpdateAcceleration

src/train_cmd.cpp:430–438  ·  view source on GitHub ↗

Update acceleration of the train from the cached power and weight. */

Source from the content-addressed store, hash-verified

428
429/** Update acceleration of the train from the cached power and weight. */
430void Train::UpdateAcceleration()
431{
432 assert(this->IsFrontEngine() || this->IsFreeWagon());
433
434 uint power = this->gcache.cached_power;
435 uint weight = this->gcache.cached_weight;
436 assert(weight != 0);
437 this->acceleration = Clamp(power / weight * 4, 1, 255);
438}
439
440int Train::GetCursorImageOffset() const
441{

Callers 4

ConsistChangedMethod · 0.95
MarkDirtyMethod · 0.95
CheckTrainStayInDepotFunction · 0.80

Calls 3

ClampFunction · 0.85
IsFrontEngineMethod · 0.80
IsFreeWagonMethod · 0.80

Tested by

no test coverage detected