(svn r24246) -Add [FS#5052-ish]: [NewGRF] Variable with the current max speed for vehicles.

pull/155/head
michi_cc 12 years ago
parent 833f9ed8c3
commit d561bfe4db

@ -76,6 +76,7 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
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 *v, const ResolverObject *object, byte
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 SpecializedVehicle<Ship, VEH_SHIP> {
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); }
Money GetRunningCost() const;
bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
bool Tick();

@ -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());

@ -398,6 +398,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

Loading…
Cancel
Save