From ffadd91ca9fc5de831eb68a4303852790efa6d41 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Sat, 8 Apr 2006 12:04:23 +0000 Subject: [PATCH] (svn r4322) - Codechange: Remove conversion of kmh to mph from gui code to within the units conversion system, in string.c. This means displaying kmh requires no conversion, instead of being convert from kmh to mph, and then back to kmh again. --- aircraft_gui.c | 10 +++++----- bridge_gui.c | 2 +- engine_gui.c | 8 ++++---- roadveh_gui.c | 10 +++++----- ship_gui.c | 10 +++++----- strings.c | 6 +++--- train_gui.c | 16 ++++++++-------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/aircraft_gui.c b/aircraft_gui.c index 60af41598d..a2d11bdc3a 100644 --- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -36,7 +36,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number) /* Purchase cost - Max speed */ SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5); - SetDParam(1, avi->max_speed * 8); + SetDParam(1, avi->max_speed * 128 / 10); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; @@ -333,7 +333,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e) /* Draw max speed */ { - SetDParam(0, v->max_speed * 8); + SetDParam(0, v->max_speed * 128 / 10); DrawString(2, 25, STR_A00E_MAX_SPEED, 0); } @@ -520,13 +520,13 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e) switch (v->current_order.type) { case OT_GOTO_STATION: { SetDParam(0, v->current_order.station); - SetDParam(1, v->cur_speed * 8); + SetDParam(1, v->cur_speed * 128 / 10); str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; } break; case OT_GOTO_DEPOT: { SetDParam(0, v->current_order.station); - SetDParam(1, v->cur_speed * 8); + SetDParam(1, v->cur_speed * 128 / 10); str = STR_HEADING_FOR_HANGAR + _patches.vehicle_speed; } break; @@ -537,7 +537,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e) default: if (v->num_orders == 0) { str = STR_NO_ORDERS + _patches.vehicle_speed; - SetDParam(0, v->cur_speed * 8); + SetDParam(0, v->cur_speed * 128 / 10); } else { str = STR_EMPTY; } diff --git a/bridge_gui.c b/bridge_gui.c index 2913853a02..778c7b93ae 100644 --- a/bridge_gui.c +++ b/bridge_gui.c @@ -50,7 +50,7 @@ static void BuildBridgeWndProc(Window *w, WindowEvent *e) const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]]; SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]); - SetDParam(1, (b->speed >> 4) * 10); + SetDParam(1, b->speed); SetDParam(0, b->material); DrawSprite(b->sprite, 3, 15 + i * 22); diff --git a/engine_gui.c b/engine_gui.c index 88d9752555..5769c45f60 100644 --- a/engine_gui.c +++ b/engine_gui.c @@ -129,7 +129,7 @@ static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw) uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0; SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5); - SetDParam(2, rvi->max_speed * 10 >> 4); + SetDParam(2, rvi->max_speed); SetDParam(3, rvi->power << multihead); SetDParam(1, rvi->weight << multihead); @@ -177,7 +177,7 @@ static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw) { const AircraftVehicleInfo *avi = AircraftVehInfo(engine); SetDParam(0, (_price.aircraft_base >> 3) * avi->base_cost >> 5); - SetDParam(1, avi->max_speed << 3); + SetDParam(1, avi->max_speed * 128 / 10); SetDParam(2, avi->passenger_capacity); SetDParam(3, avi->mail_capacity); SetDParam(4, avi->running_cost * _price.aircraft_running >> 8); @@ -217,7 +217,7 @@ static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw) const RoadVehicleInfo *rvi = RoadVehInfo(engine); SetDParam(0, (_price.roadveh_base >> 3) * rvi->base_cost >> 5); - SetDParam(1, rvi->max_speed * 10 >> 5); + SetDParam(1, rvi->max_speed / 2); SetDParam(2, rvi->running_cost * _price.roadveh_running >> 8); SetDParam(4, rvi->capacity); @@ -256,7 +256,7 @@ static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw) { const ShipVehicleInfo *svi = ShipVehInfo(engine); SetDParam(0, svi->base_cost * (_price.ship_base >> 3) >> 5); - SetDParam(1, svi->max_speed * 10 >> 5); + SetDParam(1, svi->max_speed / 2); SetDParam(2, _cargoc.names_long[svi->cargo_type]); SetDParam(3, svi->capacity); SetDParam(4, svi->running_cost * _price.ship_running >> 8); diff --git a/roadveh_gui.c b/roadveh_gui.c index 0d53444957..a5c4876c2d 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -34,7 +34,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number) /* Purchase cost - Max speed */ SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5); - SetDParam(1, rvi->max_speed * 10 >> 5); + SetDParam(1, rvi->max_speed / 2); DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; @@ -101,7 +101,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) /* Draw max speed */ { - SetDParam(0, v->max_speed * 10 >> 5); + SetDParam(0, v->max_speed / 2); DrawString(2, 25, STR_900E_MAX_SPEED, 0); } @@ -251,14 +251,14 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) switch (v->current_order.type) { case OT_GOTO_STATION: { SetDParam(0, v->current_order.station); - SetDParam(1, v->cur_speed * 10 >> 5); + SetDParam(1, v->cur_speed / 2); str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; } break; case OT_GOTO_DEPOT: { Depot *depot = GetDepot(v->current_order.station); SetDParam(0, depot->town_index); - SetDParam(1, v->cur_speed * 10 >> 5); + SetDParam(1, v->cur_speed / 2); str = STR_HEADING_FOR_ROAD_DEPOT + _patches.vehicle_speed; } break; @@ -270,7 +270,7 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) default: if (v->num_orders == 0) { str = STR_NO_ORDERS + _patches.vehicle_speed; - SetDParam(0, v->cur_speed * 10 >> 5); + SetDParam(0, v->cur_speed / 2); } else str = STR_EMPTY; break; diff --git a/ship_gui.c b/ship_gui.c index d4b0c9deeb..c724493e21 100644 --- a/ship_gui.c +++ b/ship_gui.c @@ -33,7 +33,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number) /* Purchase cost - Max speed */ SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5); - SetDParam(1, svi->max_speed * 10 >> 5); + SetDParam(1, svi->max_speed / 2); DrawString(x,y, STR_PURCHASE_INFO_COST_SPEED, 0); y += 10; @@ -179,7 +179,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e) /* Draw max speed */ { - SetDParam(0, v->max_speed * 10 >> 5); + SetDParam(0, v->max_speed / 2); DrawString(2, 25, STR_9813_MAX_SPEED, 0); } @@ -489,14 +489,14 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) { switch (v->current_order.type) { case OT_GOTO_STATION: { SetDParam(0, v->current_order.station); - SetDParam(1, v->cur_speed * 10 >> 5); + SetDParam(1, v->cur_speed / 2); str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; } break; case OT_GOTO_DEPOT: { Depot *depot = GetDepot(v->current_order.station); SetDParam(0, depot->town_index); - SetDParam(1, v->cur_speed * 10 >> 5); + SetDParam(1, v->cur_speed / 2); str = STR_HEADING_FOR_SHIP_DEPOT + _patches.vehicle_speed; } break; @@ -508,7 +508,7 @@ static void ShipViewWndProc(Window *w, WindowEvent *e) { default: if (v->num_orders == 0) { str = STR_NO_ORDERS + _patches.vehicle_speed; - SetDParam(0, v->cur_speed * 10 >> 5); + SetDParam(0, v->cur_speed / 2); } else str = STR_EMPTY; break; diff --git a/strings.c b/strings.c index a9bd7df7b4..318f9f3f4b 100644 --- a/strings.c +++ b/strings.c @@ -499,19 +499,19 @@ typedef struct Units { static const Units units[] = { { // Imperial (Original) - 1, 0, STR_UNITS_VELOCITY_IMPERIAL, + 10, 4, STR_UNITS_VELOCITY_IMPERIAL, 1, 0, STR_UNITS_POWER_IMPERIAL, 1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, 1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, }, { // Metric - 1648, 10, STR_UNITS_VELOCITY_METRIC, + 1, 0, STR_UNITS_VELOCITY_METRIC, 1, 0, STR_UNITS_POWER_METRIC, 1, 0, STR_UNITS_WEIGHT_SHORT_METRIC, STR_UNITS_WEIGHT_LONG_METRIC, 1000, 0, STR_UNITS_VOLUME_SHORT_METRIC, STR_UNITS_VOLUME_LONG_METRIC, }, { // SI - 458, 10, STR_UNITS_VELOCITY_SI, + 284, 10, STR_UNITS_VELOCITY_SI, 764, 10, STR_UNITS_POWER_SI, 1000, 0, STR_UNITS_WEIGHT_SHORT_SI, STR_UNITS_WEIGHT_LONG_SI, 1000, 0, STR_UNITS_VOLUME_SHORT_SI, STR_UNITS_VOLUME_LONG_SI, diff --git a/train_gui.c b/train_gui.c index c65b899ffa..dc6e0f7da3 100644 --- a/train_gui.c +++ b/train_gui.c @@ -43,7 +43,7 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number) y += 10; /* Max speed - Engine power */ - SetDParam(0, rvi->max_speed * 10 >> 4); + SetDParam(0, rvi->max_speed); SetDParam(1, rvi->power << multihead); DrawString(x,y, STR_PURCHASE_INFO_SPEED_POWER, 0); y += 10; @@ -114,7 +114,7 @@ void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number) /* Wagon speed limit, displayed if above zero */ if (rvi->max_speed > 0 && _patches.wagon_speed_limits) { - SetDParam(0, rvi->max_speed * 10 >> 4); + SetDParam(0, rvi->max_speed); DrawString(x,y, STR_PURCHASE_INFO_SPEED, 0); y += 10; } @@ -932,7 +932,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) if (v->u.rail.last_speed == 0) { str = STR_8861_STOPPED; } else { - SetDParam(0, v->u.rail.last_speed * 10 >> 4); + SetDParam(0, v->u.rail.last_speed); str = STR_TRAIN_STOPPING + _patches.vehicle_speed; } } else { @@ -940,14 +940,14 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) case OT_GOTO_STATION: { str = STR_HEADING_FOR_STATION + _patches.vehicle_speed; SetDParam(0, v->current_order.station); - SetDParam(1, v->u.rail.last_speed * 10 >> 4); + SetDParam(1, v->u.rail.last_speed); } break; case OT_GOTO_DEPOT: { Depot *dep = GetDepot(v->current_order.station); SetDParam(0, dep->town_index); str = STR_HEADING_FOR_TRAIN_DEPOT + _patches.vehicle_speed; - SetDParam(1, v->u.rail.last_speed * 10 >> 4); + SetDParam(1, v->u.rail.last_speed); } break; case OT_LOADING: @@ -958,14 +958,14 @@ static void TrainViewWndProc(Window *w, WindowEvent *e) case OT_GOTO_WAYPOINT: { SetDParam(0, v->current_order.station); str = STR_HEADING_FOR_WAYPOINT + _patches.vehicle_speed; - SetDParam(1, v->u.rail.last_speed * 10 >> 4); + SetDParam(1, v->u.rail.last_speed); break; } default: if (v->num_orders == 0) { str = STR_NO_ORDERS + _patches.vehicle_speed; - SetDParam(0, v->u.rail.last_speed * 10 >> 4); + SetDParam(0, v->u.rail.last_speed); } else str = STR_EMPTY; break; @@ -1171,7 +1171,7 @@ static void DrawTrainDetailsWindow(Window *w) SetDParam(3, GetTrainRunningCost(v) >> 8); DrawString(x, 15, STR_885D_AGE_RUNNING_COST_YR, 0); - SetDParam(2, v->u.rail.cached_max_speed * 10 >> 4); + SetDParam(2, v->u.rail.cached_max_speed); SetDParam(1, v->u.rail.cached_power); SetDParam(0, v->u.rail.cached_weight); DrawString(x, 25, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, 0);