Changeset - r12583:0e73b1685b49
[Not reviewed]
master
0 5 1
frosch - 15 years ago 2009-08-02 12:34:26
frosch@openttd.org
(svn r17036) -Codechange: Split price bases from economy.cpp to table/pricebase.h.
6 files changed with 107 insertions and 70 deletions:
0 comments (0 inline, 0 general)
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -2268,6 +2268,10 @@
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\pricebase.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\railtypes.h"
 
				>
 
			</File>
projects/openttd_vs90.vcproj
Show inline comments
 
@@ -2265,6 +2265,10 @@
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\pricebase.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\railtypes.h"
 
				>
 
			</File>
source.list
Show inline comments
 
@@ -515,6 +515,7 @@ table/landscape_sprite.h
 
table/namegen.h
 
table/palette_convert.h
 
table/palettes.h
 
table/pricebase.h
 
table/railtypes.h
 
table/road_land.h
 
table/roadveh_movement.h
src/economy.cpp
Show inline comments
 
@@ -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;
 
	}
src/economy_type.h
Show inline comments
 
@@ -122,6 +122,23 @@ enum ExpensesType {
 
	INVALID_EXPENSES      = 0xFF,
 
};
 

	
 
/**
 
 * Categories of a price bases.
 
 */
 
enum PriceCategory {
 
	PC_NONE,         ///< No category
 
	PC_RUNNING,      ///< Price is affected by "vehicle running cost" difficulty setting
 
	PC_CONSTRUCTION, ///< Price is affected by "construction cost" difficulty setting
 
};
 

	
 
/**
 
 * Describes properties of price bases.
 
 */
 
struct PriceBaseSpec {
 
	Money start_price;      ///< Default value at game start, before adding multipliers.
 
	PriceCategory category; ///< Price is affected by certain difficulty settings.
 
};
 

	
 
/** The "steps" in loan size, in British Pounds! */
 
static const int LOAN_INTERVAL = 10000;
 

	
src/table/pricebase.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file pricebase.h Price Bases */
 

	
 
static PriceBaseSpec _price_base_specs[NUM_PRICES] = {
 
	{    100, PC_NONE        }, ///< station_value
 
	{    100, PC_CONSTRUCTION}, ///< build_rail
 
	{     95, PC_CONSTRUCTION}, ///< build_road
 
	{     65, PC_CONSTRUCTION}, ///< build_signals
 
	{    275, PC_CONSTRUCTION}, ///< build_bridge
 
	{    600, PC_CONSTRUCTION}, ///< build_train_depot
 
	{    500, PC_CONSTRUCTION}, ///< build_road_depot
 
	{    700, PC_CONSTRUCTION}, ///< build_ship_depot
 
	{    450, PC_CONSTRUCTION}, ///< build_tunnel
 
	{    200, PC_CONSTRUCTION}, ///< train_station_track
 
	{    180, PC_CONSTRUCTION}, ///< train_station_length
 
	{    600, PC_CONSTRUCTION}, ///< build_airport
 
	{    200, PC_CONSTRUCTION}, ///< build_bus_station
 
	{    200, PC_CONSTRUCTION}, ///< build_truck_station
 
	{    350, PC_CONSTRUCTION}, ///< build_dock
 
	{ 400000, PC_CONSTRUCTION}, ///< build_railvehicle
 
	{   2000, PC_CONSTRUCTION}, ///< build_railwagon
 
	{ 700000, PC_CONSTRUCTION}, ///< aircraft_base
 
	{  14000, PC_CONSTRUCTION}, ///< roadveh_base
 
	{  65000, PC_CONSTRUCTION}, ///< ship_base
 
	{     20, PC_CONSTRUCTION}, ///< build_trees
 
	{    250, PC_CONSTRUCTION}, ///< terraform
 
	{     20, PC_CONSTRUCTION}, ///< clear_grass
 
	{     40, PC_CONSTRUCTION}, ///< clear_roughland
 
	{    200, PC_CONSTRUCTION}, ///< clear_rocks
 
	{    500, PC_CONSTRUCTION}, ///< clear_fields
 
	{     20, PC_CONSTRUCTION}, ///< remove_trees
 
	{    -70, PC_CONSTRUCTION}, ///< remove_rail
 
	{     10, PC_CONSTRUCTION}, ///< remove_signals
 
	{     50, PC_CONSTRUCTION}, ///< clear_bridge
 
	{     80, PC_CONSTRUCTION}, ///< remove_train_depot
 
	{     80, PC_CONSTRUCTION}, ///< remove_road_depot
 
	{     90, PC_CONSTRUCTION}, ///< remove_ship_depot
 
	{     30, PC_CONSTRUCTION}, ///< clear_tunnel
 
	{  10000, PC_CONSTRUCTION}, ///< clear_water
 
	{     50, PC_CONSTRUCTION}, ///< remove_rail_station
 
	{     30, PC_CONSTRUCTION}, ///< remove_airport
 
	{     50, PC_CONSTRUCTION}, ///< remove_bus_station
 
	{     50, PC_CONSTRUCTION}, ///< remove_truck_station
 
	{     55, PC_CONSTRUCTION}, ///< remove_dock
 
	{   1600, PC_CONSTRUCTION}, ///< remove_house
 
	{     40, PC_CONSTRUCTION}, ///< remove_road
 
	{   5600, PC_RUNNING     }, ///< running_rail[0] steam
 
	{   5200, PC_RUNNING     }, ///< running_rail[1] diesel
 
	{   4800, PC_RUNNING     }, ///< running_rail[2] electric
 
	{   9600, PC_RUNNING     }, ///< aircraft_running
 
	{   1600, PC_RUNNING     }, ///< roadveh_running
 
	{   5600, PC_RUNNING     }, ///< ship_running
 
	{1000000, PC_CONSTRUCTION}, ///< build_industry
 
};
0 comments (0 inline, 0 general)