Implement improved breakdown speed reductions for ships
This commit is contained in:
@@ -339,6 +339,20 @@ void Ship::UpdateDeltaXY()
|
||||
}
|
||||
}
|
||||
|
||||
int Ship::GetEffectiveMaxSpeed() const
|
||||
{
|
||||
int max_speed = this->vcache.cached_max_speed;
|
||||
|
||||
if (this->critical_breakdown_count == 0) return max_speed;
|
||||
|
||||
for (uint i = 0; i < this->critical_breakdown_count; i++) {
|
||||
max_speed = std::min(max_speed - (max_speed / 3) + 1, max_speed);
|
||||
}
|
||||
|
||||
/* clamp speed to be no less than lower of 5mph and 1/8 of base speed */
|
||||
return std::max<uint16>(max_speed, std::min<uint16>(10, (this->vcache.cached_max_speed + 7) >> 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test-procedure for HasVehicleOnPos to check for any ships which are visible and not stopped by the player.
|
||||
*/
|
||||
@@ -439,7 +453,7 @@ static bool ShipAccelerate(Vehicle *v)
|
||||
uint spd;
|
||||
byte t;
|
||||
|
||||
spd = std::min<uint>(v->cur_speed + 1, v->vcache.cached_max_speed);
|
||||
spd = std::min<uint>(v->cur_speed + 1, Ship::From(v)->GetEffectiveMaxSpeed());
|
||||
spd = std::min<uint>(spd, v->current_order.GetMaxSpeed() * 2);
|
||||
|
||||
if (v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_LOW_POWER && v->cur_speed > (v->breakdown_severity * ShipVehInfo(v->engine_type)->max_speed) >> 8) {
|
||||
|
Reference in New Issue
Block a user