OpenTTD: src/settings_type.h Source File

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 26884 2014-09-21 12:02:03Z rubidium $ */
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 pause_on_newgame;
117 bool enable_signal_gui;
118 Year coloured_news_year;
119 bool timetable_in_ticks;
120 bool quick_goto;
121 bool auto_euro;
122 byte drag_signals_density;
123 bool drag_signals_fixed_distance;
124 Year semaphore_build_before;
125 byte news_message_timeout;
126 bool show_track_reservation;
127 uint8 default_signal_type;
128 uint8 cycle_signal_types;
129 byte station_numtracks;
130 byte station_platlength;
131 bool station_dragdrop;
132 bool station_show_coverage;
133 bool persistent_buildingtools;
134 bool expenses_layout;
135 uint32 last_newgrf_count;
136 byte missing_strings_threshold;
137 uint8 graph_line_thickness;
138 uint8 osk_activation;
139
140 uint16 console_backlog_timeout;
141 uint16 console_backlog_length;
142
143 uint8 station_gui_group_order;
144 uint8 station_gui_sort_by;
145 uint8 station_gui_sort_order;
146 #ifdef ENABLE_NETWORK
147 uint16 network_chat_box_width;
148 uint8 network_chat_box_height;
149 uint16 network_chat_timeout;
150 #endif
151
152 uint8 developer;
153 bool show_date_in_logs;
154 bool newgrf_developer_tools;
155 bool ai_developer_tools;
156 bool scenario_developer;
157 uint8 settings_restriction_mode;
158 bool newgrf_show_old_versions;
159 uint8 newgrf_default_palette;
160
165 bool UserIsAllowedToChangeNewGRFs() const
166 {
167 return this->scenario_developer || this->newgrf_developer_tools;
168 }
169 };
170
172 struct SoundSettings {
173 bool news_ticker;
174 bool news_full;
175 bool new_year;
176 bool confirm;
177 bool click_beep;
178 bool disaster;
179 bool vehicle;
180 bool ambient;
181 };
182
184 struct MusicSettings {
185 byte playlist;
186 byte music_vol;
187 byte effect_vol;
188 byte custom_1[33];
189 byte custom_2[33];
190 bool playing;
191 bool shuffle;
192 };
193
195 struct LocaleSettings {
196 byte currency;
197 byte units_velocity;
198 byte units_power;
199 byte units_weight;
200 byte units_volume;
201 byte units_force;
202 byte units_height;
203 char *digit_group_separator;
204 char *digit_group_separator_currency;
205 char *digit_decimal_separator;
206 };
207
209 struct NewsSettings {
210 uint8 arrival_player;
211 uint8 arrival_other;
212 uint8 accident;
213 uint8 company_info;
214 uint8 open;
215 uint8 close;
216 uint8 economy;
217 uint8 production_player;
218 uint8 production_other;
219 uint8 production_nobody;
220 uint8 advice;
221 uint8 new_vehicles;
222 uint8 acceptance;
223 uint8 subsidies;
224 uint8 general;
225 };
226
228 struct NetworkSettings {
229 #ifdef ENABLE_NETWORK
230 uint16 sync_freq;
231 uint8 frame_freq;
232 uint16 commands_per_frame;
233 uint16 max_commands_in_queue;
234 uint16 bytes_per_frame;
235 uint16 bytes_per_frame_burst;
236 uint16 max_init_time;
237 uint16 max_join_time;
238 uint16 max_download_time;
239 uint16 max_password_time;
240 uint16 max_lag_time;
241 bool pause_on_join;
242 uint16 server_port;
243 uint16 server_admin_port;
244 bool server_admin_chat;
245 char server_name[NETWORK_NAME_LENGTH];
246 char server_password[NETWORK_PASSWORD_LENGTH];
247 char rcon_password[NETWORK_PASSWORD_LENGTH];
248 char admin_password[NETWORK_PASSWORD_LENGTH];
249 bool server_advertise;
250 uint8 lan_internet;
251 char client_name[NETWORK_CLIENT_NAME_LENGTH];
252 char default_company_pass[NETWORK_PASSWORD_LENGTH];
253 char connect_to_ip[NETWORK_HOSTNAME_LENGTH];
254 char network_id[NETWORK_SERVER_ID_LENGTH];
255 bool autoclean_companies;
256 uint8 autoclean_unprotected;
257 uint8 autoclean_protected;
258 uint8 autoclean_novehicles;
259 uint8 max_companies;
260 uint8 max_clients;
261 uint8 max_spectators;
262 Year restart_game_year;
263 uint8 min_active_clients;
264 uint8 server_lang;
265 bool reload_cfg;
266 char last_host[NETWORK_HOSTNAME_LENGTH];
267 uint16 last_port;
268 bool no_http_content_downloads;
269 #else /* ENABLE_NETWORK */
270 #endif
271 };
272
274 struct GameCreationSettings {
275 uint32 generation_seed;
276 Year starting_year;
277 uint8 map_x;
278 uint8 map_y;
279 byte land_generator;
280 byte oil_refinery_limit;
281 byte snow_line_height;
282 byte tgen_smoothness;
283 byte tree_placer;
284 byte heightmap_rotation;
285 byte se_flat_world_height;
286 byte town_name;
287 byte landscape;
288 byte water_borders;
289 uint16 custom_town_number;
290 byte variety;
291 byte custom_sea_level;
292 byte min_river_length;
293 byte river_route_random;
294 byte amount_of_rivers;
295 };
296
298 struct ConstructionSettings {
299 uint8 max_heightlevel;
300 bool build_on_slopes;
301 bool autoslope;
302 uint16 max_bridge_length;
303 byte max_bridge_height;
304 uint16 max_tunnel_length;
305 byte train_signal_side;
306 bool extra_dynamite;
307 bool road_stop_on_town_road;
308 bool road_stop_on_competitor_road;
309 uint8 raw_industry_construction;
310 uint8 industry_platform;
311 bool freeform_edges;
312 uint8 extra_tree_placement;
313 uint8 command_pause_level;
314
315 uint32 terraform_per_64k_frames;
316 uint16 terraform_frame_burst;
317 uint32 clear_per_64k_frames;
318 uint16 clear_frame_burst;
319 uint32 tree_per_64k_frames;
320 uint16 tree_frame_burst;
321 };
322
324 struct AISettings {
325 bool ai_in_multiplayer;
326 bool ai_disable_veh_train;
327 bool ai_disable_veh_roadveh;
328 bool ai_disable_veh_aircraft;
329 bool ai_disable_veh_ship;
330 };
331
333 struct ScriptSettings {
334 uint8 settings_profile;
335 uint32 script_max_opcode_till_suspend;
336 };
337
339 struct OPFSettings {
340 uint16 pf_maxlength;
341 byte pf_maxdepth;
342 };
343
345 struct NPFSettings {
351 uint32 npf_max_search_nodes;
352 uint32 maximum_go_to_depot_penalty;
353
354 uint32 npf_rail_firstred_penalty;
355 uint32 npf_rail_firstred_exit_penalty;
356 uint32 npf_rail_lastred_penalty;
357 uint32 npf_rail_station_penalty;
358 uint32 npf_rail_slope_penalty;
359 uint32 npf_rail_curve_penalty;
360 uint32 npf_rail_depot_reverse_penalty;
361 uint32 npf_rail_pbs_cross_penalty;
362 uint32 npf_rail_pbs_signal_back_penalty;
363 uint32 npf_buoy_penalty;
364 uint32 npf_water_curve_penalty;
365 uint32 npf_road_curve_penalty;
366 uint32 npf_crossing_penalty;
367 uint32 npf_road_drive_through_penalty;
368 uint32 npf_road_dt_occupied_penalty;
369 uint32 npf_road_bay_occupied_penalty;
370 };
371
373 struct YAPFSettings {
374 bool disable_node_optimization;
375 uint32 max_search_nodes;
376 uint32 maximum_go_to_depot_penalty;
377 bool ship_use_yapf;
378 bool road_use_yapf;
379 bool rail_use_yapf;
380 uint32 road_slope_penalty;
381 uint32 road_curve_penalty;
382 uint32 road_crossing_penalty;
383 uint32 road_stop_penalty;
384 uint32 road_stop_occupied_penalty;
385 uint32 road_stop_bay_occupied_penalty;
386 bool rail_firstred_twoway_eol;
387 uint32 rail_firstred_penalty;
388 uint32 rail_firstred_exit_penalty;
389 uint32 rail_lastred_penalty;
390 uint32 rail_lastred_exit_penalty;
391 uint32 rail_station_penalty;
392 uint32 rail_slope_penalty;
393 uint32 rail_curve45_penalty;
394 uint32 rail_curve90_penalty;
395 uint32 rail_depot_reverse_penalty;
396 uint32 rail_crossing_penalty;
397 uint32 rail_look_ahead_max_signals;
398 int32 rail_look_ahead_signal_p0;
399 int32 rail_look_ahead_signal_p1;
400 int32 rail_look_ahead_signal_p2;
401 uint32 rail_pbs_cross_penalty;
402 uint32 rail_pbs_station_penalty;
403 uint32 rail_pbs_signal_back_penalty;
404 uint32 rail_doubleslip_penalty;
405
406 uint32 rail_longer_platform_penalty;
407 uint32 rail_longer_platform_per_tile_penalty;
408 uint32 rail_shorter_platform_penalty;
409 uint32 rail_shorter_platform_per_tile_penalty;
410 };
411
413 struct PathfinderSettings {
414 uint8 pathfinder_for_trains;
415 uint8 pathfinder_for_roadvehs;
416 uint8 pathfinder_for_ships;
417 bool new_pathfinding_all;
418
419 bool roadveh_queue;
420 bool forbid_90_deg;
421
422 bool reverse_at_signals;
423 byte wait_oneway_signal;
424 byte wait_twoway_signal;
425
426 bool reserve_paths;
427 byte wait_for_pbs_path;
428 byte path_backoff_interval;
429
430 OPFSettings opf;
431 NPFSettings npf;
432 YAPFSettings yapf;
433 };
434
436 struct OrderSettings {
437 bool improved_load;
438 bool gradual_loading;
439 bool selectgoods;
440 bool no_servicing_if_no_breakdowns;
441 bool serviceathelipad;
442 };
443
445 struct VehicleSettings {
446 uint8 max_train_length;
447 uint8 smoke_amount;
448 uint8 train_acceleration_model;
449 uint8 roadveh_acceleration_model;
450 uint8 train_slope_steepness;
451 uint8 roadveh_slope_steepness;
452 bool wagon_speed_limits;
453 bool disable_elrails;
454 UnitID max_trains;
455 UnitID max_roadveh;
456 UnitID max_aircraft;
457 UnitID max_ships;
458 uint8 plane_speed;
459 uint8 freight_trains;
460 bool dynamic_engines;
461 bool never_expire_vehicles;
462 byte extend_vehicle_life;
463 byte road_side;
464 uint8 plane_crashes;
465 };
466
468 struct EconomySettings {
469 bool inflation;
470 bool bribe;
471 bool smooth_economy;
472 bool allow_shares;
473 uint8 feeder_payment_share;
474 byte dist_local_authority;
475 bool exclusive_rights;
476 bool fund_buildings;
477 bool fund_roads;
478 bool give_money;
479 bool mod_road_rebuild;
480 bool multiple_industry_per_town;
481 uint8 town_growth_rate;
482 uint8 larger_towns;
483 uint8 initial_city_size;
484 TownLayoutByte town_layout;
485 bool allow_town_roads;
486 TownFoundingByte found_town;
487 bool station_noise_level;
488 uint16 town_noise_population[3];
489 bool allow_town_level_crossings;
490 bool infrastructure_maintenance;
491 };
492
493 struct LinkGraphSettings {
494 uint16 recalc_time;
495 uint16 recalc_interval;
496 DistributionTypeByte distribution_pax;
497 DistributionTypeByte distribution_mail;
498 DistributionTypeByte distribution_armoured;
499 DistributionTypeByte distribution_default;
500 uint8 accuracy;
501 uint8 demand_size;
502 uint8 demand_distance;
503 uint8 short_path_saturation;
504
505 inline DistributionType GetDistributionType(CargoID cargo) const {
506 if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax;
507 if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail;
508 if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured;
509 return this->distribution_default;
510 }
511 };
512
514 struct StationSettings {
515 bool modified_catchment;
516 bool adjacent_stations;
517 bool distant_join_stations;
518 bool never_expire_airports;
519 byte station_spread;
520 };
521
523 struct VehicleDefaultSettings {
524 bool servint_ispercent;
525 uint16 servint_trains;
526 uint16 servint_roadveh;
527 uint16 servint_aircraft;
528 uint16 servint_ships;
529 };
530
532 struct CompanySettings {
533 bool engine_renew;
534 int16 engine_renew_months;
535 uint32 engine_renew_money;
536 bool renew_keep_length;
537 VehicleDefaultSettings vehicle;
538 };
539
541 struct GameSettings {
542 DifficultySettings difficulty;
543 GameCreationSettings game_creation;
544 ConstructionSettings construction;
545 AISettings ai;
546 ScriptSettings script;
547 class AIConfig *ai_config[MAX_COMPANIES];
548 class GameConfig *game_config;
549 PathfinderSettings pf;
550 OrderSettings order;
551 VehicleSettings vehicle;
552 EconomySettings economy;
553 LinkGraphSettings linkgraph;
554 StationSettings station;
555 LocaleSettings locale;
556 };
557
559 struct ClientSettings {
560 GUISettings gui;
561 NetworkSettings network;
562 CompanySettings company;
563 SoundSettings sound;
564 MusicSettings music;
565 NewsSettings news_display;
566 };
567
569 extern ClientSettings _settings_client;
570
572 extern GameSettings _settings_game;
573
575 extern GameSettings _settings_newgame;
576
578 extern VehicleDefaultSettings _old_vds;
579
584 static inline GameSettings &GetGameSettings()
585 {
586 return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
587 }
588
589 #endif /* SETTINGS_TYPE_H */