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

Method UpdateSpeed

src/roadveh_cmd.cpp:739–749  ·  view source on GitHub ↗

* This function looks at the vehicle and updates its speed (cur_speed * and subspeed) variables. Furthermore, it returns the distance that * the vehicle can drive this tick. #Vehicle::GetAdvanceDistance() determines * the distance to drive before moving a step on the map. * @return distance to drive. */

Source from the content-addressed store, hash-verified

737 * @return distance to drive.
738 */
739int RoadVehicle::UpdateSpeed()
740{
741 switch (_settings_game.vehicle.roadveh_acceleration_model) {
742 default: NOT_REACHED();
743 case AM_ORIGINAL:
744 return this->DoUpdateSpeed(this->overtaking != 0 ? 512 : 256, 0, this->GetCurrentMaxSpeed());
745
746 case AM_REALISTIC:
747 return this->DoUpdateSpeed(this->GetAcceleration() + (this->overtaking != 0 ? 256 : 0), this->GetAccelerationStatus() == AS_BRAKE ? 0 : 4, this->GetCurrentMaxSpeed());
748 }
749}
750
751static Direction RoadVehGetNewDirection(const RoadVehicle *v, int x, int y)
752{

Callers 1

RoadVehControllerFunction · 0.45

Calls 5

GetCurrentMaxSpeedMethod · 0.95
GetAccelerationStatusMethod · 0.95
NOT_REACHEDFunction · 0.85
DoUpdateSpeedMethod · 0.80
GetAccelerationMethod · 0.80

Tested by

no test coverage detected