(svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.
--- 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();
};
--- 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);
}
--- 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();
};
--- 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);
}
--- 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();
};
--- 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);
}
--- 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();
};
--- 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);
--- 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() {};