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

Method Tick

src/train_cmd.cpp:4115–4138  ·  view source on GitHub ↗

* Update train vehicle data for a tick. * @return True if the vehicle still exists, false if it has ceased to exist (front of consists only). */

Source from the content-addressed store, hash-verified

4113 * @return True if the vehicle still exists, false if it has ceased to exist (front of consists only).
4114 */
4115bool Train::Tick()
4116{
4117 this->tick_counter++;
4118
4119 if (this->IsFrontEngine()) {
4120 PerformanceAccumulator framerate(PFE_GL_TRAINS);
4121
4122 if (!this->vehstatus.Test(VehState::Stopped) || this->cur_speed > 0) this->running_ticks++;
4123
4124 this->current_order_time++;
4125
4126 if (!TrainLocoHandler(this, false)) return false;
4127
4128 return TrainLocoHandler(this, true);
4129 } else if (this->IsFreeWagon() && this->vehstatus.Test(VehState::Crashed)) {
4130 /* Delete flooded standalone wagon chain */
4131 if (++this->crash_anim_pos >= 4400) {
4132 delete this;
4133 return false;
4134 }
4135 }
4136
4137 return true;
4138}
4139
4140/**
4141 * Check whether a train needs service, and if so, find a depot or service it.

Callers

nothing calls this directly

Calls 4

TrainLocoHandlerFunction · 0.85
IsFrontEngineMethod · 0.80
TestMethod · 0.80
IsFreeWagonMethod · 0.80

Tested by

no test coverage detected