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