src/build_vehicle_gui.cpp
branchgamebalance
changeset 9903 dc85aaa556ae
parent 9895 7bd07f43b0e3
child 9907 3b068c3a1c74
--- a/src/build_vehicle_gui.cpp	Fri Mar 23 12:03:41 2007 +0000
+++ b/src/build_vehicle_gui.cpp	Sat Mar 31 12:34:36 2007 +0000
@@ -201,9 +201,24 @@
 {
 	const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
 	const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
+	uint32 cost_class_a, cost_class_b;
 
-	int va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
-	int vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+	switch (rvi_a->running_cost_class) {
+		default:
+		case 0: cost_class_a = _eco->GetPrice(CEconomy::RUNNING_RAIL0); break;
+		case 1: cost_class_a = _eco->GetPrice(CEconomy::RUNNING_RAIL1); break;
+		case 2: cost_class_a = _eco->GetPrice(CEconomy::RUNNING_RAIL2); break;
+	}
+
+	switch (rvi_b->running_cost_class) {
+		default:
+		case 0: cost_class_b = _eco->GetPrice(CEconomy::RUNNING_RAIL0); break;
+		case 1: cost_class_b = _eco->GetPrice(CEconomy::RUNNING_RAIL1); break;
+		case 2: cost_class_b = _eco->GetPrice(CEconomy::RUNNING_RAIL2); break;
+	}
+
+	int va = rvi_a->running_cost_base * cost_class_a * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+	int vb = rvi_b->running_cost_base * cost_class_b * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
 	int r = va - vb;
 
 	return _internal_sort_order ? -r : r;
@@ -213,6 +228,21 @@
 {
 	const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
 	const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
+	uint32 cost_class_a, cost_class_b;
+
+	switch (rvi_a->running_cost_class) {
+		default:
+		case 0: cost_class_a = _eco->GetPrice(CEconomy::RUNNING_RAIL0); break;
+		case 1: cost_class_a = _eco->GetPrice(CEconomy::RUNNING_RAIL1); break;
+		case 2: cost_class_a = _eco->GetPrice(CEconomy::RUNNING_RAIL2); break;
+	}
+
+	switch (rvi_b->running_cost_class) {
+		default:
+		case 0: cost_class_b = _eco->GetPrice(CEconomy::RUNNING_RAIL0); break;
+		case 1: cost_class_b = _eco->GetPrice(CEconomy::RUNNING_RAIL1); break;
+		case 2: cost_class_b = _eco->GetPrice(CEconomy::RUNNING_RAIL2); break;
+	}
 
 	/* Here we are using a few tricks to get the right sort.
 		* We want power/running cost, but since we usually got higher running cost than power and we store the result in an int,
@@ -220,8 +250,8 @@
 		* Because of this, the return value have to be reversed as well and we return b - a instead of a - b.
 		* Another thing is that both power and running costs should be doubled for multiheaded engines.
 		* Since it would be multipling with 2 in both numerator and denumerator, it will even themselves out and we skip checking for multiheaded. */
-	int va = (rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class]) / max((uint16)1, rvi_a->power);
-	int vb = (rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class]) / max((uint16)1, rvi_b->power);
+	int va = rvi_a->running_cost_base * cost_class_a / max((uint16)1, rvi_a->power);
+	int vb = rvi_b->running_cost_base * cost_class_b / max((uint16)1, rvi_b->power);
 	int r = vb - va;
 
 	return _internal_sort_order ? -r : r;
@@ -378,7 +408,7 @@
 static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
 {
 	/* Purchase cost */
-	SetDParam(0, (rvi->base_cost * _price.build_railwagon) >> 8);
+	SetDParam(0, (rvi->base_cost * _eco->GetPrice(CEconomy::BUILD_RAILWAGON)) >> 8);
 	DrawString(x, y, STR_PURCHASE_INFO_COST, 0);
 	y += 10;
 
@@ -403,7 +433,7 @@
 	int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
 
 	/* Purchase Cost - Engine weight */
-	SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5);
+	SetDParam(0, rvi->base_cost * (_eco->GetPrice(CEconomy::BUILD_RAILVEHICLE) >> 3) >> 5);
 	SetDParam(1, rvi->weight << multihead);
 	DrawString(x,y, STR_PURCHASE_INFO_COST_WEIGHT, 0);
 	y += 10;
@@ -421,8 +451,17 @@
 		y += 10;
 	}
 
+	uint32 cost_class;
+
+	switch (rvi->running_cost_class) {
+		default:
+		case 0: cost_class = _eco->GetPrice(CEconomy::RUNNING_RAIL0); break;
+		case 1: cost_class = _eco->GetPrice(CEconomy::RUNNING_RAIL1); break;
+		case 2: cost_class = _eco->GetPrice(CEconomy::RUNNING_RAIL2); break;
+	}
+
 	/* Running cost */
-	SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead);
+	SetDParam(0, (rvi->running_cost_base * cost_class >> 8) << multihead);
 	DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 	y += 10;
 
@@ -443,13 +482,13 @@
 	bool refittable = (_engine_info[engine_number].refit_mask != 0);
 
 	/* Purchase cost - Max speed */
-	SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5);
+	SetDParam(0, rvi->base_cost * (_eco->GetPrice(CEconomy::ROADVEH_BASE) >> 3) >> 5);
 	SetDParam(1, rvi->max_speed * 10 / 32);
 	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
 	y += 10;
 
 	/* Running cost */
-	SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8);
+	SetDParam(0, rvi->running_cost * _eco->GetPrice(CEconomy::ROADVEH_RUNNING) >> 8);
 	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 	y += 10;
 
@@ -467,7 +506,7 @@
 static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
 {
 	/* Purchase cost - Max speed */
-	SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5);
+	SetDParam(0, svi->base_cost * (_eco->GetPrice(CEconomy::SHIP_BASE) >> 3) >> 5);
 	SetDParam(1, svi->max_speed * 10 / 32);
 	DrawString(x,y, STR_PURCHASE_INFO_COST_SPEED, 0);
 	y += 10;
@@ -480,7 +519,7 @@
 	y += 10;
 
 	/* Running cost */
-	SetDParam(0, svi->running_cost * _price.ship_running >> 8);
+	SetDParam(0, svi->running_cost * _eco->GetPrice(CEconomy::SHIP_RUNNING) >> 8);
 	DrawString(x,y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 	y += 10;
 
@@ -493,7 +532,7 @@
 	CargoID cargo;
 
 	/* Purchase cost - Max speed */
-	SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5);
+	SetDParam(0, avi->base_cost * (_eco->GetPrice(CEconomy::AIRCRAFT_BASE) >> 3) >> 5);
 	SetDParam(1, avi->max_speed * 10 / 16);
 	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
 	y += 10;
@@ -515,7 +554,7 @@
 	y += 10;
 
 	/* Running cost */
-	SetDParam(0, avi->running_cost * _price.aircraft_running >> 8);
+	SetDParam(0, avi->running_cost * _eco->GetPrice(CEconomy::AIRCRAFT_RUNNING) >> 8);
 	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 	y += 10;