settings_type.h

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