diff options
author | rubidium <rubidium@openttd.org> | 2007-08-28 06:46:33 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-28 06:46:33 +0000 |
commit | 5e5d36d6b4c0d86abc9f8c346bda5254b7f8ba35 (patch) | |
tree | cc70dd0831f84779834db7751c18a5a7eb87e5b1 | |
parent | cb3843b8205c4fb7b04e95fa4b32cf036c7d89df (diff) | |
download | openttd-5e5d36d6b4c0d86abc9f8c346bda5254b7f8ba35.tar.xz |
(svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
-rw-r--r-- | src/aircraft.h | 1 | ||||
-rw-r--r-- | src/aircraft_gui.cpp | 2 | ||||
-rw-r--r-- | src/roadveh.h | 1 | ||||
-rw-r--r-- | src/roadveh_gui.cpp | 2 | ||||
-rw-r--r-- | src/ship.h | 1 | ||||
-rw-r--r-- | src/ship_gui.cpp | 2 | ||||
-rw-r--r-- | src/train.h | 1 | ||||
-rw-r--r-- | src/train_gui.cpp | 2 | ||||
-rw-r--r-- | src/vehicle.h | 6 |
9 files changed, 14 insertions, 4 deletions
diff --git a/src/aircraft.h b/src/aircraft.h index 1af9942ad..0a32703e2 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -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(); }; diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp index b90ddb3f1..ee8d39610 100644 --- a/src/aircraft_gui.cpp +++ b/src/aircraft_gui.cpp @@ -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); } diff --git a/src/roadveh.h b/src/roadveh.h index 8547a2610..24b64424d 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -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(); }; diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp index d301a482e..73d314b0f 100644 --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -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); } diff --git a/src/ship.h b/src/ship.h index cd7b4c3c1..ac86c907a 100644 --- a/src/ship.h +++ b/src/ship.h @@ -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(); }; diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp index d1e64d39a..fd4456c3b 100644 --- a/src/ship_gui.cpp +++ b/src/ship_gui.cpp @@ -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); } diff --git a/src/train.h b/src/train.h index db9aa5b2d..a64048fb8 100644 --- a/src/train.h +++ b/src/train.h @@ -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(); }; diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 378d874ad..ba3ad3046 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -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); diff --git a/src/vehicle.h b/src/vehicle.h index f036a2e8d..02ed8e51e 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -421,6 +421,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 */ virtual void Tick() {}; |