engine_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 ENGINE_TYPE_H
00013 #define ENGINE_TYPE_H
00014 
00015 #include "economy_type.h"
00016 #include "rail_type.h"
00017 #include "cargo_type.h"
00018 #include "date_type.h"
00019 #include "sound_type.h"
00020 #include "strings_type.h"
00021 
00022 typedef uint16 EngineID; 
00023 
00024 struct Engine;
00025 
00027 enum RailVehicleTypes {
00028   RAILVEH_SINGLEHEAD,  
00029   RAILVEH_MULTIHEAD,   
00030   RAILVEH_WAGON,       
00031 };
00032 
00034 enum EngineClass {
00035   EC_STEAM,    
00036   EC_DIESEL,   
00037   EC_ELECTRIC, 
00038   EC_MONORAIL, 
00039   EC_MAGLEV,   
00040 };
00041 
00043 struct RailVehicleInfo {
00044   byte image_index;
00045   RailVehicleTypes railveh_type;
00046   byte cost_factor;               
00047   RailTypeByte railtype;
00048   uint16 max_speed;               
00049   uint16 power;                   
00050   uint16 weight;                  
00051   byte running_cost;              
00052   Price running_cost_class;
00053   EngineClass engclass;           
00054   byte capacity;                  
00055   byte ai_passenger_only;         
00056   uint16 pow_wag_power;           
00057   byte pow_wag_weight;            
00058   byte visual_effect;             
00059   byte shorten_factor;            
00060   byte tractive_effort;           
00061   byte air_drag;                  
00062   byte user_def_data;             
00063 };
00064 
00066 struct ShipVehicleInfo {
00067   byte image_index;
00068   byte cost_factor;
00069   uint16 max_speed;      
00070   uint16 capacity;
00071   byte running_cost;
00072   SoundID sfx;
00073   bool old_refittable;   
00074   byte visual_effect;    
00075   byte ocean_speed_frac; 
00076   byte canal_speed_frac; 
00077 
00079   uint ApplyWaterClassSpeedFrac(uint raw_speed, bool is_ocean) const
00080   {
00081     /* speed_frac == 0 means no reduction while 0xFF means reduction to 1/256. */
00082     return raw_speed * (256 - (is_ocean ? this->ocean_speed_frac : this->canal_speed_frac)) / 256;
00083   }
00084 };
00085 
00091 enum AircraftSubTypeBits {
00092   AIR_HELI = 0,
00093   AIR_CTOL = 1, 
00094   AIR_FAST = 2
00095 };
00096 
00098 struct AircraftVehicleInfo {
00099   byte image_index;
00100   byte cost_factor;
00101   byte running_cost;
00102   byte subtype;               
00103   SoundID sfx;
00104   byte acceleration;
00105   uint16 max_speed;           
00106   byte mail_capacity;         
00107   uint16 passenger_capacity;  
00108 };
00109 
00111 struct RoadVehicleInfo {
00112   byte image_index;
00113   byte cost_factor;
00114   byte running_cost;
00115   Price running_cost_class;
00116   SoundID sfx;
00117   uint16 max_speed;        
00118   byte capacity;
00119   uint8 weight;            
00120   uint8 power;             
00121   uint8 tractive_effort;   
00122   uint8 air_drag;          
00123   byte visual_effect;      
00124   byte shorten_factor;     
00125 };
00126 
00131 struct EngineInfo {
00132   Date base_intro;    
00133   Year lifelength;    
00134   Year base_life;     
00135   byte decay_speed;
00136   byte load_amount;
00137   byte climates;      
00138   CargoID cargo_type;
00139   uint32 refit_mask;
00140   byte refit_cost;
00141   byte misc_flags;    
00142   byte callback_mask; 
00143   int8 retire_early;  
00144   StringID string_id; 
00145   uint16 cargo_age_period; 
00146 };
00147 
00151 enum EngineMiscFlags {
00152   EF_RAIL_TILTS = 0, 
00153   EF_ROAD_TRAM  = 0, 
00154   EF_USES_2CC   = 1, 
00155   EF_RAIL_IS_MU = 2, 
00156   EF_RAIL_FLIPS = 3, 
00157   EF_AUTO_REFIT = 4, 
00158 };
00159 
00163 enum EngineFlags {
00164   ENGINE_AVAILABLE         = 1, 
00165   ENGINE_EXCLUSIVE_PREVIEW = 2, 
00166   ENGINE_OFFER_WINDOW_OPEN = 4, 
00167 };
00168 
00169 static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32; 
00170 
00171 static const EngineID INVALID_ENGINE = 0xFFFF; 
00172 
00173 #endif /* ENGINE_TYPE_H */