changeset 3477:a247df51f17b draft

(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.
author peter1138 <peter1138@openttd.org>
date Sat, 08 Apr 2006 12:04:23 +0000
parents 798ceee089b7
children aa6e289cd887
files aircraft_gui.c bridge_gui.c engine_gui.c roadveh_gui.c ship_gui.c strings.c train_gui.c
diffstat 7 files changed, 31 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -36,7 +36,7 @@
 
 	/* 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 @@
 
 		/* 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 @@
 			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 @@
 			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;
 				}
--- a/bridge_gui.c
+++ b/bridge_gui.c
@@ -50,7 +50,7 @@
 			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);
 
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -129,7 +129,7 @@
 	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 @@
 {
 	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 @@
 	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 @@
 {
 	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);
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -34,7 +34,7 @@
 
 	/* 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 @@
 
 		/* 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 @@
 			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 @@
 			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;
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -33,7 +33,7 @@
 
 	/* 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 @@
 
 		/* 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 @@
 				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 @@
 					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;
--- a/strings.c
+++ b/strings.c
@@ -499,19 +499,19 @@
 
 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,
--- a/train_gui.c
+++ b/train_gui.c
@@ -43,7 +43,7 @@
 	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 @@
 
 	/* 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 @@
 			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 @@
 			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 @@
 			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 @@
 	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);