Mercurial > hg > openttd
changeset 10969:208ba3fba382 draft
(svn r15308) -Codechange: Deduplicate km-ish/h -> mph conversions.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 01 Feb 2009 17:14:39 +0000 |
parents | 90245d035efb |
children | 0c6169a253fd |
files | src/ai/api/ai_bridge.cpp src/ai/api/ai_engine.cpp src/ai/api/ai_event_types.cpp src/ai/api/ai_vehicle.cpp src/aircraft.h src/bridge_gui.cpp src/engine.cpp src/order_cmd.cpp src/roadveh.h src/ship.h src/strings.cpp src/train.h src/vehicle_base.h |
diffstat | 13 files changed, 22 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/api/ai_bridge.cpp +++ b/src/ai/api/ai_bridge.cpp @@ -133,7 +133,7 @@ { if (!IsValidBridge(bridge_id)) return -1; - return ::GetBridgeSpec(bridge_id)->speed; + return ::GetBridgeSpec(bridge_id)->speed; // km-ish/h } /* static */ Money AIBridge::GetPrice(BridgeID bridge_id, uint length)
--- a/src/ai/api/ai_engine.cpp +++ b/src/ai/api/ai_engine.cpp @@ -119,7 +119,7 @@ if (!IsValidEngine(engine_id)) return -1; const Engine *e = ::GetEngine(engine_id); - int32 max_speed = e->GetDisplayMaxSpeed() * 16 / 10; // convert mph to km-ish/h + int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed; return max_speed; }
--- a/src/ai/api/ai_event_types.cpp +++ b/src/ai/api/ai_event_types.cpp @@ -80,7 +80,7 @@ int32 AIEventEnginePreview::GetMaxSpeed() { const Engine *e = ::GetEngine(engine); - int32 max_speed = e->GetDisplayMaxSpeed() * 16 / 10; // convert mph to km-ish/h + int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed; return max_speed; }
--- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -278,7 +278,7 @@ { if (!IsValidVehicle(vehicle_id)) return -1; - return ::GetVehicle(vehicle_id)->GetDisplaySpeed() * 16 / 10; + return ::GetVehicle(vehicle_id)->GetDisplaySpeed(); // km-ish/h } /* static */ AIVehicle::VehicleState AIVehicle::GetState(VehicleID vehicle_id)
--- a/src/aircraft.h +++ b/src/aircraft.h @@ -102,8 +102,8 @@ ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; } bool IsPrimaryVehicle() const { return IsNormalAircraft(this); } SpriteID GetImage(Direction direction) const; - int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; } - int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 16; } + int GetDisplaySpeed() const { return this->cur_speed; } + int GetDisplayMaxSpeed() const { return this->max_speed; } Money GetRunningCost() const; bool IsInDepot() const { return (this->vehstatus & VS_HIDDEN) != 0 && IsHangarTile(this->tile); } void Tick();
--- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -165,7 +165,7 @@ const BridgeSpec *b = this->bridges->Get(i)->spec; SetDParam(2, this->bridges->Get(i)->cost); - SetDParam(1, b->speed * 10 / 16); + SetDParam(1, b->speed); SetDParam(0, b->material); DrawSprite(b->sprite, b->pal, 3, y);
--- a/src/engine.cpp +++ b/src/engine.cpp @@ -156,22 +156,22 @@ /** * Returns max speed for display purposes - * @return max speed in mph + * @return max speed in km-ish/h */ uint Engine::GetDisplayMaxSpeed() const { switch (this->type) { case VEH_TRAIN: - return GetEngineProperty(this->index, 0x09, this->u.rail.max_speed) * 10 / 16; + return GetEngineProperty(this->index, 0x09, this->u.rail.max_speed); case VEH_ROAD: - return this->u.road.max_speed * 10 / 32; + return this->u.road.max_speed / 2; case VEH_SHIP: - return GetEngineProperty(this->index, 0x0B, this->u.ship.max_speed) * 10 / 32; + return GetEngineProperty(this->index, 0x0B, this->u.ship.max_speed) / 2; case VEH_AIRCRAFT: - return this->u.air.max_speed * 10 / 16; + return this->u.air.max_speed; default: NOT_REACHED(); }
--- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1590,7 +1590,7 @@ switch (order->GetConditionVariable()) { case OCV_LOAD_PERCENTAGE: skip_order = OrderConditionCompare(occ, CalcPercentVehicleFilled(v, NULL), value); break; case OCV_RELIABILITY: skip_order = OrderConditionCompare(occ, v->reliability * 100 >> 16, value); break; - case OCV_MAX_SPEED: skip_order = OrderConditionCompare(occ, v->GetDisplayMaxSpeed(), value); break; + case OCV_MAX_SPEED: skip_order = OrderConditionCompare(occ, v->GetDisplayMaxSpeed() * 10 / 16, value); break; case OCV_AGE: skip_order = OrderConditionCompare(occ, v->age / DAYS_IN_LEAP_YEAR, value); break; case OCV_REQUIRES_SERVICE: skip_order = OrderConditionCompare(occ, v->NeedsServicing(), value); break; case OCV_UNCONDITIONALLY: skip_order = true; break;
--- a/src/roadveh.h +++ b/src/roadveh.h @@ -74,8 +74,8 @@ ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; } bool IsPrimaryVehicle() const { return IsRoadVehFront(this); } SpriteID GetImage(Direction direction) const; - int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; } - int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; } + int GetDisplaySpeed() const { return this->cur_speed / 2; } + int GetDisplayMaxSpeed() const { return this->max_speed / 2; } Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * GetPriceByIndex(RoadVehInfo(this->engine_type)->running_cost_class); } bool IsInDepot() const { return this->u.road.state == RVSB_IN_DEPOT; } bool IsStoppedInDepot() const;
--- a/src/ship.h +++ b/src/ship.h @@ -36,8 +36,8 @@ void PlayLeaveStationSound() const; bool IsPrimaryVehicle() const { return true; } SpriteID GetImage(Direction direction) const; - int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; } - int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; } + int GetDisplaySpeed() const { return this->cur_speed / 2; } + int GetDisplayMaxSpeed() const { return this->max_speed / 2; } Money GetRunningCost() const; bool IsInDepot() const { return this->u.ship.state == TRACK_BIT_DEPOT; } void Tick();
--- a/src/strings.cpp +++ b/src/strings.cpp @@ -596,7 +596,7 @@ case SCC_VELOCITY: {// {VELOCITY} int64 args[1]; assert(_settings_game.locale.units < lengthof(units)); - args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv)); + args[0] = ConvertSpeedToDisplaySpeed(GetInt32(&argv) * 10 / 16); buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].velocity), args, modifier >> 24, last); modifier = 0; break;
--- a/src/train.h +++ b/src/train.h @@ -322,8 +322,8 @@ void PlayLeaveStationSound() const; bool IsPrimaryVehicle() const { return IsFrontEngine(this); } SpriteID GetImage(Direction direction) const; - int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; } - int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; } + int GetDisplaySpeed() const { return this->u.rail.last_speed; } + int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed; } Money GetRunningCost() const; bool IsInDepot() const { return CheckTrainInDepot(this, false) != -1; } bool IsStoppedInDepot() const { return CheckTrainStoppedInDepot(this) >= 0; }
--- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -397,13 +397,13 @@ virtual SpriteID GetImage(Direction direction) const { return 0; } /** - * Gets the speed in mph that can be sent into SetDParam for string processing. + * Gets the speed in km-ish/h that can be sent into SetDParam for string processing. * @return the vehicle's speed */ virtual int GetDisplaySpeed() const { return 0; } /** - * Gets the maximum speed in mph that can be sent into SetDParam for string processing. + * Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing. * @return the vehicle's maximum speed */ virtual int GetDisplayMaxSpeed() const { return 0; }