OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

settings_type.h
Go to the documentation of this file.
1 /* $Id: settings_type.h 27825 2017-03-24 18:55:16Z peter1138 $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef SETTINGS_TYPE_H
13 #define SETTINGS_TYPE_H
14
15 #include "date_type.h"
16 #include "town_type.h"
17 #include "transport_type.h"
18 #include "network/core/config.h"
19 #include "company_type.h"
20 #include "cargotype.h"
21 #include "linkgraph/linkgraph_type.h"
22 #include "zoom_type.h"
23 #include "openttd.h"
24
25
27 enum SettingsProfile {
28 SP_BEGIN = 0,
29 SP_EASY = SP_BEGIN,
30 SP_MEDIUM,
31 SP_HARD,
32
33 SP_END,
34
35 SP_CUSTOM = SP_END,
36 SP_SAVED_HIGHSCORE_END,
37
38 SP_MULTIPLAYER = SP_SAVED_HIGHSCORE_END,
39 SP_HIGHSCORE_END,
40 };
41
43 enum IndustryDensity {
44 ID_FUND_ONLY,
45 ID_MINIMAL,
46 ID_VERY_LOW,
47 ID_LOW,
48 ID_NORMAL,
49 ID_HIGH,
50
51 ID_END,
52 };
53
55 struct DifficultySettings {
56 byte max_no_competitors;
57 byte number_towns;
58 byte industry_density;
59 uint32 max_loan;
60 byte initial_interest;
61 byte vehicle_costs;
62 byte competitor_speed;
63 byte vehicle_breakdowns;
64 byte subsidy_multiplier;
65 byte construction_cost;
66 byte terrain_type;
67 byte quantity_sea_lakes;
68 bool economy;
69 bool line_reverse_mode;
70 bool disasters;
71 byte town_council_tolerance;
72 };
73
75 struct GUISettings {
76 bool sg_full_load_any;
77 bool lost_vehicle_warn;
78 uint8 order_review_system;
79 bool vehicle_income_warn;
80 bool show_finances;
81 bool sg_new_nonstop;
82 bool new_nonstop;
83 uint8 stop_location;
84 uint8 auto_scrolling;
85 byte errmsg_duration;
86 uint16 hover_delay_ms;
87 bool link_terraform_toolbar;
88 uint8 smallmap_land_colour;
89 bool reverse_scroll;
90 bool smooth_scroll;
91 bool measure_tooltip;
92 byte liveries;
93 bool prefer_teamchat;
94 uint8 advanced_vehicle_list;
95 uint8 loading_indicators;
96 uint8 default_rail_type;
97 uint8 toolbar_pos;
98 uint8 statusbar_pos;
99 uint8 window_snap_radius;
100 uint8 window_soft_limit;
101 ZoomLevelByte zoom_min;
102 ZoomLevelByte zoom_max;
103 bool disable_unsuitable_building;
104 byte autosave;
105 bool threaded_saves;
106 bool keep_all_autosave;
107 bool autosave_on_exit;
108 uint8 date_format_in_default_names;
109 byte max_num_autosaves;
110 bool population_in_label;
111 uint8 right_mouse_btn_emulation;
112 uint8 scrollwheel_scrolling;
113 uint8 scrollwheel_multiplier;
114 bool timetable_arrival_departure;
115 bool left_mouse_btn_scrolling;
116 bool right_mouse_wnd_close;
117 bool pause_on_newgame;
118 bool enable_signal_gui;
119 Year coloured_news_year;
120 bool timetable_in_ticks;
121 bool quick_goto;
122 bool auto_euro;
123 byte drag_signals_density;
124 bool drag_signals_fixed_distance;
125 Year semaphore_build_before;
126 byte news_message_timeout;
127 bool show_track_reservation;
128 uint8 default_signal_type;
129 uint8 cycle_signal_types;
130 byte station_numtracks;
131 byte station_platlength;
132 bool station_dragdrop;
133 bool station_show_coverage;
134 bool persistent_buildingtools;
135 bool expenses_layout;
136 uint32 last_newgrf_count;
137 byte missing_strings_threshold;
138 uint8 graph_line_thickness;
139 uint8 osk_activation;
140
141 uint16 console_backlog_timeout;
142 uint16 console_backlog_length;
143
144 uint8 station_gui_group_order;
145 uint8 station_gui_sort_by;
146 uint8 station_gui_sort_order;
147 #ifdef ENABLE_NETWORK
148 uint16 network_chat_box_width_pct;
149 uint8 network_chat_box_height;
150 uint16 network_chat_timeout;
151 #endif
152
153 uint8 developer;
154 bool show_date_in_logs;
155 bool newgrf_developer_tools;
156 bool ai_developer_tools;
157 bool scenario_developer;
158 uint8 settings_restriction_mode;
159 bool newgrf_show_old_versions;
160 uint8 newgrf_default_palette;
161
166 bool UserIsAllowedToChangeNewGRFs() const
167 {
168 return this->scenario_developer || this->newgrf_developer_tools;
169 }
170 };
171
173 struct SoundSettings {
174 bool news_ticker;
175 bool news_full;
176 bool new_year;
177 bool confirm;
178 bool click_beep;
179 bool disaster;
180 bool vehicle;
181 bool ambient;
182 };
183
185 struct MusicSettings {
186 byte playlist;
187 byte music_vol;
188 byte effect_vol;
189 byte custom_1[33];
190 byte custom_2[33];
191 bool playing;
192 bool shuffle;
193 };
194
196 struct LocaleSettings {
197 byte currency;
198 byte units_velocity;
199 byte units_power;
200 byte units_weight;
201 byte units_volume;
202 byte units_force;
203 byte units_height;
204 char *digit_group_separator;
205 char *digit_group_separator_currency;
206 char *digit_decimal_separator;
207 };
208
210 struct NewsSettings {
211 uint8 arrival_player;
212 uint8 arrival_other;
213 uint8 accident;
214 uint8 company_info;
215 uint8 open;
216 uint8 close;
217 uint8 economy;
218 uint8 production_player;
219 uint8 production_other;
220 uint8 production_nobody;
221 uint8 advice;
222 uint8 new_vehicles;
223 uint8 acceptance;
224 uint8 subsidies;
225 uint8 general;
226 };
227
229 struct NetworkSettings {
230 #ifdef ENABLE_NETWORK
231 uint16 sync_freq;
232 uint8 frame_freq;
233 uint16 commands_per_frame;
234 uint16 max_commands_in_queue;
235 uint16 bytes_per_frame;
236 uint16 bytes_per_frame_burst;
237 uint16 max_init_time;
238 uint16 max_join_time;
239 uint16 max_download_time;
240 uint16 max_password_time;
241 uint16 max_lag_time;
242 bool pause_on_join;
243 uint16 server_port;
244 uint16 server_admin_port;
245 bool server_admin_chat;
246 char server_name[NETWORK_NAME_LENGTH];
247 char server_password[NETWORK_PASSWORD_LENGTH];
248 char rcon_password[NETWORK_PASSWORD_LENGTH];
249 char admin_password[NETWORK_PASSWORD_LENGTH];
250 bool server_advertise;
251 uint8 lan_internet;
252 char client_name[NETWORK_CLIENT_NAME_LENGTH];
253 char default_company_pass[NETWORK_PASSWORD_LENGTH];
254 char connect_to_ip[NETWORK_HOSTNAME_LENGTH];
255 char network_id[NETWORK_SERVER_ID_LENGTH];
256 bool autoclean_companies;
257 uint8 autoclean_unprotected;
258 uint8 autoclean_protected;
259 uint8 autoclean_novehicles;
260 uint8 max_companies;
261 uint8 max_clients;
262 uint8 max_spectators;
263 Year restart_game_year;
264 uint8 min_active_clients;
265 uint8 server_lang;
266 bool reload_cfg;
267 char last_host[NETWORK_HOSTNAME_LENGTH];
268 uint16 last_port;
269 bool no_http_content_downloads;
270 #else /* ENABLE_NETWORK */
271 #endif
272 };
273
275 struct GameCreationSettings {
276 uint32 generation_seed;
277 Year starting_year;
278 uint8 map_x;
279 uint8 map_y;
280 byte land_generator;
281 byte oil_refinery_limit;
282 byte snow_line_height;
283 byte tgen_smoothness;
284 byte tree_placer;
285 byte heightmap_rotation;
286 byte se_flat_world_height;
287 byte town_name;
288 byte landscape;
289 byte water_borders;
290 uint16 custom_town_number;
291 byte variety;
292 byte custom_sea_level;
293 byte min_river_length;
294 byte river_route_random;
295 byte amount_of_rivers;
296 };
297
299 struct ConstructionSettings {
300 uint8 max_heightlevel;
301 bool build_on_slopes;
302 bool autoslope;
303 uint16 max_bridge_length;
304 byte max_bridge_height;
305 uint16 max_tunnel_length;
306 byte train_signal_side;
307 bool extra_dynamite;
308 bool road_stop_on_town_road;
309 bool road_stop_on_competitor_road;
310 uint8 raw_industry_construction;
311 uint8 industry_platform;
312 bool freeform_edges;
313 uint8 extra_tree_placement;
314 uint8 command_pause_level;
315
316 uint32 terraform_per_64k_frames;
317 uint16 terraform_frame_burst;
318 uint32 clear_per_64k_frames;
319 uint16 clear_frame_burst;
320 uint32 tree_per_64k_frames;
321 uint16 tree_frame_burst;
322 };
323
325 struct AISettings {
326 bool ai_in_multiplayer;
327 bool ai_disable_veh_train;
328 bool ai_disable_veh_roadveh;
329 bool ai_disable_veh_aircraft;
330 bool ai_disable_veh_ship;
331 };
332
334 struct ScriptSettings {
335 uint8 settings_profile;
336 uint32 script_max_opcode_till_suspend;
337 };
338
340 struct OPFSettings {
341 uint16 pf_maxlength;
342 byte pf_maxdepth;
343 };
344
346 struct NPFSettings {
352 uint32 npf_max_search_nodes;
353 uint32 maximum_go_to_depot_penalty;
354
355 uint32 npf_rail_firstred_penalty;
356 uint32 npf_rail_firstred_exit_penalty;
357 uint32 npf_rail_lastred_penalty;
358 uint32 npf_rail_station_penalty;
359 uint32 npf_rail_slope_penalty;
360 uint32 npf_rail_curve_penalty;
361 uint32 npf_rail_depot_reverse_penalty;
362 uint32 npf_rail_pbs_cross_penalty;
363 uint32 npf_rail_pbs_signal_back_penalty;
364 uint32 npf_buoy_penalty;
365 uint32 npf_water_curve_penalty;
366 uint32 npf_road_curve_penalty;
367 uint32 npf_crossing_penalty;
368 uint32 npf_road_drive_through_penalty;
369 uint32 npf_road_dt_occupied_penalty;
370 uint32 npf_road_bay_occupied_penalty;
371 };
372
374 struct YAPFSettings {
375 bool disable_node_optimization;
376 uint32 max_search_nodes;
377 uint32 maximum_go_to_depot_penalty;
378 bool ship_use_yapf;
379 bool road_use_yapf;
380 bool rail_use_yapf;
381 uint32 road_slope_penalty;
382 uint32 road_curve_penalty;
383 uint32 road_crossing_penalty;
384 uint32 road_stop_penalty;
385 uint32 road_stop_occupied_penalty;
386 uint32 road_stop_bay_occupied_penalty;
387 bool rail_firstred_twoway_eol;
388 uint32 rail_firstred_penalty;
389 uint32 rail_firstred_exit_penalty;
390 uint32 rail_lastred_penalty;
391 uint32 rail_lastred_exit_penalty;
392 uint32 rail_station_penalty;
393 uint32 rail_slope_penalty;
394 uint32 rail_curve45_penalty;
395 uint32 rail_curve90_penalty;
396 uint32 rail_depot_reverse_penalty;
397 uint32 rail_crossing_penalty;
398 uint32 rail_look_ahead_max_signals;
399 int32 rail_look_ahead_signal_p0;
400 int32 rail_look_ahead_signal_p1;
401 int32 rail_look_ahead_signal_p2;
402 uint32 rail_pbs_cross_penalty;
403 uint32 rail_pbs_station_penalty;
404 uint32 rail_pbs_signal_back_penalty;
405 uint32 rail_doubleslip_penalty;
406
407 uint32 rail_longer_platform_penalty;
408 uint32 rail_longer_platform_per_tile_penalty;
409 uint32 rail_shorter_platform_penalty;
410 uint32 rail_shorter_platform_per_tile_penalty;
411 };
412
414 struct PathfinderSettings {
415 uint8 pathfinder_for_trains;
416 uint8 pathfinder_for_roadvehs;
417 uint8 pathfinder_for_ships;
418 bool new_pathfinding_all;
419
420 bool roadveh_queue;
421 bool forbid_90_deg;
422
423 bool reverse_at_signals;
424 byte wait_oneway_signal;
425 byte wait_twoway_signal;
426
427 bool reserve_paths;
428 byte wait_for_pbs_path;
429 byte path_backoff_interval;
430
431 OPFSettings opf;
432 NPFSettings npf;
433 YAPFSettings yapf;
434 };
435
437 struct OrderSettings {
438 bool improved_load;
439 bool gradual_loading;
440 bool selectgoods;
441 bool no_servicing_if_no_breakdowns;
442 bool serviceathelipad;
443 };
444
446 struct VehicleSettings {
447 uint8 max_train_length;
448 uint8 smoke_amount;
449 uint8 train_acceleration_model;
450 uint8 roadveh_acceleration_model;
451 uint8 train_slope_steepness;
452 uint8 roadveh_slope_steepness;
453 bool wagon_speed_limits;
454 bool disable_elrails;
455 UnitID max_trains;
456 UnitID max_roadveh;
457 UnitID max_aircraft;
458 UnitID max_ships;
459 uint8 plane_speed;
460 uint8 freight_trains;
461 bool dynamic_engines;
462 bool never_expire_vehicles;
463 byte extend_vehicle_life;
464 byte road_side;
465 uint8 plane_crashes;
466 };
467
469 struct EconomySettings {
470 bool inflation;
471 bool bribe;
472 bool smooth_economy;
473 bool allow_shares;
474 uint8 feeder_payment_share;
475 byte dist_local_authority;
476 bool exclusive_rights;
477 bool fund_buildings;
478 bool fund_roads;
479 bool give_money;
480 bool mod_road_rebuild;
481 bool multiple_industry_per_town;
482 uint8 town_growth_rate;
483 uint8 larger_towns;
484 uint8 initial_city_size;
485 TownLayoutByte town_layout;
486 bool allow_town_roads;
487 TownFoundingByte found_town;
488 bool station_noise_level;
489 uint16 town_noise_population[3];
490 bool allow_town_level_crossings;
491 bool infrastructure_maintenance;
492 };
493
494 struct LinkGraphSettings {
495 uint16 recalc_time;
496 uint16 recalc_interval;
497 DistributionTypeByte distribution_pax;
498 DistributionTypeByte distribution_mail;
499 DistributionTypeByte distribution_armoured;
500 DistributionTypeByte distribution_default;
501 uint8 accuracy;
502 uint8 demand_size;
503 uint8 demand_distance;
504 uint8 short_path_saturation;
505
506 inline DistributionType GetDistributionType(CargoID cargo) const {
507 if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax;
508 if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail;
509 if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured;
510 return this->distribution_default;
511 }
512 };
513
515 struct StationSettings {
516 bool modified_catchment;
517 bool adjacent_stations;
518 bool distant_join_stations;
519 bool never_expire_airports;
520 byte station_spread;
521 };
522
524 struct VehicleDefaultSettings {
525 bool servint_ispercent;
526 uint16 servint_trains;
527 uint16 servint_roadveh;
528 uint16 servint_aircraft;
529 uint16 servint_ships;
530 };
531
533 struct CompanySettings {
534 bool engine_renew;
535 int16 engine_renew_months;
536 uint32 engine_renew_money;
537 bool renew_keep_length;
538 VehicleDefaultSettings vehicle;
539 };
540
542 struct GameSettings {
543 DifficultySettings difficulty;
544 GameCreationSettings game_creation;
545 ConstructionSettings construction;
546 AISettings ai;
547 ScriptSettings script;
548 class AIConfig *ai_config[MAX_COMPANIES];
549 class GameConfig *game_config;
550 PathfinderSettings pf;
551 OrderSettings order;
552 VehicleSettings vehicle;
553 EconomySettings economy;
554 LinkGraphSettings linkgraph;
555 StationSettings station;
556 LocaleSettings locale;
557 };
558
560 struct ClientSettings {
561 GUISettings gui;
562 NetworkSettings network;
563 CompanySettings company;
564 SoundSettings sound;
565 MusicSettings music;
566 NewsSettings news_display;
567 };
568
570 extern ClientSettings _settings_client;
571
573 extern GameSettings _settings_game;
574
576 extern GameSettings _settings_newgame;
577
579 extern VehicleDefaultSettings _old_vds;
580
585 static inline GameSettings &GetGameSettings()
586 {
587 return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
588 }
589
590 #endif /* SETTINGS_TYPE_H */