@@ -76,6 +76,7 @@ struct Aircraft FINAL : public Specializ
int GetDisplaySpeed() const { return this->cur_speed; }
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed; }
int GetSpeedOldUnits() const { return this->vcache.cached_max_speed * 10 / 128; }
int GetCurrentMaxSpeed() const { return this->GetSpeedOldUnits(); }
Money GetRunningCost() const;
bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
bool Tick();
@@ -619,6 +619,10 @@ static uint32 VehicleGetVariable(Vehicle
case 0x4B: // Long date of last service
return v->date_of_last_service;
case 0x4C: // Current maximum speed in NewGRF units
if (!v->IsPrimaryVehicle()) return 0;
return v->GetCurrentMaxSpeed();
/* Variables which use the parameter */
case 0x60: // Count consist's engine ID occurance
if (v->type != VEH_TRAIN) return v->GetEngine()->grf_prop.local_id == parameter ? 1 : 0;
@@ -37,6 +37,7 @@ struct Ship FINAL : public SpecializedVe
SpriteID GetImage(Direction direction, EngineImageType image_type) const;
int GetDisplaySpeed() const { return this->cur_speed / 2; }
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
int GetCurrentMaxSpeed() const { return min(this->vcache.cached_max_speed, this->current_order.max_speed * 2); }
bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
@@ -369,6 +369,8 @@ int Train::GetCurveSpeedLimit() const
*/
int Train::GetCurrentMaxSpeed() const
{
if (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) return min(this->gcache.cached_max_track_speed, this->current_order.max_speed);
int max_speed = this->tcache.cached_max_curve_speed;
assert(max_speed == this->GetCurveSpeedLimit());
@@ -399,6 +399,12 @@ public:
virtual int GetDisplayMaxSpeed() const { return 0; }
/**
* Calculates the maximum speed of the vehicle under its current conditions.
* @return Current maximum speed in native units.
virtual int GetCurrentMaxSpeed() const { return 0; }
* Gets the running cost of a vehicle
* @return the vehicle's running cost
Status change: