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

Function MarkTrainAsStuck

src/train_cmd.cpp:1560–1575  ·  view source on GitHub ↗

* Mark a train as stuck and stop it if it isn't stopped right now. * @param v %Train to mark as being stuck. */

Source from the content-addressed store, hash-verified

1558 * @param v %Train to mark as being stuck.
1559 */
1560static void MarkTrainAsStuck(Train *v)
1561{
1562 if (!v->flags.Test(VehicleRailFlag::Stuck)) {
1563 /* It is the first time the problem occurred, set the "train stuck" flag. */
1564 v->flags.Set(VehicleRailFlag::Stuck);
1565
1566 v->wait_counter = 0;
1567
1568 /* Stop train */
1569 v->cur_speed = 0;
1570 v->subspeed = 0;
1571 v->SetLastSpeed();
1572
1573 SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
1574 }
1575}
1576
1577/**
1578 * Swap the two up/down flags in two ways:

Callers 5

ReverseTrainDirectionFunction · 0.85
CheckTrainStayInDepotFunction · 0.85
ChooseTrainTrackFunction · 0.85
TryPathReserveFunction · 0.85
TrainControllerFunction · 0.85

Calls 4

SetWindowWidgetDirtyFunction · 0.85
TestMethod · 0.80
SetLastSpeedMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected