src/economy_type.h
author smatz
Sat, 13 Dec 2008 15:59:25 +0000
changeset 10416 b35c0a4c73c5
parent 10146 cfea97f96067
permissions -rw-r--r--
(svn r14669) -Codechange: use SmallVector instead of std::list at one place
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     1
/* $Id$ */
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     2
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     3
/** @file economy_type.h Types related to the economy. */
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     4
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     5
#ifndef ECONOMY_TYPE_H
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     6
#define ECONOMY_TYPE_H
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     7
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     8
#include "core/overflowsafe_type.hpp"
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
     9
#include "core/enum_type.hpp"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8116
diff changeset
    10
#include "cargo_type.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    11
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    12
typedef OverflowSafeInt64 Money;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    13
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    14
struct Economy {
10146
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    15
	Money max_loan;                       ///< Maximum possible loan
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    16
	Money max_loan_unround;               ///< Economy fluctuation status
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    17
	uint16 max_loan_unround_fract;        ///< Fraction of the unrounded max loan
9623
fce00b25b921 (svn r13679) -Fix [FS#2131]: saving TTD imported games in recession failed due to wrong (and unneeded) type conversions in the saveload code.
rubidium
parents: 9438
diff changeset
    18
	int16 fluct;
10146
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    19
	byte interest_rate;                   ///< Interest
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    20
	byte infl_amount;                     ///< inflation amount
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    21
	byte infl_amount_pr;                  ///< inflation rate for payment rates
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    22
	uint32 industry_daily_change_counter; ///< Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily
cfea97f96067 (svn r14332) -Fix[FS#1885]: Balance the monthly random industry changes, by introducing a daily random industry change.
belugas
parents: 9623
diff changeset
    23
	uint32 industry_daily_increment;      ///< The value which will increment industry_daily_change_counter. Computed value. NOSAVE
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    24
};
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    25
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    26
struct Subsidy {
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    27
	CargoID cargo_type;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    28
	byte age;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    29
	/* from and to can either be TownID, StationID or IndustryID */
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    30
	uint16 from;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    31
	uint16 to;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    32
};
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    33
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    34
enum ScoreID {
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    35
	SCORE_BEGIN      = 0,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    36
	SCORE_VEHICLES   = 0,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    37
	SCORE_STATIONS   = 1,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    38
	SCORE_MIN_PROFIT = 2,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    39
	SCORE_MIN_INCOME = 3,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    40
	SCORE_MAX_INCOME = 4,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    41
	SCORE_DELIVERED  = 5,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    42
	SCORE_CARGO      = 6,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    43
	SCORE_MONEY      = 7,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    44
	SCORE_LOAN       = 8,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    45
	SCORE_TOTAL      = 9,  ///< This must always be the last entry
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    46
	SCORE_END        = 10, ///< How many scores are there..
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    47
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    48
	SCORE_MAX = 1000       ///< The max score that can be in the performance history
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    49
	/* the scores together of score_info is allowed to be more! */
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    50
};
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    51
DECLARE_POSTFIX_INCREMENT(ScoreID);
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    52
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    53
struct ScoreInfo {
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    54
	byte id;    ///< Unique ID of the score
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    55
	int needed; ///< How much you need to get the perfect score
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    56
	int score;  ///< How much score it will give
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    57
};
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    58
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    59
struct Prices {
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    60
	Money station_value;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    61
	Money build_rail;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    62
	Money build_road;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    63
	Money build_signals;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    64
	Money build_bridge;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    65
	Money build_train_depot;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    66
	Money build_road_depot;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    67
	Money build_ship_depot;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    68
	Money build_tunnel;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    69
	Money train_station_track;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    70
	Money train_station_length;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    71
	Money build_airport;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    72
	Money build_bus_station;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    73
	Money build_truck_station;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    74
	Money build_dock;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    75
	Money build_railvehicle;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    76
	Money build_railwagon;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    77
	Money aircraft_base;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    78
	Money roadveh_base;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    79
	Money ship_base;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    80
	Money build_trees;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    81
	Money terraform;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    82
	Money clear_grass;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    83
	Money clear_roughland;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    84
	Money clear_rocks;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    85
	Money clear_fields;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    86
	Money remove_trees;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    87
	Money remove_rail;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    88
	Money remove_signals;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    89
	Money clear_bridge;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    90
	Money remove_train_depot;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    91
	Money remove_road_depot;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    92
	Money remove_ship_depot;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    93
	Money clear_tunnel;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    94
	Money clear_water;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    95
	Money remove_rail_station;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    96
	Money remove_airport;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    97
	Money remove_bus_station;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    98
	Money remove_truck_station;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
    99
	Money remove_dock;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   100
	Money remove_house;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   101
	Money remove_road;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   102
	Money running_rail[3];
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   103
	Money aircraft_running;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   104
	Money roadveh_running;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   105
	Money ship_running;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   106
	Money build_industry;
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   107
};
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   108
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   109
enum {
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   110
	NUM_PRICES = 49,
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   111
};
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   112
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   113
assert_compile(NUM_PRICES * sizeof(Money) == sizeof(Prices));
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   114
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   115
enum ExpensesType {
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   116
	EXPENSES_CONSTRUCTION =  0,
8515
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   117
	EXPENSES_NEW_VEHICLES,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   118
	EXPENSES_TRAIN_RUN,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   119
	EXPENSES_ROADVEH_RUN,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   120
	EXPENSES_AIRCRAFT_RUN,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   121
	EXPENSES_SHIP_RUN,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   122
	EXPENSES_PROPERTY,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   123
	EXPENSES_TRAIN_INC,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   124
	EXPENSES_ROADVEH_INC,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   125
	EXPENSES_AIRCRAFT_INC,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   126
	EXPENSES_SHIP_INC,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   127
	EXPENSES_LOAN_INT,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   128
	EXPENSES_OTHER,
20b5c6e8415e (svn r12090) -Codechange : removed a magic number and code style application on enum ExpensesType
belugas
parents: 8254
diff changeset
   129
	EXPENSES_END,
8230
64f28fe2d5c8 (svn r11793) -Codechange: pass the expense type via the CommandCost instead of a global variable. Patch by Noldo (FS#1114).
rubidium
parents: 8119
diff changeset
   130
	INVALID_EXPENSES      = 0xFF,
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   131
};
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   132
8254
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8230
diff changeset
   133
/* The "steps" in loan size, in British Pounds! */
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8230
diff changeset
   134
enum {
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8230
diff changeset
   135
	LOAN_INTERVAL        = 10000,
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8230
diff changeset
   136
	LOAN_INTERVAL_OLD_AI = 50000,
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8230
diff changeset
   137
};
1496654ca5e7 (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8230
diff changeset
   138
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
diff changeset
   139
#endif /* ECONOMY_TYPE_H */