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   uint16 max_range;           
00109 };
00110 
00112 struct RoadVehicleInfo {
00113   byte image_index;
00114   byte cost_factor;
00115   byte running_cost;
00116   Price running_cost_class;
00117   SoundID sfx;
00118   uint16 max_speed;        
00119   byte capacity;
00120   uint8 weight;            
00121   uint8 power;             
00122   uint8 tractive_effort;   
00123   uint8 air_drag;          
00124   byte visual_effect;      
00125   byte shorten_factor;     
00126 };
00127 
00132 struct EngineInfo {
00133   Date base_intro;    
00134   Year lifelength;    
00135   Year base_life;     
00136   byte decay_speed;
00137   byte load_amount;
00138   byte climates;      
00139   CargoID cargo_type;
00140   uint32 refit_mask;
00141   byte refit_cost;
00142   byte misc_flags;    
00143   byte callback_mask; 
00144   int8 retire_early;  
00145   StringID string_id; 
00146   uint16 cargo_age_period; 
00147 };
00148 
00152 enum EngineMiscFlags {
00153   EF_RAIL_TILTS = 0, 
00154   EF_ROAD_TRAM  = 0, 
00155   EF_USES_2CC   = 1, 
00156   EF_RAIL_IS_MU = 2, 
00157   EF_RAIL_FLIPS = 3, 
00158   EF_AUTO_REFIT = 4, 
00159   EF_NO_DEFAULT_CARGO_MULTIPLIER = 5, 
00160   EF_NO_BREAKDOWN_SMOKE          = 6, 
00161 };
00162 
00166 enum EngineFlags {
00167   ENGINE_AVAILABLE         = 1, 
00168   ENGINE_EXCLUSIVE_PREVIEW = 2, 
00169   ENGINE_OFFER_WINDOW_OPEN = 4, 
00170 };
00171 
00172 static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32; 
00173 
00174 static const EngineID INVALID_ENGINE = 0xFFFF; 
00175 
00176 #endif /* ENGINE_TYPE_H */