# economy_type.h

Go to the documentation of this file.

    00001 /* $Id: economy_type.h 18284 2009-11-24 23:34:46Z frosch $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef ECONOMY_TYPE_H
    00013 #define ECONOMY_TYPE_H
    00014
    00015 #include "core/overflowsafe_type.hpp"
    00016 #include "core/enum_type.hpp"
    00017 #include "cargo_type.h"
    00018
    00019 typedef OverflowSafeInt64 Money;
    00020
    00021 struct Economy {
    00022   Money max_loan;
    00023   int16 fluct;
    00024   byte interest_rate;
    00025   byte infl_amount;
    00026   byte infl_amount_pr;
    00027   uint32 industry_daily_change_counter;
    00028   uint32 industry_daily_increment;
    00029   uint64 inflation_prices;
    00030   uint64 inflation_payment;
    00031
    00032   /* Old stuff for savegame conversion only */
    00033   Money old_max_loan_unround;
    00034   uint16 old_max_loan_unround_fract;
    00035 };
    00036
    00037 enum ScoreID {
    00038   SCORE_BEGIN      = 0,
    00039   SCORE_VEHICLES   = 0,
    00040   SCORE_STATIONS   = 1,
    00041   SCORE_MIN_PROFIT = 2,
    00042   SCORE_MIN_INCOME = 3,
    00043   SCORE_MAX_INCOME = 4,
    00044   SCORE_DELIVERED  = 5,
    00045   SCORE_CARGO      = 6,
    00046   SCORE_MONEY      = 7,
    00047   SCORE_LOAN       = 8,
    00048   SCORE_TOTAL      = 9,
    00049   SCORE_END        = 10,
    00050
    00051   SCORE_MAX = 1000
    00052   /* the scores together of score_info is allowed to be more! */
    00053 };
    00054 DECLARE_POSTFIX_INCREMENT(ScoreID);
    00055
    00056 struct ScoreInfo {
    00057   byte id;
    00058   int needed;
    00059   int score;
    00060 };
    00061
    00066 enum Price {
    00067   PR_BEGIN = 0,
    00068   PR_STATION_VALUE = 0,
    00069   PR_BUILD_RAIL,
    00070   PR_BUILD_ROAD,
    00071   PR_BUILD_SIGNALS,
    00072   PR_BUILD_BRIDGE,
    00073   PR_BUILD_DEPOT_TRAIN,
    00074   PR_BUILD_DEPOT_ROAD,
    00075   PR_BUILD_DEPOT_SHIP,
    00076   PR_BUILD_TUNNEL,
    00077   PR_BUILD_STATION_RAIL,
    00078   PR_BUILD_STATION_RAIL_LENGTH,
    00079   PR_BUILD_STATION_AIRPORT,
    00080   PR_BUILD_STATION_BUS,
    00081   PR_BUILD_STATION_TRUCK,
    00082   PR_BUILD_STATION_DOCK,
    00083   PR_BUILD_VEHICLE_TRAIN,
    00084   PR_BUILD_VEHICLE_WAGON,
    00085   PR_BUILD_VEHICLE_AIRCRAFT,
    00086   PR_BUILD_VEHICLE_ROAD,
    00087   PR_BUILD_VEHICLE_SHIP,
    00088   PR_BUILD_TREES,
    00089   PR_TERRAFORM,
    00090   PR_CLEAR_GRASS,
    00091   PR_CLEAR_ROUGH,
    00092   PR_CLEAR_ROCKS,
    00093   PR_CLEAR_FILEDS,
    00094   PR_CLEAR_TREES,
    00095   PR_CLEAR_RAIL,
    00096   PR_CLEAR_SIGNALS,
    00097   PR_CLEAR_BRIDGE,
    00098   PR_CLEAR_DEPOT_TRAIN,
    00099   PR_CLEAR_DEPOT_ROAD,
    00100   PR_CLEAR_DEPOT_SHIP,
    00101   PR_CLEAR_TUNNEL,
    00102   PR_CLEAR_WATER,
    00103   PR_CLEAR_STATION_RAIL,
    00104   PR_CLEAR_STATION_AIRPORT,
    00105   PR_CLEAR_STATION_BUS,
    00106   PR_CLEAR_STATION_TRUCK,
    00107   PR_CLEAR_STATION_DOCK,
    00108   PR_CLEAR_HOUSE,
    00109   PR_CLEAR_ROAD,
    00110   PR_RUNNING_TRAIN_STEAM,
    00111   PR_RUNNING_TRAIN_DIESEL,
    00112   PR_RUNNING_TRAIN_ELECTRIC,
    00113   PR_RUNNING_AIRCRAFT,
    00114   PR_RUNNING_ROADVEH,
    00115   PR_RUNNING_SHIP,
    00116   PR_BUILD_INDUSTRY,
    00117   PR_CLEAR_INDUSTRY,
    00118   PR_BUILD_UNMOVABLE,
    00119   PR_CLEAR_UNMOVABLE,
    00120   PR_BUILD_WAYPOINT_RAIL,
    00121   PR_CLEAR_WAYPOINT_RAIL,
    00122   PR_BUILD_WAYPOINT_BUOY,
    00123   PR_CLEAR_WAYPOINT_BUOY,
    00124   PR_TOWN_ACTION,
    00125   PR_BUILD_FOUNDATION,
    00126   PR_BUILD_INDUSTRY_RAW,
    00127   PR_BUILD_TOWN,
    00128
    00129   PR_END,
    00130   INVALID_PRICE = 0xFF
    00131 };
    00132 DECLARE_POSTFIX_INCREMENT(Price)
    00133
    00134 typedef Money Prices[PR_END];
    00135 typedef int8 PriceMultipliers[PR_END];
    00136
    00137 enum ExpensesType {
    00138   EXPENSES_CONSTRUCTION =  0,
    00139   EXPENSES_NEW_VEHICLES,
    00140   EXPENSES_TRAIN_RUN,
    00141   EXPENSES_ROADVEH_RUN,
    00142   EXPENSES_AIRCRAFT_RUN,
    00143   EXPENSES_SHIP_RUN,
    00144   EXPENSES_PROPERTY,
    00145   EXPENSES_TRAIN_INC,
    00146   EXPENSES_ROADVEH_INC,
    00147   EXPENSES_AIRCRAFT_INC,
    00148   EXPENSES_SHIP_INC,
    00149   EXPENSES_LOAN_INT,
    00150   EXPENSES_OTHER,
    00151   EXPENSES_END,
    00152   INVALID_EXPENSES      = 0xFF,
    00153 };
    00154
    00158 enum PriceCategory {
    00159   PCAT_NONE,
    00160   PCAT_RUNNING,
    00161   PCAT_CONSTRUCTION,
    00162 };
    00163
    00167 struct PriceBaseSpec {
    00168   Money start_price;
    00169   PriceCategory category;
    00170   uint grf_feature;
    00171   Price fallback_price;
    00172 };
    00173
    00175 static const int LOAN_INTERVAL = 10000;
    00176
    00185 static const uint64 MAX_INFLATION = (1ull << (63 - 32)) - 1;
    00186
    00192 enum {
    00193   MIN_PRICE_MODIFIER = -8,
    00194   MAX_PRICE_MODIFIER = 16,
    00195   INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1,
    00196 };
    00197
    00198 struct CargoPayment;
    00199 typedef uint32 CargoPaymentID;
    00200
    00201 #endif /* ECONOMY_TYPE_H */