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 "openttd.h"
00021 #include "cargotype.h"
00022 #include "linkgraph/linkgraph_type.h"
00023 
00025 enum IndustryDensity {
00026   ID_FUND_ONLY, 
00027   ID_MINIMAL,   
00028   ID_VERY_LOW,  
00029   ID_LOW,       
00030   ID_NORMAL,    
00031   ID_HIGH,      
00032 
00033   ID_END,       
00034 };
00035 
00037 struct DifficultySettings {
00038   byte   max_no_competitors;               
00039   byte   number_towns;                     
00040   byte   industry_density;                 
00041   uint32 max_loan;                         
00042   byte   initial_interest;                 
00043   byte   vehicle_costs;                    
00044   byte   competitor_speed;                 
00045   byte   vehicle_breakdowns;               
00046   byte   subsidy_multiplier;               
00047   byte   construction_cost;                
00048   byte   terrain_type;                     
00049   byte   quantity_sea_lakes;               
00050   byte   economy;                          
00051   byte   line_reverse_mode;                
00052   byte   disasters;                        
00053   byte   town_council_tolerance;           
00054   byte   diff_level;                       
00055 };
00056 
00058 struct GUISettings {
00059   bool   vehicle_speed;                    
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   smallmap_flood_warning;           
00074   uint8  linkgraph_companies;              
00075   bool   reverse_scroll;                   
00076   bool   smooth_scroll;                    
00077   bool   measure_tooltip;                  
00078   byte   liveries;                         
00079   bool   prefer_teamchat;                  
00080   uint8  advanced_vehicle_list;            
00081   uint8  loading_indicators;               
00082   uint8  default_rail_type;                
00083   uint8  toolbar_pos;                      
00084   uint8  statusbar_pos;                    
00085   uint8  window_snap_radius;               
00086   uint8  window_soft_limit;                
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   bool   population_in_label_coloured;     
00096   uint8  right_mouse_btn_emulation;        
00097   uint8  scrollwheel_scrolling;            
00098   uint8  scrollwheel_multiplier;           
00099   bool   timetable_arrival_departure;      
00100   uint8  max_departures;                   
00101   uint16 max_departure_time;               
00102   uint16 departure_calc_frequency;         
00103   bool   departure_show_vehicle;           
00104   bool   departure_show_group;             
00105   bool   departure_show_company;           
00106   bool   departure_show_vehicle_type;      
00107   bool   departure_show_vehicle_color;     
00108   bool   departure_larger_font;            
00109   bool   departure_destination_type;       
00110   bool   departure_show_both;              
00111   bool   departure_only_passengers;        
00112   uint8  departure_conditionals;           
00113   bool   departure_show_all_stops;         
00114   bool   left_mouse_btn_scrolling;         
00115   bool   pause_on_newgame;                 
00116   bool   enable_signal_gui;                
00117   Year   coloured_news_year;               
00118   bool   timetable_in_ticks;               
00119   bool   time_in_minutes;                  
00120   uint8  ticks_per_minute;                 
00121   uint8  date_with_time;                   
00122   bool   quick_goto;                       
00123   bool   bridge_pillars;                   
00124   bool   auto_euro;                        
00125   byte   drag_signals_density;             
00126   Year   semaphore_build_before;           
00127   byte   news_message_timeout;             
00128   bool   show_track_reservation;           
00129   uint8  default_signal_type;              
00130   uint8  cycle_signal_types;               
00131   byte   station_numtracks;                
00132   byte   station_platlength;               
00133   bool   station_dragdrop;                 
00134   bool   station_show_coverage;            
00135   bool   persistent_buildingtools;         
00136   bool   expenses_layout;                  
00137 
00138   uint16 console_backlog_timeout;          
00139   uint16 console_backlog_length;           
00140 
00141   uint8  station_gui_group_order;          
00142   uint8  station_gui_sort_by;              
00143   uint8  station_gui_sort_order;           
00144 #ifdef ENABLE_NETWORK
00145   uint16 network_chat_box_width;           
00146   uint8  network_chat_box_height;          
00147   uint16 network_chat_timeout;             
00148 #endif
00149 
00150   uint8  developer;                        
00151   bool   show_date_in_logs;                
00152   bool   newgrf_developer_tools;           
00153   bool   ai_developer_tools;               
00154   bool   scenario_developer;               
00155   bool   newgrf_show_old_versions;         
00156   uint8  newgrf_default_palette;           
00157   uint8  cp_paste_speed;                   
00158 
00163   bool UserIsAllowedToChangeNewGRFs() const
00164   {
00165     return this->scenario_developer || this->newgrf_developer_tools;
00166   }
00167 };
00168 
00170 struct LocaleSettings {
00171   byte   currency;                         
00172   byte   units;                            
00173   char  *digit_group_separator;            
00174   char  *digit_group_separator_currency;   
00175   char  *digit_decimal_separator;          
00176 };
00177 
00179 struct NetworkSettings {
00180 #ifdef ENABLE_NETWORK
00181   uint16 sync_freq;                                     
00182   uint8  frame_freq;                                    
00183   uint16 commands_per_frame;                            
00184   uint16 max_commands_in_queue;                         
00185   uint16 bytes_per_frame;                               
00186   uint16 bytes_per_frame_burst;                         
00187   uint16 max_join_time;                                 
00188   bool   pause_on_join;                                 
00189   uint16 server_port;                                   
00190   uint16 server_admin_port;                             
00191   bool   server_admin_chat;                             
00192   char   server_name[NETWORK_NAME_LENGTH];              
00193   char   server_password[NETWORK_PASSWORD_LENGTH];      
00194   char   rcon_password[NETWORK_PASSWORD_LENGTH];        
00195   char   admin_password[NETWORK_PASSWORD_LENGTH];       
00196   bool   server_advertise;                              
00197   uint8  lan_internet;                                  
00198   char   client_name[NETWORK_CLIENT_NAME_LENGTH];       
00199   char   default_company_pass[NETWORK_PASSWORD_LENGTH]; 
00200   char   connect_to_ip[NETWORK_HOSTNAME_LENGTH];        
00201   char   network_id[NETWORK_SERVER_ID_LENGTH];          
00202   bool   autoclean_companies;                           
00203   uint8  autoclean_unprotected;                         
00204   uint8  autoclean_protected;                           
00205   uint8  autoclean_novehicles;                          
00206   uint8  max_companies;                                 
00207   uint8  max_clients;                                   
00208   uint8  max_spectators;                                
00209   Year   restart_game_year;                             
00210   uint8  min_active_clients;                            
00211   uint8  server_lang;                                   
00212   bool   reload_cfg;                                    
00213   char   last_host[NETWORK_HOSTNAME_LENGTH];            
00214   uint16 last_port;                                     
00215   bool   no_http_content_downloads;                     
00216 #else /* ENABLE_NETWORK */
00217 #endif
00218 };
00219 
00221 struct GameCreationSettings {
00222   uint32 generation_seed;                  
00223   Year   starting_year;                    
00224   uint8  map_x;                            
00225   uint8  map_y;                            
00226   byte   land_generator;                   
00227   byte   oil_refinery_limit;               
00228   byte   snow_line_height;                 
00229   byte   desert_amount;                    
00230   byte   tree_line_height;                 
00231   byte   tgen_smoothness;                  
00232   byte   tree_placer;                      
00233   byte   heightmap_rotation;               
00234   byte   se_flat_world_height;             
00235   byte   town_name;                        
00236   byte   landscape;                        
00237   uint16 snow_line;                        
00238   uint16 tree_line;                        
00239   byte   water_borders;                    
00240   uint16 custom_town_number;               
00241   byte   variety;                          
00242   byte   custom_sea_level;                 
00243 };
00244 
00246 struct ConstructionSettings {
00247   bool   allow_more_heightlevels;          
00248   bool   build_on_slopes;                  
00249   bool   autoslope;                        
00250   uint16 max_bridge_length;                
00251   uint16 max_tunnel_length;                
00252   byte   max_tunnel_exit_length;           
00253   bool   signal_side;                      
00254   bool   extra_dynamite;                   
00255   bool   road_stop_on_town_road;           
00256   bool   road_stop_on_competitor_road;     
00257   uint8  raw_industry_construction;        
00258   uint8  industry_platform;                
00259   bool   freeform_edges;                   
00260   uint8  extra_tree_placement;             
00261   uint8  tree_placement_drag_limit;        
00262   uint8  command_pause_level;              
00263   uint32 terraform_per_64k_frames;         
00264   uint16 terraform_frame_burst;            
00265   uint32 clear_per_64k_frames;             
00266   uint16 clear_frame_burst;                
00267   byte   ingame_tree_line_height;          
00268   uint8  tree_growth_rate;                 
00269   uint16 maximum_signal_evaluations;       
00270   bool traffic_lights;                     
00271   bool towns_build_traffic_lights;         
00272   bool allow_building_tls_in_towns;        
00273   uint8 traffic_lights_green_phase;        
00274   uint8 max_tlc_size;                      
00275   uint8 max_tlc_distance;                  
00276   uint8 extra_industry_placement_logic;    
00277 };
00278 
00280 struct AISettings {
00281   bool   ai_in_multiplayer;                
00282   bool   ai_disable_veh_train;             
00283   bool   ai_disable_veh_roadveh;           
00284   bool   ai_disable_veh_aircraft;          
00285   bool   ai_disable_veh_ship;              
00286   uint32 ai_max_opcode_till_suspend;       
00287 };
00288 
00290 struct OPFSettings {
00291   uint16 pf_maxlength;                     
00292   byte   pf_maxdepth;                      
00293 };
00294 
00296 struct NPFSettings {
00302   uint32 npf_max_search_nodes;
00303   uint32 maximum_go_to_depot_penalty;      
00304 
00305   uint32 npf_rail_firstred_penalty;        
00306   uint32 npf_rail_firstred_exit_penalty;   
00307   uint32 npf_rail_lastred_penalty;         
00308   uint32 npf_rail_station_penalty;         
00309   uint32 npf_rail_slope_penalty;           
00310   uint32 npf_rail_curve_penalty;           
00311   uint32 npf_rail_depot_reverse_penalty;   
00312   uint32 npf_rail_pbs_cross_penalty;       
00313   uint32 npf_rail_pbs_signal_back_penalty; 
00314   uint32 npf_buoy_penalty;                 
00315   uint32 npf_water_curve_penalty;          
00316   uint32 npf_road_curve_penalty;           
00317   uint32 npf_crossing_penalty;             
00318   uint32 npf_road_drive_through_penalty;   
00319   uint32 npf_road_trafficlight_penalty;    
00320   uint32 npf_road_dt_occupied_penalty;     
00321   uint32 npf_road_bay_occupied_penalty;    
00322 };
00323 
00325 struct YAPFSettings {
00326   bool   disable_node_optimization;        
00327   uint32 max_search_nodes;                 
00328   uint32 maximum_go_to_depot_penalty;      
00329   bool   ship_use_yapf;                    
00330   bool   road_use_yapf;                    
00331   bool   rail_use_yapf;                    
00332   uint32 road_slope_penalty;               
00333   uint32 road_curve_penalty;               
00334   uint32 road_crossing_penalty;            
00335   uint32 road_stop_penalty;                
00336   uint32 road_trafficlight_penalty;        
00337   uint32 road_stop_occupied_penalty;       
00338   uint32 road_stop_bay_occupied_penalty;   
00339   bool   rail_firstred_twoway_eol;         
00340   uint32 rail_firstred_penalty;            
00341   uint32 rail_firstred_exit_penalty;       
00342   uint32 rail_lastred_penalty;             
00343   uint32 rail_lastred_exit_penalty;        
00344   uint32 rail_station_penalty;             
00345   uint32 rail_slope_penalty;               
00346   uint32 rail_curve45_penalty;             
00347   uint32 rail_curve90_penalty;             
00348   uint32 rail_depot_reverse_penalty;       
00349   uint32 rail_crossing_penalty;            
00350   uint32 rail_look_ahead_max_signals;      
00351   int32  rail_look_ahead_signal_p0;        
00352   int32  rail_look_ahead_signal_p1;        
00353   int32  rail_look_ahead_signal_p2;        
00354   uint32 rail_pbs_cross_penalty;           
00355   uint32 rail_pbs_station_penalty;         
00356   uint32 rail_pbs_signal_back_penalty;     
00357   uint32 rail_doubleslip_penalty;          
00358 
00359   uint32 rail_longer_platform_penalty;           
00360   uint32 rail_longer_platform_per_tile_penalty;  
00361   uint32 rail_shorter_platform_penalty;          
00362   uint32 rail_shorter_platform_per_tile_penalty; 
00363 };
00364 
00366 struct PathfinderSettings {
00367   uint8  pathfinder_for_trains;            
00368   uint8  pathfinder_for_roadvehs;          
00369   uint8  pathfinder_for_ships;             
00370   bool   new_pathfinding_all;              
00371 
00372   bool   roadveh_queue;                    
00373   bool   forbid_90_deg;                    
00374 
00375   bool   reverse_at_signals;               
00376   byte   wait_oneway_signal;               
00377   byte   wait_twoway_signal;               
00378 
00379   bool   reserve_paths;                    
00380   byte   wait_for_pbs_path;                
00381   byte   path_backoff_interval;            
00382 
00383   OPFSettings  opf;                        
00384   NPFSettings  npf;                        
00385   YAPFSettings yapf;                       
00386 
00387   bool back_of_one_way_pbs_waiting_point;  
00388 };
00389 
00391 struct OrderSettings {
00392   bool   improved_load;                    
00393   bool   gradual_loading;                  
00394   bool   selectgoods;                      
00395   bool   gotodepot;                        
00396   bool   no_servicing_if_no_breakdowns;    
00397   bool   timetabling;                      
00398   bool   timetable_automated;              
00399   bool   timetable_separation;             
00400   bool   serviceathelipad;                 
00401 };
00402 
00404 struct VehicleSettings {
00405   uint8  max_train_length;                 
00406   uint8  smoke_amount;                     
00407   uint8  train_acceleration_model;         
00408   uint8  roadveh_acceleration_model;       
00409   uint8  train_slope_steepness;            
00410   uint8  roadveh_slope_steepness;          
00411   bool   wagon_speed_limits;               
00412   bool   disable_elrails;                  
00413   UnitID max_trains;                       
00414   UnitID max_roadveh;                      
00415   UnitID max_aircraft;                     
00416   UnitID max_ships;                        
00417   uint8  plane_speed;                      
00418   uint8  freight_trains;                   
00419   bool   dynamic_engines;                  
00420   bool   never_expire_vehicles;            
00421   byte   extend_vehicle_life;              
00422   byte   road_side;                        
00423   uint8  plane_crashes;                    
00424   bool   improved_breakdowns;              
00425 };
00426 
00428 struct EconomySettings {
00429   bool   inflation;                        
00430   bool   bribe;                            
00431   bool   smooth_economy;                   
00432   bool   allow_shares;                     
00433   uint8  feeder_payment_share;             
00434   byte   dist_local_authority;             
00435   bool   exclusive_rights;                 
00436   bool   fund_roads;                       
00437   bool   give_money;                       
00438   bool   mod_road_rebuild;                 
00439   bool   multiple_industry_per_town;       
00440   uint8  town_growth_rate;                 
00441   uint8  larger_towns;                     
00442   uint8  initial_city_size;                
00443   uint8  town_growth_cargo;                
00444   uint32 town_pop_need_goods;              
00445   uint8  larger_town_growth_cargo;         
00446   uint32 larger_town_pop_need_goods;       
00447   TownLayoutByte town_layout;              
00448   bool   allow_town_roads;                 
00449   TownFoundingByte found_town;             
00450   bool   station_noise_level;              
00451   uint16 town_noise_population[3];         
00452   bool   allow_town_level_crossings;       
00453   bool   infrastructure_maintenance;       
00454   int8   town_cargo_factor;                
00455   bool   infrastructure_sharing[4];        
00456   uint   sharing_fee[4];                   
00457   bool   sharing_payment_in_debt;          
00458 };
00459 
00460 struct LinkGraphSettings {
00461   uint16 recalc_interval;                     
00462   DistributionTypeByte distribution_pax;      
00463   DistributionTypeByte distribution_mail;     
00464   DistributionTypeByte distribution_express;  
00465   DistributionTypeByte distribution_armoured; 
00466   DistributionTypeByte distribution_default;  
00467   uint8 accuracy;                             
00468   uint8 demand_size;                          
00469   uint8 demand_distance;                      
00470   uint8 short_path_saturation;                
00471   bool no_overload_links;                     
00472 
00473   FORCEINLINE DistributionType GetDistributionType(CargoID cargo) const {
00474     if (IsCargoInClass(cargo, CC_PASSENGERS)) {
00475       return this->distribution_pax;
00476     } else if (IsCargoInClass(cargo, CC_MAIL)) {
00477       return this->distribution_mail;
00478     } else if (IsCargoInClass(cargo, CC_EXPRESS)) {
00479       return this->distribution_express;
00480     } else if (IsCargoInClass(cargo, CC_ARMOURED)) {
00481       return this->distribution_armoured;
00482     } else {
00483       return this->distribution_default;
00484     }
00485   }
00486 };
00487 
00489 struct StationSettings {
00490   bool   modified_catchment;               
00491   bool   adjacent_stations;                
00492   bool   distant_join_stations;            
00493   bool   never_expire_airports;            
00494   byte   station_spread;                   
00495 };
00496 
00498 struct VehicleDefaultSettings {
00499   bool   servint_ispercent;                
00500   uint16 servint_trains;                   
00501   uint16 servint_roadveh;                  
00502   uint16 servint_aircraft;                 
00503   uint16 servint_ships;                    
00504 };
00505 
00507 struct CompanySettings {
00508   bool engine_renew;                       
00509   int16 engine_renew_months;               
00510   uint32 engine_renew_money;               
00511   bool renew_keep_length;                  
00512   VehicleDefaultSettings vehicle;          
00513 };
00514 
00516 struct GameSettings {
00517   DifficultySettings   difficulty;         
00518   GameCreationSettings game_creation;      
00519   ConstructionSettings construction;       
00520   AISettings           ai;                 
00521   class AIConfig      *ai_config[MAX_COMPANIES]; 
00522   PathfinderSettings   pf;                 
00523   OrderSettings        order;              
00524   VehicleSettings      vehicle;            
00525   EconomySettings      economy;            
00526   LinkGraphSettings    linkgraph;          
00527   StationSettings      station;            
00528   LocaleSettings       locale;             
00529 };
00530 
00532 struct ClientSettings {
00533   GUISettings          gui;                
00534   NetworkSettings      network;            
00535   CompanySettings      company;            
00536 };
00537 
00539 extern ClientSettings _settings_client;
00540 
00542 extern GameSettings _settings_game;
00543 
00545 extern GameSettings _settings_newgame;
00546 
00551 static inline GameSettings &GetGameSettings()
00552 {
00553   return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
00554 }
00555 
00556 #endif /* SETTINGS_TYPE_H */