mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
This commit is contained in:
parent
41a0bd2b74
commit
2179faf5c8
@ -129,6 +129,7 @@ struct Aircraft : public Vehicle {
|
||||
bool IsPrimaryVehicle() const { return IsNormalAircraft(this); }
|
||||
int GetImage(Direction direction) const;
|
||||
int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
|
||||
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 16; }
|
||||
void Tick();
|
||||
};
|
||||
|
||||
|
@ -86,7 +86,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
/* Draw max speed */
|
||||
{
|
||||
SetDParam(0, v->max_speed * 10 / 16);
|
||||
SetDParam(0, v->GetDisplayMaxSpeed());
|
||||
DrawString(2, 25, STR_A00E_MAX_SPEED, 0);
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ struct RoadVehicle : public Vehicle {
|
||||
bool HasFront() const { return true; }
|
||||
int GetImage(Direction direction) const;
|
||||
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
||||
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
|
||||
void Tick();
|
||||
};
|
||||
|
||||
|
@ -97,7 +97,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
/* Draw max speed */
|
||||
{
|
||||
SetDParam(0, v->max_speed * 10 / 32);
|
||||
SetDParam(0, v->GetDisplayMaxSpeed());
|
||||
DrawString(2, 25, STR_900E_MAX_SPEED, 0);
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ struct Ship: public Vehicle {
|
||||
bool IsPrimaryVehicle() const { return true; }
|
||||
int GetImage(Direction direction) const;
|
||||
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
||||
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
|
||||
void Tick();
|
||||
};
|
||||
|
||||
|
@ -56,7 +56,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
/* Draw max speed */
|
||||
{
|
||||
SetDParam(0, v->max_speed * 10 / 32);
|
||||
SetDParam(0, v->GetDisplayMaxSpeed());
|
||||
DrawString(2, 25, STR_9813_MAX_SPEED, 0);
|
||||
}
|
||||
|
||||
|
@ -273,6 +273,7 @@ struct Train : public Vehicle {
|
||||
bool HasFront() const { return true; }
|
||||
int GetImage(Direction direction) const;
|
||||
int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
|
||||
int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; }
|
||||
void Tick();
|
||||
};
|
||||
|
||||
|
@ -421,7 +421,7 @@ static void DrawTrainDetailsWindow(Window *w)
|
||||
SetDParam(3, GetTrainRunningCost(v) >> 8);
|
||||
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0);
|
||||
|
||||
SetDParam(2, v->u.rail.cached_max_speed * 10 / 16);
|
||||
SetDParam(2, v->GetDisplayMaxSpeed());
|
||||
SetDParam(1, v->u.rail.cached_power);
|
||||
SetDParam(0, v->u.rail.cached_weight);
|
||||
SetDParam(3, v->u.rail.cached_max_te / 1000);
|
||||
|
@ -420,6 +420,12 @@ struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool> {
|
||||
*/
|
||||
virtual int GetDisplaySpeed() const { return 0; }
|
||||
|
||||
/**
|
||||
* Gets the maximum speed in mph that can be sent into SetDParam for string processing.
|
||||
* @return the vehicle's maximum speed
|
||||
*/
|
||||
virtual int GetDisplayMaxSpeed() const { return 0; }
|
||||
|
||||
/**
|
||||
* Calls the tick handler of the vehicle
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user