1
0
Fork 0

(svn r10995) -Codechange: unify the way to get the displayed maxium speed of a vehicle. Patch by nycom.

release/0.6
rubidium 2007-08-28 06:46:33 +00:00
parent 41a0bd2b74
commit 2179faf5c8
9 changed files with 14 additions and 4 deletions

View File

@ -129,6 +129,7 @@ struct Aircraft : public Vehicle {
bool IsPrimaryVehicle() const { return IsNormalAircraft(this); } bool IsPrimaryVehicle() const { return IsNormalAircraft(this); }
int GetImage(Direction direction) const; int GetImage(Direction direction) const;
int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; } int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 16; }
void Tick(); void Tick();
}; };

View File

@ -86,7 +86,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
/* Draw max speed */ /* Draw max speed */
{ {
SetDParam(0, v->max_speed * 10 / 16); SetDParam(0, v->GetDisplayMaxSpeed());
DrawString(2, 25, STR_A00E_MAX_SPEED, 0); DrawString(2, 25, STR_A00E_MAX_SPEED, 0);
} }

View File

@ -82,6 +82,7 @@ struct RoadVehicle : public Vehicle {
bool HasFront() const { return true; } bool HasFront() const { return true; }
int GetImage(Direction direction) const; int GetImage(Direction direction) const;
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; } int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
void Tick(); void Tick();
}; };

View File

@ -97,7 +97,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
/* Draw max speed */ /* Draw max speed */
{ {
SetDParam(0, v->max_speed * 10 / 32); SetDParam(0, v->GetDisplayMaxSpeed());
DrawString(2, 25, STR_900E_MAX_SPEED, 0); DrawString(2, 25, STR_900E_MAX_SPEED, 0);
} }

View File

@ -47,6 +47,7 @@ struct Ship: public Vehicle {
bool IsPrimaryVehicle() const { return true; } bool IsPrimaryVehicle() const { return true; }
int GetImage(Direction direction) const; int GetImage(Direction direction) const;
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; } int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
void Tick(); void Tick();
}; };

View File

@ -56,7 +56,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
/* Draw max speed */ /* Draw max speed */
{ {
SetDParam(0, v->max_speed * 10 / 32); SetDParam(0, v->GetDisplayMaxSpeed());
DrawString(2, 25, STR_9813_MAX_SPEED, 0); DrawString(2, 25, STR_9813_MAX_SPEED, 0);
} }

View File

@ -273,6 +273,7 @@ struct Train : public Vehicle {
bool HasFront() const { return true; } bool HasFront() const { return true; }
int GetImage(Direction direction) const; int GetImage(Direction direction) const;
int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; } int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; }
int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; }
void Tick(); void Tick();
}; };

View File

@ -421,7 +421,7 @@ static void DrawTrainDetailsWindow(Window *w)
SetDParam(3, GetTrainRunningCost(v) >> 8); SetDParam(3, GetTrainRunningCost(v) >> 8);
DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); 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(1, v->u.rail.cached_power);
SetDParam(0, v->u.rail.cached_weight); SetDParam(0, v->u.rail.cached_weight);
SetDParam(3, v->u.rail.cached_max_te / 1000); SetDParam(3, v->u.rail.cached_max_te / 1000);

View File

@ -420,6 +420,12 @@ struct Vehicle : PoolItem<Vehicle, VehicleID, &_Vehicle_pool> {
*/ */
virtual int GetDisplaySpeed() const { return 0; } 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 * Calls the tick handler of the vehicle
*/ */