summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-08-02 12:34:26 +0000
committerfrosch <frosch@openttd.org>2009-08-02 12:34:26 +0000
commita6cbf0d419569989d54f6df37232e9e771acafa8 (patch)
treed3263e8de74e831af809bc3318becad666d8918b /src/economy.cpp
parent053ba65836d98b73f2061a2d92681cce30380f1e (diff)
downloadopenttd-a6cbf0d419569989d54f6df37232e9e771acafa8.tar.xz
(svn r17036) -Codechange: Split price bases from economy.cpp to table/pricebase.h.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp96
1 files changed, 26 insertions, 70 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 6052c524e..a9cb34aea 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -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;
}