changeset 9923:82b94a0a3f6c draft

(svn r14078) -Codechange: Rename *VehicleInfo::base_cost to cost_factor, indicating what it actually is.
author peter1138 <peter1138@openttd.org>
date Fri, 15 Aug 2008 17:54:43 +0000
parents 4ab35bb4095e
children 35b1647d0db4
files src/aircraft_cmd.cpp src/build_vehicle_gui.cpp src/engine_gui.cpp src/engine_type.h src/newgrf.cpp src/roadveh_cmd.cpp src/ship_cmd.cpp src/train_cmd.cpp
diffstat 8 files changed, 30 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -228,7 +228,7 @@
 
 static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi)
 {
-	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x0B, avi->cost_factor) * (_price.aircraft_base >> 3) >> 5);
 }
 
 
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -135,8 +135,8 @@
 /* Train sorting functions */
 static int CDECL TrainEngineCostSorter(const void *a, const void *b)
 {
-	int va = RailVehInfo(*(const EngineID*)a)->base_cost;
-	int vb = RailVehInfo(*(const EngineID*)b)->base_cost;
+	int va = RailVehInfo(*(const EngineID*)a)->cost_factor;
+	int vb = RailVehInfo(*(const EngineID*)b)->cost_factor;
 	int r = va - vb;
 
 	return _internal_sort_order ? -r : r;
@@ -223,8 +223,8 @@
 /* Road vehicle sorting functions */
 static int CDECL RoadVehEngineCostSorter(const void *a, const void *b)
 {
-	int va = RoadVehInfo(*(const EngineID*)a)->base_cost;
-	int vb = RoadVehInfo(*(const EngineID*)b)->base_cost;
+	int va = RoadVehInfo(*(const EngineID*)a)->cost_factor;
+	int vb = RoadVehInfo(*(const EngineID*)b)->cost_factor;
 	int r = va - vb;
 
 	return _internal_sort_order ? -r : r;
@@ -271,8 +271,8 @@
 /* Road vehicle sorting functions */
 static int CDECL ShipEngineCostSorter(const void *a, const void *b)
 {
-	int va = ShipVehInfo(*(const EngineID*)a)->base_cost;
-	int vb = ShipVehInfo(*(const EngineID*)b)->base_cost;
+	int va = ShipVehInfo(*(const EngineID*)a)->cost_factor;
+	int vb = ShipVehInfo(*(const EngineID*)b)->cost_factor;
 	int r = va - vb;
 
 	return _internal_sort_order ? -r : r;
@@ -317,8 +317,8 @@
 
 static int CDECL AircraftEngineCostSorter(const void *a, const void *b)
 {
-	const int va = AircraftVehInfo(*(const EngineID*)a)->base_cost;
-	const int vb = AircraftVehInfo(*(const EngineID*)b)->base_cost;
+	const int va = AircraftVehInfo(*(const EngineID*)a)->cost_factor;
+	const int vb = AircraftVehInfo(*(const EngineID*)b)->cost_factor;
 	int r = va - vb;
 
 	return _internal_sort_order ? -r : r;
@@ -486,7 +486,7 @@
 static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
 {
 	/* Purchase cost */
-	SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8);
+	SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * _price.build_railwagon) >> 8);
 	DrawString(x, y, STR_PURCHASE_INFO_COST, TC_FROMSTRING);
 	y += 10;
 
@@ -524,7 +524,7 @@
 	uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight);
 
 	/* Purchase Cost - Engine weight */
-	SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5);
+	SetDParam(0, GetEngineProperty(engine_number, 0x17, rvi->cost_factor) * (_price.build_railvehicle >> 3) >> 5);
 	SetDParam(1, weight << multihead);
 	DrawString(x, y, STR_PURCHASE_INFO_COST_WEIGHT, TC_FROMSTRING);
 	y += 10;
@@ -566,7 +566,7 @@
 	bool refittable = (EngInfo(engine_number)->refit_mask != 0);
 
 	/* Purchase cost - Max speed */
-	SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->base_cost) * (_price.roadveh_base >> 3) >> 5);
+	SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->cost_factor) * (_price.roadveh_base >> 3) >> 5);
 	SetDParam(1, rvi->max_speed * 10 / 32);
 	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING);
 	y += 10;
@@ -584,7 +584,7 @@
 static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
 {
 	/* Purchase cost - Max speed */
-	SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5);
+	SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->cost_factor) * (_price.ship_base >> 3) >> 5);
 	SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32);
 	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING);
 	y += 10;
@@ -610,7 +610,7 @@
 	CargoID cargo;
 
 	/* Purchase cost - Max speed */
-	SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5);
+	SetDParam(0, GetEngineProperty(engine_number, 0x0B, avi->cost_factor) * (_price.aircraft_base >> 3) >> 5);
 	SetDParam(1, avi->max_speed * 10 / 16);
 	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, TC_FROMSTRING);
 	y += 10;
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -135,7 +135,7 @@
 	const RailVehicleInfo *rvi = RailVehInfo(engine);
 	int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0;
 
-	SetDParam(0, (_price.build_railvehicle >> 3) * GetEngineProperty(engine, 0x17, rvi->base_cost) >> 5);
+	SetDParam(0, (_price.build_railvehicle >> 3) * GetEngineProperty(engine, 0x17, rvi->cost_factor) >> 5);
 	SetDParam(2, GetEngineProperty(engine, 0x09, rvi->max_speed) * 10 / 16);
 	SetDParam(3, GetEngineProperty(engine, 0x0B, rvi->power));
 	SetDParam(1, GetEngineProperty(engine, 0x16, rvi->weight) << multihead);
@@ -155,7 +155,7 @@
 static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
 {
 	const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
-	SetDParam(0, (_price.aircraft_base >> 3) * GetEngineProperty(engine, 0x0B, avi->base_cost) >> 5);
+	SetDParam(0, (_price.aircraft_base >> 3) * GetEngineProperty(engine, 0x0B, avi->cost_factor) >> 5);
 	SetDParam(1, avi->max_speed * 10 / 16);
 	SetDParam(2, avi->passenger_capacity);
 	SetDParam(3, avi->mail_capacity);
@@ -168,7 +168,7 @@
 {
 	const RoadVehicleInfo *rvi = RoadVehInfo(engine);
 
-	SetDParam(0, (_price.roadveh_base >> 3) * GetEngineProperty(engine, 0x11, rvi->base_cost) >> 5);
+	SetDParam(0, (_price.roadveh_base >> 3) * GetEngineProperty(engine, 0x11, rvi->cost_factor) >> 5);
 	SetDParam(1, rvi->max_speed * 10 / 32);
 	SetDParam(2, rvi->running_cost * GetPriceByIndex(rvi->running_cost_class) >> 8);
 	SetDParam(3, rvi->cargo_type);
@@ -180,7 +180,7 @@
 static void DrawShipEngineInfo(EngineID engine, int x, int y, int maxw)
 {
 	const ShipVehicleInfo *svi = ShipVehInfo(engine);
-	SetDParam(0, GetEngineProperty(engine, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5);
+	SetDParam(0, GetEngineProperty(engine, 0x0A, svi->cost_factor) * (_price.ship_base >> 3) >> 5);
 	SetDParam(1, GetEngineProperty(engine, 0x0B, svi->max_speed) * 10 / 32);
 	SetDParam(2, svi->cargo_type);
 	SetDParam(3, GetEngineProperty(engine, 0x0D, svi->capacity));
--- a/src/engine_type.h
+++ b/src/engine_type.h
@@ -36,7 +36,7 @@
 struct RailVehicleInfo {
 	byte image_index;
 	RailVehicleTypes railveh_type;
-	byte base_cost;                 ///< Purchase cost factor;      For multiheaded engines the sum of both engine prices.
+	byte cost_factor;               ///< Purchase cost factor;      For multiheaded engines the sum of both engine prices.
 	RailTypeByte railtype;
 	uint16 max_speed;
 	uint16 power;                   ///< Power of engine;           For multiheaded engines the sum of both engine powers.
@@ -61,7 +61,7 @@
 
 struct ShipVehicleInfo {
 	byte image_index;
-	byte base_cost;
+	byte cost_factor;
 	uint16 max_speed;
 	CargoID cargo_type;
 	uint16 capacity;
@@ -81,7 +81,7 @@
 
 struct AircraftVehicleInfo {
 	byte image_index;
-	byte base_cost;
+	byte cost_factor;
 	byte running_cost;
 	byte subtype;
 	SoundFxByte sfx;
@@ -93,7 +93,7 @@
 
 struct RoadVehicleInfo {
 	byte image_index;
-	byte base_cost;
+	byte cost_factor;
 	byte running_cost;
 	byte running_cost_class;
 	SoundFxByte sfx;
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -546,7 +546,7 @@
 				break;
 
 			case 0x17: // Cost factor
-				rvi->base_cost = grf_load_byte(&buf);
+				rvi->cost_factor = grf_load_byte(&buf);
 				break;
 
 			case 0x18: // AI rank
@@ -735,7 +735,7 @@
 			} break;
 
 			case 0x11: // Cost factor
-				rvi->base_cost = grf_load_byte(&buf); // ?? is it base_cost?
+				rvi->cost_factor = grf_load_byte(&buf);
 				break;
 
 			case 0x12: // SFX
@@ -833,7 +833,7 @@
 				break;
 
 			case 0x0A: // Cost factor
-				svi->base_cost = grf_load_byte(&buf); // ?? is it base_cost?
+				svi->cost_factor = grf_load_byte(&buf);
 				break;
 
 			case 0x0B: // Speed (1 unit is 0.5 kmh)
@@ -952,7 +952,7 @@
 				break;
 
 			case 0x0B: // Cost factor
-				avi->base_cost = grf_load_byte(&buf); // ?? is it base_cost?
+				avi->cost_factor = grf_load_byte(&buf);
 				break;
 
 			case 0x0C: // Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h)
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -134,7 +134,7 @@
 
 static CommandCost EstimateRoadVehCost(EngineID engine_type)
 {
-	return CommandCost(EXPENSES_NEW_VEHICLES, ((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->base_cost)) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, ((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->cost_factor)) >> 5);
 }
 
 byte GetRoadVehLength(const Vehicle *v)
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -337,7 +337,7 @@
 
 static CommandCost EstimateShipCost(EngineID engine_type)
 {
-	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base >> 3) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->cost_factor) * (_price.ship_base >> 3) >> 5);
 }
 
 static void ShipArrivesAt(const Vehicle* v, Station* st)
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -610,7 +610,7 @@
 static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
 {
 	const RailVehicleInfo *rvi = RailVehInfo(engine);
-	CommandCost value(EXPENSES_NEW_VEHICLES, (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8);
+	CommandCost value(EXPENSES_NEW_VEHICLES, (GetEngineProperty(engine, 0x17, rvi->cost_factor) * _price.build_railwagon) >> 8);
 
 	uint num_vehicles = 1 + CountArticulatedParts(engine, false);
 
@@ -720,7 +720,7 @@
 
 static CommandCost EstimateTrainCost(EngineID engine, const RailVehicleInfo *rvi)
 {
-	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5);
+	return CommandCost(EXPENSES_NEW_VEHICLES, GetEngineProperty(engine, 0x17, rvi->cost_factor) * (_price.build_railvehicle >> 3) >> 5);
 }
 
 static void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool building)