settings_type.h

Go to the documentation of this file.
00001 /* $Id: settings_type.h 23795 2012-01-13 21:54:59Z rubidium $ */
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 SETTINGS_TYPE_H
00013 #define SETTINGS_TYPE_H
00014 
00015 #include "date_type.h"
00016 #include "town_type.h"
00017 #include "transport_type.h"
00018 #include "network/core/config.h"
00019 #include "company_type.h"
00020 #include "openttd.h"
00021 
00023 enum IndustryDensity {
00024   ID_FUND_ONLY, 
00025   ID_MINIMAL,   
00026   ID_VERY_LOW,  
00027   ID_LOW,       
00028   ID_NORMAL,    
00029   ID_HIGH,      
00030 
00031   ID_END,       
00032 };
00033 
00035 struct DifficultySettings {
00036   byte   max_no_competitors;               
00037   byte   number_towns;                     
00038   byte   industry_density;                 
00039   uint32 max_loan;                         
00040   byte   initial_interest;                 
00041   byte   vehicle_costs;                    
00042   byte   competitor_speed;                 
00043   byte   vehicle_breakdowns;               
00044   byte   subsidy_multiplier;               
00045   byte   construction_cost;                
00046   byte   terrain_type;                     
00047   byte   quantity_sea_lakes;               
00048   byte   economy;                          
00049   byte   line_reverse_mode;                
00050   byte   disasters;                        
00051   byte   town_council_tolerance;           
00052   byte   diff_level;                       
00053 };
00054 
00056 struct GUISettings {
00057   bool   sg_full_load_any;                 
00058   bool   lost_vehicle_warn;                
00059   uint8  order_review_system;              
00060   bool   vehicle_income_warn;              
00061   bool   show_finances;                    
00062   bool   sg_new_nonstop;                   
00063   bool   new_nonstop;                      
00064   uint8  stop_location;                    
00065   bool   autoscroll;                       
00066   byte   errmsg_duration;                  
00067   byte   hover_delay;                      
00068   bool   link_terraform_toolbar;           
00069   uint8  smallmap_land_colour;             
00070   bool   reverse_scroll;                   
00071   bool   smooth_scroll;                    
00072   bool   measure_tooltip;                  
00073   byte   liveries;                         
00074   bool   prefer_teamchat;                  
00075   uint8  advanced_vehicle_list;            
00076   uint8  loading_indicators;               
00077   uint8  default_rail_type;                
00078   uint8  toolbar_pos;                      
00079   uint8  statusbar_pos;                    
00080   uint8  window_snap_radius;               
00081   uint8  window_soft_limit;                
00082   bool   disable_unsuitable_building;      
00083   byte   autosave;                         
00084   bool   threaded_saves;                   
00085   bool   keep_all_autosave;                
00086   bool   autosave_on_exit;                 
00087   uint8  date_format_in_default_names;     
00088   byte   max_num_autosaves;                
00089   bool   population_in_label;              
00090   uint8  right_mouse_btn_emulation;        
00091   uint8  scrollwheel_scrolling;            
00092   uint8  scrollwheel_multiplier;           
00093   bool   timetable_arrival_departure;      
00094   bool   left_mouse_btn_scrolling;         
00095   bool   pause_on_newgame;                 
00096   bool   enable_signal_gui;                
00097   Year   coloured_news_year;               
00098   bool   timetable_in_ticks;               
00099   bool   quick_goto;                       
00100   bool   auto_euro;                        
00101   byte   drag_signals_density;             
00102   Year   semaphore_build_before;           
00103   byte   news_message_timeout;             
00104   bool   show_track_reservation;           
00105   uint8  default_signal_type;              
00106   uint8  cycle_signal_types;               
00107   byte   station_numtracks;                
00108   byte   station_platlength;               
00109   bool   station_dragdrop;                 
00110   bool   station_show_coverage;            
00111   bool   persistent_buildingtools;         
00112   bool   expenses_layout;                  
00113 
00114   uint16 console_backlog_timeout;          
00115   uint16 console_backlog_length;           
00116 #ifdef ENABLE_NETWORK
00117   uint16 network_chat_box_width;           
00118   uint8  network_chat_box_height;          
00119   uint16 network_chat_timeout;             
00120 #endif
00121 
00122   uint8  developer;                        
00123   bool   show_date_in_logs;                
00124   bool   newgrf_developer_tools;           
00125   bool   ai_developer_tools;               
00126   bool   scenario_developer;               
00127   bool   newgrf_show_old_versions;         
00128 
00133   bool UserIsAllowedToChangeNewGRFs() const
00134   {
00135     return this->scenario_developer || this->newgrf_developer_tools;
00136   }
00137 };
00138 
00140 struct LocaleSettings {
00141   byte   currency;                         
00142   byte   units;                            
00143   char  *digit_group_separator;            
00144   char  *digit_group_separator_currency;   
00145   char  *digit_decimal_separator;          
00146 };
00147 
00149 struct NetworkSettings {
00150 #ifdef ENABLE_NETWORK
00151   uint16 sync_freq;                                     
00152   uint8  frame_freq;                                    
00153   uint16 commands_per_frame;                            
00154   uint16 max_commands_in_queue;                         
00155   uint16 bytes_per_frame;                               
00156   uint16 bytes_per_frame_burst;                         
00157   uint16 max_join_time;                                 
00158   uint16 max_download_time;                             
00159   uint16 max_password_time;                             
00160   bool   pause_on_join;                                 
00161   uint16 server_port;                                   
00162   uint16 server_admin_port;                             
00163   bool   server_admin_chat;                             
00164   char   server_name[NETWORK_NAME_LENGTH];              
00165   char   server_password[NETWORK_PASSWORD_LENGTH];      
00166   char   rcon_password[NETWORK_PASSWORD_LENGTH];        
00167   char   admin_password[NETWORK_PASSWORD_LENGTH];       
00168   bool   server_advertise;                              
00169   uint8  lan_internet;                                  
00170   char   client_name[NETWORK_CLIENT_NAME_LENGTH];       
00171   char   default_company_pass[NETWORK_PASSWORD_LENGTH]; 
00172   char   connect_to_ip[NETWORK_HOSTNAME_LENGTH];        
00173   char   network_id[NETWORK_SERVER_ID_LENGTH];          
00174   bool   autoclean_companies;                           
00175   uint8  autoclean_unprotected;                         
00176   uint8  autoclean_protected;                           
00177   uint8  autoclean_novehicles;                          
00178   uint8  max_companies;                                 
00179   uint8  max_clients;                                   
00180   uint8  max_spectators;                                
00181   Year   restart_game_year;                             
00182   uint8  min_active_clients;                            
00183   uint8  server_lang;                                   
00184   bool   reload_cfg;                                    
00185   char   last_host[NETWORK_HOSTNAME_LENGTH];            
00186   uint16 last_port;                                     
00187   bool   no_http_content_downloads;                     
00188 #else /* ENABLE_NETWORK */
00189 #endif
00190 };
00191 
00193 struct GameCreationSettings {
00194   uint32 generation_seed;                  
00195   Year   starting_year;                    
00196   uint8  map_x;                            
00197   uint8  map_y;                            
00198   byte   land_generator;                   
00199   byte   oil_refinery_limit;               
00200   byte   snow_line_height;                 
00201   byte   tgen_smoothness;                  
00202   byte   tree_placer;                      
00203   byte   heightmap_rotation;               
00204   byte   se_flat_world_height;             
00205   byte   town_name;                        
00206   byte   landscape;                        
00207   byte   snow_line;                        
00208   byte   water_borders;                    
00209   uint16 custom_town_number;               
00210   byte   variety;                          
00211   byte   custom_sea_level;                 
00212 };
00213 
00215 struct ConstructionSettings {
00216   bool   build_on_slopes;                  
00217   bool   autoslope;                        
00218   uint16 max_bridge_length;                
00219   uint16 max_tunnel_length;                
00220   bool   signal_side;                      
00221   bool   extra_dynamite;                   
00222   bool   road_stop_on_town_road;           
00223   bool   road_stop_on_competitor_road;     
00224   uint8  raw_industry_construction;        
00225   uint8  industry_platform;                
00226   bool   freeform_edges;                   
00227   uint8  extra_tree_placement;             
00228   uint8  command_pause_level;              
00229 
00230   uint32 terraform_per_64k_frames;         
00231   uint16 terraform_frame_burst;            
00232   uint32 clear_per_64k_frames;             
00233   uint16 clear_frame_burst;                
00234 };
00235 
00237 struct AISettings {
00238   bool   ai_in_multiplayer;                
00239   bool   ai_disable_veh_train;             
00240   bool   ai_disable_veh_roadveh;           
00241   bool   ai_disable_veh_aircraft;          
00242   bool   ai_disable_veh_ship;              
00243   uint32 ai_max_opcode_till_suspend;       
00244 };
00245 
00247 struct OPFSettings {
00248   uint16 pf_maxlength;                     
00249   byte   pf_maxdepth;                      
00250 };
00251 
00253 struct NPFSettings {
00259   uint32 npf_max_search_nodes;
00260   uint32 maximum_go_to_depot_penalty;      
00261 
00262   uint32 npf_rail_firstred_penalty;        
00263   uint32 npf_rail_firstred_exit_penalty;   
00264   uint32 npf_rail_lastred_penalty;         
00265   uint32 npf_rail_station_penalty;         
00266   uint32 npf_rail_slope_penalty;           
00267   uint32 npf_rail_curve_penalty;           
00268   uint32 npf_rail_depot_reverse_penalty;   
00269   uint32 npf_rail_pbs_cross_penalty;       
00270   uint32 npf_rail_pbs_signal_back_penalty; 
00271   uint32 npf_buoy_penalty;                 
00272   uint32 npf_water_curve_penalty;          
00273   uint32 npf_road_curve_penalty;           
00274   uint32 npf_crossing_penalty;             
00275   uint32 npf_road_drive_through_penalty;   
00276   uint32 npf_road_dt_occupied_penalty;     
00277   uint32 npf_road_bay_occupied_penalty;    
00278 };
00279 
00281 struct YAPFSettings {
00282   bool   disable_node_optimization;        
00283   uint32 max_search_nodes;                 
00284   uint32 maximum_go_to_depot_penalty;      
00285   bool   ship_use_yapf;                    
00286   bool   road_use_yapf;                    
00287   bool   rail_use_yapf;                    
00288   uint32 road_slope_penalty;               
00289   uint32 road_curve_penalty;               
00290   uint32 road_crossing_penalty;            
00291   uint32 road_stop_penalty;                
00292   uint32 road_stop_occupied_penalty;       
00293   uint32 road_stop_bay_occupied_penalty;   
00294   bool   rail_firstred_twoway_eol;         
00295   uint32 rail_firstred_penalty;            
00296   uint32 rail_firstred_exit_penalty;       
00297   uint32 rail_lastred_penalty;             
00298   uint32 rail_lastred_exit_penalty;        
00299   uint32 rail_station_penalty;             
00300   uint32 rail_slope_penalty;               
00301   uint32 rail_curve45_penalty;             
00302   uint32 rail_curve90_penalty;             
00303   uint32 rail_depot_reverse_penalty;       
00304   uint32 rail_crossing_penalty;            
00305   uint32 rail_look_ahead_max_signals;      
00306   int32  rail_look_ahead_signal_p0;        
00307   int32  rail_look_ahead_signal_p1;        
00308   int32  rail_look_ahead_signal_p2;        
00309   uint32 rail_pbs_cross_penalty;           
00310   uint32 rail_pbs_station_penalty;         
00311   uint32 rail_pbs_signal_back_penalty;     
00312   uint32 rail_doubleslip_penalty;          
00313 
00314   uint32 rail_longer_platform_penalty;           
00315   uint32 rail_longer_platform_per_tile_penalty;  
00316   uint32 rail_shorter_platform_penalty;          
00317   uint32 rail_shorter_platform_per_tile_penalty; 
00318 };
00319 
00321 struct PathfinderSettings {
00322   uint8  pathfinder_for_trains;            
00323   uint8  pathfinder_for_roadvehs;          
00324   uint8  pathfinder_for_ships;             
00325   bool   new_pathfinding_all;              
00326 
00327   bool   roadveh_queue;                    
00328   bool   forbid_90_deg;                    
00329 
00330   bool   reverse_at_signals;               
00331   byte   wait_oneway_signal;               
00332   byte   wait_twoway_signal;               
00333 
00334   bool   reserve_paths;                    
00335   byte   wait_for_pbs_path;                
00336   byte   path_backoff_interval;            
00337 
00338   OPFSettings  opf;                        
00339   NPFSettings  npf;                        
00340   YAPFSettings yapf;                       
00341 };
00342 
00344 struct OrderSettings {
00345   bool   improved_load;                    
00346   bool   gradual_loading;                  
00347   bool   selectgoods;                      
00348   bool   no_servicing_if_no_breakdowns;    
00349   bool   serviceathelipad;                 
00350 };
00351 
00353 struct VehicleSettings {
00354   uint8  max_train_length;                 
00355   uint8  smoke_amount;                     
00356   uint8  train_acceleration_model;         
00357   uint8  roadveh_acceleration_model;       
00358   uint8  train_slope_steepness;            
00359   uint8  roadveh_slope_steepness;          
00360   bool   wagon_speed_limits;               
00361   bool   disable_elrails;                  
00362   UnitID max_trains;                       
00363   UnitID max_roadveh;                      
00364   UnitID max_aircraft;                     
00365   UnitID max_ships;                        
00366   uint8  plane_speed;                      
00367   uint8  freight_trains;                   
00368   bool   dynamic_engines;                  
00369   bool   never_expire_vehicles;            
00370   byte   extend_vehicle_life;              
00371   byte   road_side;                        
00372   uint8  plane_crashes;                    
00373 };
00374 
00376 struct EconomySettings {
00377   bool   inflation;                        
00378   bool   bribe;                            
00379   bool   smooth_economy;                   
00380   bool   allow_shares;                     
00381   uint8  feeder_payment_share;             
00382   byte   dist_local_authority;             
00383   bool   exclusive_rights;                 
00384   bool   fund_roads;                       
00385   bool   give_money;                       
00386   bool   mod_road_rebuild;                 
00387   bool   multiple_industry_per_town;       
00388   uint8  town_growth_rate;                 
00389   uint8  larger_towns;                     
00390   uint8  initial_city_size;                
00391   TownLayoutByte town_layout;              
00392   bool   allow_town_roads;                 
00393   TownFoundingByte found_town;             
00394   bool   station_noise_level;              
00395   uint16 town_noise_population[3];         
00396   bool   allow_town_level_crossings;       
00397 };
00398 
00400 struct StationSettings {
00401   bool   modified_catchment;               
00402   bool   adjacent_stations;                
00403   bool   distant_join_stations;            
00404   bool   never_expire_airports;            
00405   byte   station_spread;                   
00406 };
00407 
00409 struct VehicleDefaultSettings {
00410   bool   servint_ispercent;                
00411   uint16 servint_trains;                   
00412   uint16 servint_roadveh;                  
00413   uint16 servint_aircraft;                 
00414   uint16 servint_ships;                    
00415 };
00416 
00418 struct CompanySettings {
00419   bool engine_renew;                       
00420   int16 engine_renew_months;               
00421   uint32 engine_renew_money;               
00422   bool renew_keep_length;                  
00423   VehicleDefaultSettings vehicle;          
00424 };
00425 
00427 struct GameSettings {
00428   DifficultySettings   difficulty;         
00429   GameCreationSettings game_creation;      
00430   ConstructionSettings construction;       
00431   AISettings           ai;                 
00432   class AIConfig      *ai_config[MAX_COMPANIES]; 
00433   PathfinderSettings   pf;                 
00434   OrderSettings        order;              
00435   VehicleSettings      vehicle;            
00436   EconomySettings      economy;            
00437   StationSettings      station;            
00438   LocaleSettings       locale;             
00439 };
00440 
00442 struct ClientSettings {
00443   GUISettings          gui;                
00444   NetworkSettings      network;            
00445   CompanySettings      company;            
00446 };
00447 
00449 extern ClientSettings _settings_client;
00450 
00452 extern GameSettings _settings_game;
00453 
00455 extern GameSettings _settings_newgame;
00456 
00458 extern VehicleDefaultSettings _old_vds;
00459 
00464 static inline GameSettings &GetGameSettings()
00465 {
00466   return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
00467 }
00468 
00469 #endif /* SETTINGS_TYPE_H */