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

Function RoadVehSetRandomDirection

src/roadveh_cmd.cpp:505–517  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503}
504
505static void RoadVehSetRandomDirection(RoadVehicle *v)
506{
507 static const DirDiff delta[] = {
508 DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT
509 };
510
511 do {
512 uint32_t r = Random();
513
514 v->direction = ChangeDir(v->direction, delta[r & 3]);
515 v->UpdateViewport(true, true);
516 } while ((v = v->Next()) != nullptr);
517}
518
519/**
520 * Road vehicle chain has crashed.

Callers 1

RoadVehIsCrashedFunction · 0.85

Calls 4

ChangeDirFunction · 0.85
RandomFunction · 0.50
UpdateViewportMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected