# settings_type.h

Go to the documentation of this file.

    00001 /* $Id: settings_type.h 25508 2013-06-29 09:47:18Z 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 "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_velocity;
    00198   byte   units_power;
    00199   byte   units_weight;
    00200   byte   units_volume;
    00201   byte   units_force;
    00202   byte   units_height;
    00203   char  *digit_group_separator;
    00204   char  *digit_group_separator_currency;
    00205   char  *digit_decimal_separator;
    00206 };
    00207
    00209 struct NewsSettings {
    00210   uint8 arrival_player;
    00211   uint8 arrival_other;
    00212   uint8 accident;
    00213   uint8 company_info;
    00214   uint8 open;
    00215   uint8 close;
    00216   uint8 economy;
    00217   uint8 production_player;
    00218   uint8 production_other;
    00219   uint8 production_nobody;
    00220   uint8 advice;
    00221   uint8 new_vehicles;
    00222   uint8 acceptance;
    00223   uint8 subsidies;
    00224   uint8 general;
    00225 };
    00226
    00228 struct NetworkSettings {
    00229 #ifdef ENABLE_NETWORK
    00230   uint16 sync_freq;
    00231   uint8  frame_freq;
    00232   uint16 commands_per_frame;
    00233   uint16 max_commands_in_queue;
    00234   uint16 bytes_per_frame;
    00235   uint16 bytes_per_frame_burst;
    00236   uint16 max_init_time;
    00237   uint16 max_join_time;
    00238   uint16 max_download_time;
    00239   uint16 max_password_time;
    00240   uint16 max_lag_time;
    00241   bool   pause_on_join;
    00242   uint16 server_port;
    00243   uint16 server_admin_port;
    00244   bool   server_admin_chat;
    00245   char   server_name[NETWORK_NAME_LENGTH];
    00246   char   server_password[NETWORK_PASSWORD_LENGTH];
    00247   char   rcon_password[NETWORK_PASSWORD_LENGTH];
    00248   char   admin_password[NETWORK_PASSWORD_LENGTH];
    00249   bool   server_advertise;
    00250   uint8  lan_internet;
    00251   char   client_name[NETWORK_CLIENT_NAME_LENGTH];
    00252   char   default_company_pass[NETWORK_PASSWORD_LENGTH];
    00253   char   connect_to_ip[NETWORK_HOSTNAME_LENGTH];
    00254   char   network_id[NETWORK_SERVER_ID_LENGTH];
    00255   bool   autoclean_companies;
    00256   uint8  autoclean_unprotected;
    00257   uint8  autoclean_protected;
    00258   uint8  autoclean_novehicles;
    00259   uint8  max_companies;
    00260   uint8  max_clients;
    00261   uint8  max_spectators;
    00262   Year   restart_game_year;
    00263   uint8  min_active_clients;
    00264   uint8  server_lang;
    00265   bool   reload_cfg;
    00266   char   last_host[NETWORK_HOSTNAME_LENGTH];
    00267   uint16 last_port;
    00268   bool   no_http_content_downloads;
    00269 #else /* ENABLE_NETWORK */
    00270 #endif
    00271 };
    00272
    00274 struct GameCreationSettings {
    00275   uint32 generation_seed;
    00276   Year   starting_year;
    00277   uint8  map_x;
    00278   uint8  map_y;
    00279   byte   land_generator;
    00280   byte   oil_refinery_limit;
    00281   byte   snow_line_height;
    00282   byte   tgen_smoothness;
    00283   byte   tree_placer;
    00284   byte   heightmap_rotation;
    00285   byte   se_flat_world_height;
    00286   byte   town_name;
    00287   byte   landscape;
    00288   byte   water_borders;
    00289   uint16 custom_town_number;
    00290   byte   variety;
    00291   byte   custom_sea_level;
    00292   byte   min_river_length;
    00293   byte   river_route_random;
    00294   byte   amount_of_rivers;
    00295 };
    00296
    00298 struct ConstructionSettings {
    00299   bool   build_on_slopes;
    00300   bool   autoslope;
    00301   uint16 max_bridge_length;
    00302   uint16 max_tunnel_length;
    00303   byte   train_signal_side;
    00304   bool   extra_dynamite;
    00305   bool   road_stop_on_town_road;
    00306   bool   road_stop_on_competitor_road;
    00307   uint8  raw_industry_construction;
    00308   uint8  industry_platform;
    00309   bool   freeform_edges;
    00310   uint8  extra_tree_placement;
    00311   uint8  command_pause_level;
    00312
    00313   uint32 terraform_per_64k_frames;
    00314   uint16 terraform_frame_burst;
    00315   uint32 clear_per_64k_frames;
    00316   uint16 clear_frame_burst;
    00317   uint32 tree_per_64k_frames;
    00318   uint16 tree_frame_burst;
    00319 };
    00320
    00322 struct AISettings {
    00323   bool   ai_in_multiplayer;
    00324   bool   ai_disable_veh_train;
    00325   bool   ai_disable_veh_roadveh;
    00326   bool   ai_disable_veh_aircraft;
    00327   bool   ai_disable_veh_ship;
    00328 };
    00329
    00331 struct ScriptSettings {
    00332   uint8  settings_profile;
    00333   uint32 script_max_opcode_till_suspend;
    00334 };
    00335
    00337 struct OPFSettings {
    00338   uint16 pf_maxlength;
    00339   byte   pf_maxdepth;
    00340 };
    00341
    00343 struct NPFSettings {
    00349   uint32 npf_max_search_nodes;
    00350   uint32 maximum_go_to_depot_penalty;
    00351
    00352   uint32 npf_rail_firstred_penalty;
    00353   uint32 npf_rail_firstred_exit_penalty;
    00354   uint32 npf_rail_lastred_penalty;
    00355   uint32 npf_rail_station_penalty;
    00356   uint32 npf_rail_slope_penalty;
    00357   uint32 npf_rail_curve_penalty;
    00358   uint32 npf_rail_depot_reverse_penalty;
    00359   uint32 npf_rail_pbs_cross_penalty;
    00360   uint32 npf_rail_pbs_signal_back_penalty;
    00361   uint32 npf_buoy_penalty;
    00362   uint32 npf_water_curve_penalty;
    00363   uint32 npf_road_curve_penalty;
    00364   uint32 npf_crossing_penalty;
    00365   uint32 npf_road_drive_through_penalty;
    00366   uint32 npf_road_dt_occupied_penalty;
    00367   uint32 npf_road_bay_occupied_penalty;
    00368 };
    00369
    00371 struct YAPFSettings {
    00372   bool   disable_node_optimization;
    00373   uint32 max_search_nodes;
    00374   uint32 maximum_go_to_depot_penalty;
    00375   bool   ship_use_yapf;
    00376   bool   road_use_yapf;
    00377   bool   rail_use_yapf;
    00378   uint32 road_slope_penalty;
    00379   uint32 road_curve_penalty;
    00380   uint32 road_crossing_penalty;
    00381   uint32 road_stop_penalty;
    00382   uint32 road_stop_occupied_penalty;
    00383   uint32 road_stop_bay_occupied_penalty;
    00384   bool   rail_firstred_twoway_eol;
    00385   uint32 rail_firstred_penalty;
    00386   uint32 rail_firstred_exit_penalty;
    00387   uint32 rail_lastred_penalty;
    00388   uint32 rail_lastred_exit_penalty;
    00389   uint32 rail_station_penalty;
    00390   uint32 rail_slope_penalty;
    00391   uint32 rail_curve45_penalty;
    00392   uint32 rail_curve90_penalty;
    00393   uint32 rail_depot_reverse_penalty;
    00394   uint32 rail_crossing_penalty;
    00395   uint32 rail_look_ahead_max_signals;
    00396   int32  rail_look_ahead_signal_p0;
    00397   int32  rail_look_ahead_signal_p1;
    00398   int32  rail_look_ahead_signal_p2;
    00399   uint32 rail_pbs_cross_penalty;
    00400   uint32 rail_pbs_station_penalty;
    00401   uint32 rail_pbs_signal_back_penalty;
    00402   uint32 rail_doubleslip_penalty;
    00403
    00404   uint32 rail_longer_platform_penalty;
    00405   uint32 rail_longer_platform_per_tile_penalty;
    00406   uint32 rail_shorter_platform_penalty;
    00407   uint32 rail_shorter_platform_per_tile_penalty;
    00408 };
    00409
    00411 struct PathfinderSettings {
    00412   uint8  pathfinder_for_trains;
    00413   uint8  pathfinder_for_roadvehs;
    00414   uint8  pathfinder_for_ships;
    00415   bool   new_pathfinding_all;
    00416
    00417   bool   roadveh_queue;
    00418   bool   forbid_90_deg;
    00419
    00420   bool   reverse_at_signals;
    00421   byte   wait_oneway_signal;
    00422   byte   wait_twoway_signal;
    00423
    00424   bool   reserve_paths;
    00425   byte   wait_for_pbs_path;
    00426   byte   path_backoff_interval;
    00427
    00428   OPFSettings  opf;
    00429   NPFSettings  npf;
    00430   YAPFSettings yapf;
    00431 };
    00432
    00434 struct OrderSettings {
    00435   bool   improved_load;
    00436   bool   gradual_loading;
    00437   bool   selectgoods;
    00438   bool   no_servicing_if_no_breakdowns;
    00439   bool   serviceathelipad;
    00440 };
    00441
    00443 struct VehicleSettings {
    00444   uint8  max_train_length;
    00445   uint8  smoke_amount;
    00446   uint8  train_acceleration_model;
    00447   uint8  roadveh_acceleration_model;
    00448   uint8  train_slope_steepness;
    00449   uint8  roadveh_slope_steepness;
    00450   bool   wagon_speed_limits;
    00451   bool   disable_elrails;
    00452   UnitID max_trains;
    00453   UnitID max_roadveh;
    00454   UnitID max_aircraft;
    00455   UnitID max_ships;
    00456   uint8  plane_speed;
    00457   uint8  freight_trains;
    00458   bool   dynamic_engines;
    00459   bool   never_expire_vehicles;
    00460   byte   extend_vehicle_life;
    00461   byte   road_side;
    00462   uint8  plane_crashes;
    00463 };
    00464
    00466 struct EconomySettings {
    00467   bool   inflation;
    00468   bool   bribe;
    00469   bool   smooth_economy;
    00470   bool   allow_shares;
    00471   uint8  feeder_payment_share;
    00472   byte   dist_local_authority;
    00473   bool   exclusive_rights;
    00474   bool   fund_buildings;
    00475   bool   fund_roads;
    00476   bool   give_money;
    00477   bool   mod_road_rebuild;
    00478   bool   multiple_industry_per_town;
    00479   uint8  town_growth_rate;
    00480   uint8  larger_towns;
    00481   uint8  initial_city_size;
    00482   TownLayoutByte town_layout;
    00483   bool   allow_town_roads;
    00484   TownFoundingByte found_town;
    00485   bool   station_noise_level;
    00486   uint16 town_noise_population[3];
    00487   bool   allow_town_level_crossings;
    00488   bool   infrastructure_maintenance;
    00489 };
    00490
    00491 struct LinkGraphSettings {
    00492   uint16 recalc_time;
    00493   uint16 recalc_interval;
    00494   DistributionTypeByte distribution_pax;
    00495   DistributionTypeByte distribution_mail;
    00496   DistributionTypeByte distribution_armoured;
    00497   DistributionTypeByte distribution_default;
    00498   uint8 accuracy;
    00499   uint8 demand_size;
    00500   uint8 demand_distance;
    00501   uint8 short_path_saturation;
    00502
    00503   inline DistributionType GetDistributionType(CargoID cargo) const {
    00504     if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax;
    00505     if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail;
    00506     if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured;
    00507     return this->distribution_default;
    00508   }
    00509 };
    00510
    00512 struct StationSettings {
    00513   bool   modified_catchment;
    00514   bool   adjacent_stations;
    00515   bool   distant_join_stations;
    00516   bool   never_expire_airports;
    00517   byte   station_spread;
    00518 };
    00519
    00521 struct VehicleDefaultSettings {
    00522   bool   servint_ispercent;
    00523   uint16 servint_trains;
    00524   uint16 servint_roadveh;
    00525   uint16 servint_aircraft;
    00526   uint16 servint_ships;
    00527 };
    00528
    00530 struct CompanySettings {
    00531   bool engine_renew;
    00532   int16 engine_renew_months;
    00533   uint32 engine_renew_money;
    00534   bool renew_keep_length;
    00535   VehicleDefaultSettings vehicle;
    00536 };
    00537
    00539 struct GameSettings {
    00540   DifficultySettings   difficulty;
    00541   GameCreationSettings game_creation;
    00542   ConstructionSettings construction;
    00543   AISettings           ai;
    00544   ScriptSettings       script;
    00545   class AIConfig      *ai_config[MAX_COMPANIES];
    00546   class GameConfig    *game_config;
    00547   PathfinderSettings   pf;
    00548   OrderSettings        order;
    00549   VehicleSettings      vehicle;
    00550   EconomySettings      economy;
    00551   LinkGraphSettings    linkgraph;
    00552   StationSettings      station;
    00553   LocaleSettings       locale;
    00554 };
    00555
    00557 struct ClientSettings {
    00558   GUISettings          gui;
    00559   NetworkSettings      network;
    00560   CompanySettings      company;
    00561   SoundSettings        sound;
    00562   MusicSettings        music;
    00563   NewsSettings         news_display;
    00564 };
    00565
    00567 extern ClientSettings _settings_client;
    00568
    00570 extern GameSettings _settings_game;
    00571
    00573 extern GameSettings _settings_newgame;
    00574
    00576 extern VehicleDefaultSettings _old_vds;
    00577
    00582 static inline GameSettings &GetGameSettings()
    00583 {
    00584   return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
    00585 }
    00586
    00587 #endif /* SETTINGS_TYPE_H */