summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-11-06 12:50:34 +0000
committerterkhen <terkhen@openttd.org>2010-11-06 12:50:34 +0000
commit78d0a1cb1af68863e3e7bfed584f4a94ee46f611 (patch)
tree3919b2ecde621dc86ccf82c7f64e564ecd7db520 /src
parentcfac2ced69f072a3881e990837f82a884e27cd40 (diff)
downloadopenttd-78d0a1cb1af68863e3e7bfed584f4a94ee46f611.tar.xz
(svn r21096) -Fix: Display the real max speed for aircrafts instead of always using the engine value.
Diffstat (limited to 'src')
-rw-r--r--src/aircraft.h4
-rw-r--r--src/aircraft_cmd.cpp5
-rw-r--r--src/vehicle_gui.cpp2
3 files changed, 7 insertions, 4 deletions
diff --git a/src/aircraft.h b/src/aircraft.h
index cc9dd8641..34e6e2082 100644
--- a/src/aircraft.h
+++ b/src/aircraft.h
@@ -90,8 +90,8 @@ struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
bool IsPrimaryVehicle() const { return this->IsNormalAircraft(); }
SpriteID GetImage(Direction direction) const;
int GetDisplaySpeed() const { return this->cur_speed; }
- int GetDisplayMaxSpeed() const { return this->max_speed; }
- int GetSpeedOldUnits() const { return this->max_speed * 10 / 128; }
+ int GetDisplayMaxSpeed() const { return this->acache.cached_max_speed; }
+ int GetSpeedOldUnits() const { return this->acache.cached_max_speed * 10 / 128; }
Money GetRunningCost() const;
bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); }
bool Tick();
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 7f389c6e3..1f9df1853 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -537,7 +537,8 @@ void UpdateAircraftCache(Aircraft *v)
v->acache.cached_max_speed = max_speed;
} else {
- v->acache.cached_max_speed = 0xFFFF;
+ /* Use the default max speed of the vehicle. */
+ v->acache.cached_max_speed = v->max_speed;
}
}
@@ -639,7 +640,7 @@ byte GetAircraftFlyingAltitude(const Aircraft *v)
}
/* Make faster planes fly higher so that they can overtake slower ones */
- base_altitude += min(20 * (v->max_speed / 200), 90);
+ base_altitude += min(20 * (v->acache.cached_max_speed / 200), 90);
return base_altitude;
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 4906d67a7..23b1e1e42 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -809,6 +809,8 @@ static int CDECL VehicleMaxSpeedSorter(const Vehicle * const *a, const Vehicle *
int r = 0;
if ((*a)->type == VEH_TRAIN && (*b)->type == VEH_TRAIN) {
r = Train::From(*a)->tcache.cached_max_speed - Train::From(*b)->tcache.cached_max_speed;
+ } if ((*a)->type == VEH_AIRCRAFT && (*b)->type == VEH_AIRCRAFT) {
+ r = Aircraft::From(*a)->acache.cached_max_speed - Aircraft::From(*b)->acache.cached_max_speed;
} else {
r = (*a)->max_speed - (*b)->max_speed;
}