# HG changeset patch # User rubidium # Date 1188283593 0 # Node ID 7734e4119e70865c98933b52f25cb72382201582 # Parent c36db156811dc411a725b40e50eb491721ad25ae (svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom. diff -r c36db156811d -r 7734e4119e70 src/aircraft.h --- a/src/aircraft.h Tue Aug 28 01:09:41 2007 +0000 +++ b/src/aircraft.h Tue Aug 28 06:46:33 2007 +0000 @@ -129,6 +129,7 @@ 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 -r c36db156811d -r 7734e4119e70 src/aircraft_gui.cpp --- a/src/aircraft_gui.cpp Tue Aug 28 01:09:41 2007 +0000 +++ b/src/aircraft_gui.cpp Tue Aug 28 06:46:33 2007 +0000 @@ -86,7 +86,7 @@ /* Draw max speed */ { - SetDParam(0, v->max_speed * 10 / 16); + SetDParam(0, v->GetDisplayMaxSpeed()); DrawString(2, 25, STR_A00E_MAX_SPEED, 0); } diff -r c36db156811d -r 7734e4119e70 src/roadveh.h --- a/src/roadveh.h Tue Aug 28 01:09:41 2007 +0000 +++ b/src/roadveh.h Tue Aug 28 06:46:33 2007 +0000 @@ -82,6 +82,7 @@ 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 -r c36db156811d -r 7734e4119e70 src/roadveh_gui.cpp --- a/src/roadveh_gui.cpp Tue Aug 28 01:09:41 2007 +0000 +++ b/src/roadveh_gui.cpp Tue Aug 28 06:46:33 2007 +0000 @@ -97,7 +97,7 @@ /* Draw max speed */ { - SetDParam(0, v->max_speed * 10 / 32); + SetDParam(0, v->GetDisplayMaxSpeed()); DrawString(2, 25, STR_900E_MAX_SPEED, 0); } diff -r c36db156811d -r 7734e4119e70 src/ship.h --- a/src/ship.h Tue Aug 28 01:09:41 2007 +0000 +++ b/src/ship.h Tue Aug 28 06:46:33 2007 +0000 @@ -47,6 +47,7 @@ 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 -r c36db156811d -r 7734e4119e70 src/ship_gui.cpp --- a/src/ship_gui.cpp Tue Aug 28 01:09:41 2007 +0000 +++ b/src/ship_gui.cpp Tue Aug 28 06:46:33 2007 +0000 @@ -56,7 +56,7 @@ /* Draw max speed */ { - SetDParam(0, v->max_speed * 10 / 32); + SetDParam(0, v->GetDisplayMaxSpeed()); DrawString(2, 25, STR_9813_MAX_SPEED, 0); } diff -r c36db156811d -r 7734e4119e70 src/train.h --- a/src/train.h Tue Aug 28 01:09:41 2007 +0000 +++ b/src/train.h Tue Aug 28 06:46:33 2007 +0000 @@ -273,6 +273,7 @@ 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 -r c36db156811d -r 7734e4119e70 src/train_gui.cpp --- a/src/train_gui.cpp Tue Aug 28 01:09:41 2007 +0000 +++ b/src/train_gui.cpp Tue Aug 28 06:46:33 2007 +0000 @@ -421,7 +421,7 @@ 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 -r c36db156811d -r 7734e4119e70 src/vehicle.h --- a/src/vehicle.h Tue Aug 28 01:09:41 2007 +0000 +++ b/src/vehicle.h Tue Aug 28 06:46:33 2007 +0000 @@ -421,6 +421,12 @@ 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() {};