diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/aircraft.h | 1 | ||||
-rw-r--r-- | src/economy.cpp | 2 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 16 |
3 files changed, 16 insertions, 3 deletions
diff --git a/src/aircraft.h b/src/aircraft.h index a7d7761a1..cc9dd8641 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -91,6 +91,7 @@ struct Aircraft : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> { 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; } Money GetRunningCost() const; bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); } bool Tick(); diff --git a/src/economy.cpp b/src/economy.cpp index f0530c3da..810e99701 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1231,7 +1231,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) case VEH_TRAIN: t = Train::From(u)->tcache.cached_max_speed; break; case VEH_ROAD: t = u->max_speed / 2; break; case VEH_SHIP: t = u->max_speed; break; - case VEH_AIRCRAFT: t = u->max_speed * 10 / 128; break; // convert to old units + case VEH_AIRCRAFT: t = Aircraft::From(u)->GetSpeedOldUnits(); break; // Convert to old units. default: NOT_REACHED(); } diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 33479cabd..1d683430c 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -715,8 +715,20 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by case 0x17: return v->tick_counter; case 0x18: case 0x19: { - uint max_speed = v->type == VEH_TRAIN ? Train::From(v)->tcache.cached_max_speed : v->max_speed; - if (v->type == VEH_AIRCRAFT) max_speed = max_speed * 10 / 128; + uint max_speed; + switch (v->type) { + case VEH_TRAIN: + max_speed = Train::From(v)->tcache.cached_max_speed; + break; + + case VEH_AIRCRAFT: + max_speed = Aircraft::From(v)->GetSpeedOldUnits(); // Convert to old units. + break; + + default: + max_speed = v->max_speed; + break; + } return (variable - 0x80) == 0x18 ? max_speed : GB(max_speed, 8, 8); } case 0x1A: return v->x_pos; |