settings_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 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 "cargotype.h"
00021 #include "linkgraph/linkgraph_type.h"
00022 #include "zoom_type.h"
00023 #include "openttd.h"
00024 
00026 enum IndustryDensity {
00027   ID_FUND_ONLY, 
00028   ID_MINIMAL,   
00029   ID_VERY_LOW,  
00030   ID_LOW,       
00031   ID_NORMAL,    
00032   ID_HIGH,      
00033 
00034   ID_END,       
00035 };
00036 
00038 struct DifficultySettings {
00039   byte   max_no_competitors;               
00040   byte   number_towns;                     
00041   byte   industry_density;                 
00042   uint32 max_loan;                         
00043   byte   initial_interest;                 
00044   byte   vehicle_costs;                    
00045   byte   competitor_speed;                 
00046   byte   vehicle_breakdowns;               
00047   byte   subsidy_multiplier;               
00048   byte   construction_cost;                
00049   byte   terrain_type;                     
00050   byte   quantity_sea_lakes;               
00051   byte   economy;                          
00052   byte   line_reverse_mode;                
00053   byte   disasters;                        
00054   byte   town_council_tolerance;           
00055   byte   diff_level;                       
00056 };
00057 
00059 struct GUISettings {
00060   bool   sg_full_load_any;                 
00061   bool   lost_vehicle_warn;                
00062   uint8  order_review_system;              
00063   bool   vehicle_income_warn;              
00064   bool   show_finances;                    
00065   bool   sg_new_nonstop;                   
00066   bool   new_nonstop;                      
00067   uint8  stop_location;                    
00068   bool   autoscroll;                       
00069   byte   errmsg_duration;                  
00070   byte   hover_delay;                      
00071   bool   link_terraform_toolbar;           
00072   uint8  smallmap_land_colour;             
00073   bool   reverse_scroll;                   
00074   bool   smooth_scroll;                    
00075   bool   measure_tooltip;                  
00076   byte   liveries;                         
00077   bool   prefer_teamchat;                  
00078   uint8  advanced_vehicle_list;            
00079   uint8  loading_indicators;               
00080   uint8  default_rail_type;                
00081   uint8  toolbar_pos;                      
00082   uint8  statusbar_pos;                    
00083   uint8  window_snap_radius;               
00084   uint8  window_soft_limit;                
00085   ZoomLevelByte zoom_min;                  
00086   ZoomLevelByte zoom_max;                  
00087   bool   disable_unsuitable_building;      
00088   byte   autosave;                         
00089   bool   threaded_saves;                   
00090   bool   keep_all_autosave;                
00091   bool   autosave_on_exit;                 
00092   uint8  date_format_in_default_names;     
00093   byte   max_num_autosaves;                
00094   bool   population_in_label;              
00095   uint8  right_mouse_btn_emulation;        
00096   uint8  scrollwheel_scrolling;            
00097   uint8  scrollwheel_multiplier;           
00098   bool   timetable_arrival_departure;      
00099   bool   left_mouse_btn_scrolling;         
00100   bool   pause_on_newgame;                 
00101   bool   enable_signal_gui;                
00102   Year   coloured_news_year;               
00103   bool   timetable_in_ticks;               
00104   bool   quick_goto;                       
00105   bool   auto_euro;                        
00106   byte   drag_signals_density;             
00107   Year   semaphore_build_before;           
00108   byte   news_message_timeout;             
00109   bool   show_track_reservation;           
00110   uint8  default_signal_type;              
00111   uint8  cycle_signal_types;               
00112   byte   station_numtracks;                
00113   byte   station_platlength;               
00114   bool   station_dragdrop;                 
00115   bool   station_show_coverage;            
00116   bool   persistent_buildingtools;         
00117   bool   expenses_layout;                  
00118   uint32 last_newgrf_count;                
00119   byte   missing_strings_threshold;        
00120 
00121   uint16 console_backlog_timeout;          
00122   uint16 console_backlog_length;           
00123 
00124   uint8  station_gui_group_order;          
00125   uint8  station_gui_sort_by;              
00126   uint8  station_gui_sort_order;           
00127 #ifdef ENABLE_NETWORK
00128   uint16 network_chat_box_width;           
00129   uint8  network_chat_box_height;          
00130   uint16 network_chat_timeout;             
00131 #endif
00132 
00133   uint8  developer;                        
00134   bool   show_date_in_logs;                
00135   bool   newgrf_developer_tools;           
00136   bool   ai_developer_tools;               
00137   bool   scenario_developer;               
00138   bool   newgrf_show_old_versions;         
00139   uint8  newgrf_default_palette;           
00140 
00145   bool UserIsAllowedToChangeNewGRFs() const
00146   {
00147     return this->scenario_developer || this->newgrf_developer_tools;
00148   }
00149 };
00150 
00152 struct MusicSettings {
00153   byte playlist;     
00154   byte music_vol;    
00155   byte effect_vol;   
00156   byte custom_1[33]; 
00157   byte custom_2[33]; 
00158   bool playing;      
00159   bool shuffle;      
00160 };
00161 
00163 struct LocaleSettings {
00164   byte   currency;                         
00165   byte   units;                            
00166   char  *digit_group_separator;            
00167   char  *digit_group_separator_currency;   
00168   char  *digit_decimal_separator;          
00169 };
00170 
00172 struct NetworkSettings {
00173 #ifdef ENABLE_NETWORK
00174   uint16 sync_freq;                                     
00175   uint8  frame_freq;                                    
00176   uint16 commands_per_frame;                            
00177   uint16 max_commands_in_queue;                         
00178   uint16 bytes_per_frame;                               
00179   uint16 bytes_per_frame_burst;                         
00180   uint16 max_join_time;                                 
00181   bool   pause_on_join;                                 
00182   uint16 server_port;                                   
00183   uint16 server_admin_port;                             
00184   bool   server_admin_chat;                             
00185   char   server_name[NETWORK_NAME_LENGTH];              
00186   char   server_password[NETWORK_PASSWORD_LENGTH];      
00187   char   rcon_password[NETWORK_PASSWORD_LENGTH];        
00188   char   admin_password[NETWORK_PASSWORD_LENGTH];       
00189   bool   server_advertise;                              
00190   uint8  lan_internet;                                  
00191   char   client_name[NETWORK_CLIENT_NAME_LENGTH];       
00192   char   default_company_pass[NETWORK_PASSWORD_LENGTH]; 
00193   char   connect_to_ip[NETWORK_HOSTNAME_LENGTH];        
00194   char   network_id[NETWORK_SERVER_ID_LENGTH];          
00195   bool   autoclean_companies;                           
00196   uint8  autoclean_unprotected;                         
00197   uint8  autoclean_protected;                           
00198   uint8  autoclean_novehicles;                          
00199   uint8  max_companies;                                 
00200   uint8  max_clients;                                   
00201   uint8  max_spectators;                                
00202   Year   restart_game_year;                             
00203   uint8  min_active_clients;                            
00204   uint8  server_lang;                                   
00205   bool   reload_cfg;                                    
00206   char   last_host[NETWORK_HOSTNAME_LENGTH];            
00207   uint16 last_port;                                     
00208   bool   no_http_content_downloads;                     
00209 #else /* ENABLE_NETWORK */
00210 #endif
00211 };
00212 
00214 struct GameCreationSettings {
00215   uint32 generation_seed;                  
00216   Year   starting_year;                    
00217   uint8  map_x;                            
00218   uint8  map_y;                            
00219   byte   land_generator;                   
00220   byte   oil_refinery_limit;               
00221   byte   snow_line_height;                 
00222   byte   tgen_smoothness;                  
00223   byte   tree_placer;                      
00224   byte   heightmap_rotation;               
00225   byte   se_flat_world_height;             
00226   byte   town_name;                        
00227   byte   landscape;                        
00228   byte   water_borders;                    
00229   uint16 custom_town_number;               
00230   byte   variety;                          
00231   byte   custom_sea_level;                 
00232   byte   min_river_length;                 
00233   byte   river_route_random;               
00234   byte   amount_of_rivers;                 
00235 };
00236 
00238 struct ConstructionSettings {
00239   bool   build_on_slopes;                  
00240   bool   autoslope;                        
00241   uint16 max_bridge_length;                
00242   uint16 max_tunnel_length;                
00243   bool   signal_side;                      
00244   bool   extra_dynamite;                   
00245   bool   road_stop_on_town_road;           
00246   bool   road_stop_on_competitor_road;     
00247   uint8  raw_industry_construction;        
00248   uint8  industry_platform;                
00249   bool   freeform_edges;                   
00250   uint8  extra_tree_placement;             
00251   uint8  command_pause_level;              
00252 
00253   uint32 terraform_per_64k_frames;         
00254   uint16 terraform_frame_burst;            
00255   uint32 clear_per_64k_frames;             
00256   uint16 clear_frame_burst;                
00257 };
00258 
00260 struct AISettings {
00261   bool   ai_in_multiplayer;                
00262   bool   ai_disable_veh_train;             
00263   bool   ai_disable_veh_roadveh;           
00264   bool   ai_disable_veh_aircraft;          
00265   bool   ai_disable_veh_ship;              
00266 };
00267 
00269 struct ScriptSettings {
00270   uint32 script_max_opcode_till_suspend;   
00271 };
00272 
00274 struct OPFSettings {
00275   uint16 pf_maxlength;                     
00276   byte   pf_maxdepth;                      
00277 };
00278 
00280 struct NPFSettings {
00286   uint32 npf_max_search_nodes;
00287   uint32 maximum_go_to_depot_penalty;      
00288 
00289   uint32 npf_rail_firstred_penalty;        
00290   uint32 npf_rail_firstred_exit_penalty;   
00291   uint32 npf_rail_lastred_penalty;         
00292   uint32 npf_rail_station_penalty;         
00293   uint32 npf_rail_slope_penalty;           
00294   uint32 npf_rail_curve_penalty;           
00295   uint32 npf_rail_depot_reverse_penalty;   
00296   uint32 npf_rail_pbs_cross_penalty;       
00297   uint32 npf_rail_pbs_signal_back_penalty; 
00298   uint32 npf_buoy_penalty;                 
00299   uint32 npf_water_curve_penalty;          
00300   uint32 npf_road_curve_penalty;           
00301   uint32 npf_crossing_penalty;             
00302   uint32 npf_road_drive_through_penalty;   
00303   uint32 npf_road_dt_occupied_penalty;     
00304   uint32 npf_road_bay_occupied_penalty;    
00305 };
00306 
00308 struct YAPFSettings {
00309   bool   disable_node_optimization;        
00310   uint32 max_search_nodes;                 
00311   uint32 maximum_go_to_depot_penalty;      
00312   bool   ship_use_yapf;                    
00313   bool   road_use_yapf;                    
00314   bool   rail_use_yapf;                    
00315   uint32 road_slope_penalty;               
00316   uint32 road_curve_penalty;               
00317   uint32 road_crossing_penalty;            
00318   uint32 road_stop_penalty;                
00319   uint32 road_stop_occupied_penalty;       
00320   uint32 road_stop_bay_occupied_penalty;   
00321   bool   rail_firstred_twoway_eol;         
00322   uint32 rail_firstred_penalty;            
00323   uint32 rail_firstred_exit_penalty;       
00324   uint32 rail_lastred_penalty;             
00325   uint32 rail_lastred_exit_penalty;        
00326   uint32 rail_station_penalty;             
00327   uint32 rail_slope_penalty;               
00328   uint32 rail_curve45_penalty;             
00329   uint32 rail_curve90_penalty;             
00330   uint32 rail_depot_reverse_penalty;       
00331   uint32 rail_crossing_penalty;            
00332   uint32 rail_look_ahead_max_signals;      
00333   int32  rail_look_ahead_signal_p0;        
00334   int32  rail_look_ahead_signal_p1;        
00335   int32  rail_look_ahead_signal_p2;        
00336   uint32 rail_pbs_cross_penalty;           
00337   uint32 rail_pbs_station_penalty;         
00338   uint32 rail_pbs_signal_back_penalty;     
00339   uint32 rail_doubleslip_penalty;          
00340 
00341   uint32 rail_longer_platform_penalty;           
00342   uint32 rail_longer_platform_per_tile_penalty;  
00343   uint32 rail_shorter_platform_penalty;          
00344   uint32 rail_shorter_platform_per_tile_penalty; 
00345 };
00346 
00348 struct PathfinderSettings {
00349   uint8  pathfinder_for_trains;            
00350   uint8  pathfinder_for_roadvehs;          
00351   uint8  pathfinder_for_ships;             
00352   bool   new_pathfinding_all;              
00353 
00354   bool   roadveh_queue;                    
00355   bool   forbid_90_deg;                    
00356 
00357   bool   reverse_at_signals;               
00358   byte   wait_oneway_signal;               
00359   byte   wait_twoway_signal;               
00360 
00361   bool   reserve_paths;                    
00362   byte   wait_for_pbs_path;                
00363   byte   path_backoff_interval;            
00364 
00365   OPFSettings  opf;                        
00366   NPFSettings  npf;                        
00367   YAPFSettings yapf;                       
00368 };
00369 
00371 struct OrderSettings {
00372   bool   improved_load;                    
00373   bool   gradual_loading;                  
00374   bool   selectgoods;                      
00375   bool   no_servicing_if_no_breakdowns;    
00376   bool   serviceathelipad;                 
00377 };
00378 
00380 struct VehicleSettings {
00381   uint8  max_train_length;                 
00382   uint8  smoke_amount;                     
00383   uint8  train_acceleration_model;         
00384   uint8  roadveh_acceleration_model;       
00385   uint8  train_slope_steepness;            
00386   uint8  roadveh_slope_steepness;          
00387   bool   wagon_speed_limits;               
00388   bool   disable_elrails;                  
00389   UnitID max_trains;                       
00390   UnitID max_roadveh;                      
00391   UnitID max_aircraft;                     
00392   UnitID max_ships;                        
00393   uint8  plane_speed;                      
00394   uint8  freight_trains;                   
00395   bool   dynamic_engines;                  
00396   bool   never_expire_vehicles;            
00397   byte   extend_vehicle_life;              
00398   byte   road_side;                        
00399   uint8  plane_crashes;                    
00400 };
00401 
00403 struct EconomySettings {
00404   bool   inflation;                        
00405   bool   bribe;                            
00406   bool   smooth_economy;                   
00407   bool   allow_shares;                     
00408   uint8  feeder_payment_share;             
00409   byte   dist_local_authority;             
00410   bool   exclusive_rights;                 
00411   bool   fund_buildings;                   
00412   bool   fund_roads;                       
00413   bool   give_money;                       
00414   bool   mod_road_rebuild;                 
00415   bool   multiple_industry_per_town;       
00416   uint8  town_growth_rate;                 
00417   uint8  larger_towns;                     
00418   uint8  initial_city_size;                
00419   TownLayoutByte town_layout;              
00420   bool   allow_town_roads;                 
00421   TownFoundingByte found_town;             
00422   bool   station_noise_level;              
00423   uint16 town_noise_population[3];         
00424   bool   allow_town_level_crossings;       
00425   bool   infrastructure_maintenance;       
00426 };
00427 
00428 struct LinkGraphSettings {
00429   uint16 recalc_interval;                     
00430   DistributionTypeByte distribution_pax;      
00431   DistributionTypeByte distribution_mail;     
00432   DistributionTypeByte distribution_armoured; 
00433   DistributionTypeByte distribution_default;  
00434   uint8 accuracy;                             
00435   uint8 demand_size;                          
00436   uint8 demand_distance;                      
00437   uint8 short_path_saturation;                
00438 
00439   FORCEINLINE DistributionType GetDistributionType(CargoID cargo) const {
00440     if (IsCargoInClass(cargo, CC_PASSENGERS)) {
00441       return this->distribution_pax;
00442     } else if (IsCargoInClass(cargo, CC_MAIL)) {
00443       return this->distribution_mail;
00444     } else if (IsCargoInClass(cargo, CC_ARMOURED)) {
00445       return this->distribution_armoured;
00446     } else {
00447       return this->distribution_default;
00448     }
00449   }
00450 };
00451 
00453 struct StationSettings {
00454   bool   modified_catchment;               
00455   bool   adjacent_stations;                
00456   bool   distant_join_stations;            
00457   bool   never_expire_airports;            
00458   byte   station_spread;                   
00459 };
00460 
00462 struct VehicleDefaultSettings {
00463   bool   servint_ispercent;                
00464   uint16 servint_trains;                   
00465   uint16 servint_roadveh;                  
00466   uint16 servint_aircraft;                 
00467   uint16 servint_ships;                    
00468 };
00469 
00471 struct CompanySettings {
00472   bool engine_renew;                       
00473   int16 engine_renew_months;               
00474   uint32 engine_renew_money;               
00475   bool renew_keep_length;                  
00476   VehicleDefaultSettings vehicle;          
00477 };
00478 
00480 struct GameSettings {
00481   DifficultySettings   difficulty;         
00482   GameCreationSettings game_creation;      
00483   ConstructionSettings construction;       
00484   AISettings           ai;                 
00485   ScriptSettings       script;             
00486   class AIConfig      *ai_config[MAX_COMPANIES]; 
00487   PathfinderSettings   pf;                 
00488   OrderSettings        order;              
00489   VehicleSettings      vehicle;            
00490   EconomySettings      economy;            
00491   LinkGraphSettings    linkgraph;          
00492   StationSettings      station;            
00493   LocaleSettings       locale;             
00494 };
00495 
00497 struct ClientSettings {
00498   GUISettings          gui;                
00499   NetworkSettings      network;            
00500   CompanySettings      company;            
00501   MusicSettings        music;              
00502 };
00503 
00505 extern ClientSettings _settings_client;
00506 
00508 extern GameSettings _settings_game;
00509 
00511 extern GameSettings _settings_newgame;
00512 
00514 extern VehicleDefaultSettings _old_vds;
00515 
00520 static inline GameSettings &GetGameSettings()
00521 {
00522   return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
00523 }
00524 
00525 #endif /* SETTINGS_TYPE_H */