economy_type.h

Go to the documentation of this file.
00001 /* $Id$ */
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 
00018 typedef OverflowSafeInt64 Money;
00019 
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 
00038 enum ScoreID {
00039   SCORE_BEGIN      = 0,
00040   SCORE_VEHICLES   = 0,
00041   SCORE_STATIONS   = 1,
00042   SCORE_MIN_PROFIT = 2,
00043   SCORE_MIN_INCOME = 3,
00044   SCORE_MAX_INCOME = 4,
00045   SCORE_DELIVERED  = 5,
00046   SCORE_CARGO      = 6,
00047   SCORE_MONEY      = 7,
00048   SCORE_LOAN       = 8,
00049   SCORE_TOTAL      = 9,  
00050   SCORE_END        = 10, 
00051 
00052   SCORE_MAX = 1000       
00053   /* the scores together of score_info is allowed to be more! */
00054 };
00055 DECLARE_POSTFIX_INCREMENT(ScoreID)
00056 
00057 
00058 struct ScoreInfo {
00059   int needed; 
00060   int score;  
00061 };
00062 
00067 enum Price {
00068   PR_BEGIN = 0,
00069   PR_STATION_VALUE = 0,
00070   PR_BUILD_RAIL,
00071   PR_BUILD_ROAD,
00072   PR_BUILD_SIGNALS,
00073   PR_BUILD_BRIDGE,
00074   PR_BUILD_DEPOT_TRAIN,
00075   PR_BUILD_DEPOT_ROAD,
00076   PR_BUILD_DEPOT_SHIP,
00077   PR_BUILD_TUNNEL,
00078   PR_BUILD_STATION_RAIL,
00079   PR_BUILD_STATION_RAIL_LENGTH,
00080   PR_BUILD_STATION_AIRPORT,
00081   PR_BUILD_STATION_BUS,
00082   PR_BUILD_STATION_TRUCK,
00083   PR_BUILD_STATION_DOCK,
00084   PR_BUILD_VEHICLE_TRAIN,
00085   PR_BUILD_VEHICLE_WAGON,
00086   PR_BUILD_VEHICLE_AIRCRAFT,
00087   PR_BUILD_VEHICLE_ROAD,
00088   PR_BUILD_VEHICLE_SHIP,
00089   PR_BUILD_TREES,
00090   PR_TERRAFORM,
00091   PR_CLEAR_GRASS,
00092   PR_CLEAR_ROUGH,
00093   PR_CLEAR_ROCKS,
00094   PR_CLEAR_FIELDS,
00095   PR_CLEAR_TREES,
00096   PR_CLEAR_RAIL,
00097   PR_CLEAR_SIGNALS,
00098   PR_CLEAR_BRIDGE,
00099   PR_CLEAR_DEPOT_TRAIN,
00100   PR_CLEAR_DEPOT_ROAD,
00101   PR_CLEAR_DEPOT_SHIP,
00102   PR_CLEAR_TUNNEL,
00103   PR_CLEAR_WATER,
00104   PR_CLEAR_STATION_RAIL,
00105   PR_CLEAR_STATION_AIRPORT,
00106   PR_CLEAR_STATION_BUS,
00107   PR_CLEAR_STATION_TRUCK,
00108   PR_CLEAR_STATION_DOCK,
00109   PR_CLEAR_HOUSE,
00110   PR_CLEAR_ROAD,
00111   PR_RUNNING_TRAIN_STEAM,
00112   PR_RUNNING_TRAIN_DIESEL,
00113   PR_RUNNING_TRAIN_ELECTRIC,
00114   PR_RUNNING_AIRCRAFT,
00115   PR_RUNNING_ROADVEH,
00116   PR_RUNNING_SHIP,
00117   PR_BUILD_INDUSTRY,
00118   PR_CLEAR_INDUSTRY,
00119   PR_BUILD_OBJECT,
00120   PR_CLEAR_OBJECT,
00121   PR_BUILD_WAYPOINT_RAIL,
00122   PR_CLEAR_WAYPOINT_RAIL,
00123   PR_BUILD_WAYPOINT_BUOY,
00124   PR_CLEAR_WAYPOINT_BUOY,
00125   PR_TOWN_ACTION,
00126   PR_BUILD_FOUNDATION,
00127   PR_BUILD_INDUSTRY_RAW,
00128   PR_BUILD_TOWN,
00129   PR_BUILD_CANAL,
00130   PR_CLEAR_CANAL,
00131   PR_BUILD_AQUEDUCT,
00132   PR_CLEAR_AQUEDUCT,
00133   PR_BUILD_LOCK,
00134   PR_CLEAR_LOCK,
00135 
00136   PR_END,
00137   INVALID_PRICE = 0xFF
00138 };
00139 DECLARE_POSTFIX_INCREMENT(Price)
00140 
00141 typedef Money Prices[PR_END]; 
00142 typedef int8 PriceMultipliers[PR_END];
00143 
00145 enum ExpensesType {
00146   EXPENSES_CONSTRUCTION =  0,   
00147   EXPENSES_NEW_VEHICLES,        
00148   EXPENSES_TRAIN_RUN,           
00149   EXPENSES_ROADVEH_RUN,         
00150   EXPENSES_AIRCRAFT_RUN,        
00151   EXPENSES_SHIP_RUN,            
00152   EXPENSES_PROPERTY,            
00153   EXPENSES_TRAIN_INC,           
00154   EXPENSES_ROADVEH_INC,         
00155   EXPENSES_AIRCRAFT_INC,        
00156   EXPENSES_SHIP_INC,            
00157   EXPENSES_LOAN_INT,            
00158   EXPENSES_OTHER,               
00159   EXPENSES_END,                 
00160   INVALID_EXPENSES      = 0xFF, 
00161 };
00162 
00166 enum PriceCategory {
00167   PCAT_NONE,         
00168   PCAT_RUNNING,      
00169   PCAT_CONSTRUCTION, 
00170 };
00171 
00175 struct PriceBaseSpec {
00176   Money start_price;      
00177   PriceCategory category; 
00178   uint grf_feature;       
00179   Price fallback_price;   
00180 };
00181 
00183 static const int LOAN_INTERVAL = 10000;
00184 
00193 static const uint64 MAX_INFLATION = (1ull << (63 - 32)) - 1;
00194 
00200 static const int MIN_PRICE_MODIFIER = -8;
00201 static const int MAX_PRICE_MODIFIER = 16;
00202 static const int INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1;
00203 
00204 struct CargoPayment;
00205 typedef uint32 CargoPaymentID;
00206 
00207 #endif /* ECONOMY_TYPE_H */

Generated on Mon May 9 05:18:52 2011 for OpenTTD by  doxygen 1.6.1