(svn r17036) -Codechange: Split price bases from economy.cpp to table/pricebase.h.

This commit is contained in:
frosch
2009-08-02 12:34:26 +00:00
parent f554d21349
commit 8b50754b19
6 changed files with 107 additions and 70 deletions

View File

@@ -42,6 +42,7 @@
#include "table/strings.h"
#include "table/sprites.h"
#include "table/pricebase.h"
/* Initialize the cargo payment-pool */
@@ -683,67 +684,6 @@ static void HandleEconomyFluctuations()
}
}
static byte _price_category[NUM_PRICES] = {
0, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 1, 1, 1, 1, 1, 1,
2,
};
static const Money _price_base[NUM_PRICES] = {
100, ///< station_value
100, ///< build_rail
95, ///< build_road
65, ///< build_signals
275, ///< build_bridge
600, ///< build_train_depot
500, ///< build_road_depot
700, ///< build_ship_depot
450, ///< build_tunnel
200, ///< train_station_track
180, ///< train_station_length
600, ///< build_airport
200, ///< build_bus_station
200, ///< build_truck_station
350, ///< build_dock
400000, ///< build_railvehicle
2000, ///< build_railwagon
700000, ///< aircraft_base
14000, ///< roadveh_base
65000, ///< ship_base
20, ///< build_trees
250, ///< terraform
20, ///< clear_grass
40, ///< clear_roughland
200, ///< clear_rocks
500, ///< clear_fields
20, ///< remove_trees
-70, ///< remove_rail
10, ///< remove_signals
50, ///< clear_bridge
80, ///< remove_train_depot
80, ///< remove_road_depot
90, ///< remove_ship_depot
30, ///< clear_tunnel
10000, ///< clear_water
50, ///< remove_rail_station
30, ///< remove_airport
50, ///< remove_bus_station
50, ///< remove_truck_station
55, ///< remove_dock
1600, ///< remove_house
40, ///< remove_road
5600, ///< running_rail[0] steam
5200, ///< running_rail[1] diesel
4800, ///< running_rail[2] electric
9600, ///< aircraft_running
1600, ///< roadveh_running
5600, ///< ship_running
1000000, ///< build_industry
};
static byte price_base_multiplier[NUM_PRICES];
@@ -799,21 +739,37 @@ void StartupEconomy()
assert(sizeof(_price) == NUM_PRICES * sizeof(Money));
for (i = 0; i != NUM_PRICES; i++) {
Money price = _price_base[i];
if (_price_category[i] != 0) {
uint mod = _price_category[i] == 1 ? _settings_game.difficulty.vehicle_costs : _settings_game.difficulty.construction_cost;
if (mod < 1) {
price = price * 3 >> 2;
} else if (mod > 1) {
price = price * 9 >> 3;
}
/* Setup price bases */
for (i = 0; i < NUM_PRICES; i++) {
Money price = _price_base_specs[i].start_price;
/* Apply difficulty settings */
uint mod = 1;
switch (_price_base_specs[i].category) {
case PC_RUNNING:
mod = _settings_game.difficulty.vehicle_costs;
break;
case PC_CONSTRUCTION:
mod = _settings_game.difficulty.construction_cost;
break;
default: break;
}
if (mod < 1) {
price = price * 3 >> 2;
} else if (mod > 1) {
price = price * 9 >> 3;
}
/* Apply newgrf modifiers */
if (price_base_multiplier[i] > 8) {
price <<= price_base_multiplier[i] - 8;
} else {
price >>= 8 - price_base_multiplier[i];
}
/* Store start value */
((Money*)&_price)[i] = price;
_price_frac[i] = 0;
}