1 /*
2  * Copyright (c) 1997 - 2003 Hj. Malthaner
3  *
4  * This file is part of the Simutrans project under the artistic licence.
5  * (see licence.txt)
6  */
7 
8 #include "welt.h"
9 #include "simwin.h"
10 #include "../simversion.h"
11 #include "../dataobj/settings.h"
12 #include "../dataobj/environment.h"
13 #include "../dataobj/translator.h"
14 #include "../player/finance.h" // MAX_PLAYER_HISTORY_YEARS
15 #include "../vehicle/simvehicle.h"
16 #include "settings_stats.h"
17 #include "components/gui_divider.h"
18 
19 
20 /* stuff not set here ....
21 INIT_NUM( "intercity_road_length", env_t::intercity_road_length);
22 INIT_NUM( "diagonal_multiplier", pak_diagonal_multiplier);
23 */
24 
25 
26 static char const* const version[] =
27 {
28 	"0.99.17",
29 	"0.100.0",
30 	"0.101.0",
31 	"0.102.1",
32 	"0.102.2",
33 	"0.102.5",
34 	"0.110.0",
35 	"0.110.1",
36 	"0.111.0",
37 	"0.111.1",
38 	"0.111.2",
39 	"0.111.3",
40 	"0.111.4",
41 	"0.112.0",
42 	"0.112.2",
43 	"0.120.1",
44 	"0.120.2",
45 	"0.120.3",
46 	"0.120.4",
47 	"0.120.5"
48 };
49 
50 
action_triggered(gui_action_creator_t * comp,value_t v)51 bool settings_general_stats_t::action_triggered(gui_action_creator_t *comp, value_t v)
52 {
53 	assert( comp==&savegame ); (void)comp;
54 
55 	if(  v.i==-1  ) {
56 		savegame.set_selection( 0 );
57 	}
58 	return true;
59 }
60 
61 /* Nearly automatic lists with controls:
62  * BEWARE: The init exit pair MUST match in the same order or else!!!
63  */
init(settings_t const * const sets)64 void settings_general_stats_t::init(settings_t const* const sets)
65 {
66 	INIT_INIT
67 
68 	// combobox for savegame version
69 	for(  uint32 i=0;  i<lengthof(version);  i++  ) {
70 		savegame.new_component<gui_scrolled_list_t::const_text_scrollitem_t>( version[i]+2, SYSCOL_TEXT ) ;
71 		if(  strcmp(version[i],env_t::savegame_version_str)==0  ) {
72 			savegame.set_selection( i );
73 		}
74 	}
75 	savegame.set_focusable( false );
76 	add_component( &savegame );
77 	savegame.add_listener( this );
78 	INIT_LB( "savegame version" );
79 	SEPERATOR
80 	INIT_BOOL( "drive_left", sets->is_drive_left() );
81 	INIT_BOOL( "signals_on_left", sets->is_signals_left() );
82 	SEPERATOR
83 	INIT_NUM( "autosave", env_t::autosave, 0, 12, gui_numberinput_t::AUTOLINEAR, false );
84 	INIT_NUM( "fast_forward", env_t::max_acceleration, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
85 	SEPERATOR
86 	INIT_BOOL( "numbered_stations", sets->get_numbered_stations() );
87 	INIT_NUM( "show_names", env_t::show_names, 0, 3, gui_numberinput_t::AUTOLINEAR, true );
88 	SEPERATOR
89 	INIT_NUM( "bits_per_month", sets->get_bits_per_month(), 16, 24, gui_numberinput_t::AUTOLINEAR, false );
90 	INIT_NUM( "use_timeline", sets->get_use_timeline(), 0, 3, gui_numberinput_t::AUTOLINEAR, false );
91 	INIT_NUM_NEW( "starting_year", sets->get_starting_year(), 0, 2999, gui_numberinput_t::AUTOLINEAR, false );
92 	INIT_NUM_NEW( "starting_month", sets->get_starting_month(), 0, 11, gui_numberinput_t::AUTOLINEAR, false );
93 	INIT_NUM( "show_month", env_t::show_month, 0, 7, gui_numberinput_t::AUTOLINEAR, true );
94 	SEPERATOR
95 	INIT_NUM( "random_grounds_probability", env_t::ground_object_probability, 0, 0x7FFFFFFFul, gui_numberinput_t::POWER2, false );
96 	INIT_NUM( "random_wildlife_probability", env_t::moving_object_probability, 0, 0x7FFFFFFFul, gui_numberinput_t::POWER2, false );
97 	SEPERATOR
98 	INIT_BOOL( "pedes_and_car_info", env_t::road_user_info );
99 	INIT_BOOL( "tree_info", env_t::tree_info );
100 	INIT_BOOL( "ground_info", env_t::ground_info );
101 	INIT_BOOL( "townhall_info", env_t::townhall_info );
102 	INIT_BOOL( "only_single_info", env_t::single_info );
103 	SEPERATOR
104 	INIT_NUM( "compass_map_position", env_t::compass_map_position, 0, 16, gui_numberinput_t::AUTOLINEAR, false );
105 	INIT_NUM( "compass_screen_position", env_t::compass_screen_position, 0, 16, gui_numberinput_t::AUTOLINEAR, false );
106 	SEPERATOR
107 	INIT_NUM( "world_maximum_height", sets->get_maximumheight(), 16, 127, gui_numberinput_t::AUTOLINEAR, false );
108 	INIT_NUM( "world_minimum_height", sets->get_minimumheight(), -127, -12, gui_numberinput_t::AUTOLINEAR, false );
109 
110 	INIT_END
111 	clear_dirty();
112 }
113 
read(settings_t * const sets)114 void settings_general_stats_t::read(settings_t* const sets)
115 {
116 	READ_INIT
117 
118 	int selected = savegame.get_selection();
119 	if(  0 <= selected  &&  (uint32)selected < lengthof(version)  ) {
120 		env_t::savegame_version_str = version[ selected ];
121 	}
122 
123 	READ_BOOL_VALUE( sets->drive_on_left );
124 	vehicle_base_t::set_overtaking_offsets( sets->drive_on_left );
125 	READ_BOOL_VALUE( sets->signals_on_left );
126 
127 	READ_NUM_VALUE( env_t::autosave );
128 	READ_NUM_VALUE( env_t::max_acceleration );
129 
130 	READ_BOOL_VALUE( sets->numbered_stations );
131 	READ_NUM_VALUE( env_t::show_names );
132 
133 	READ_NUM_VALUE( sets->bits_per_month );
134 	READ_NUM_VALUE( sets->use_timeline );
135 	READ_NUM_VALUE_NEW( sets->starting_year );
136 	READ_NUM_VALUE_NEW( sets->starting_month );
137 	READ_NUM_VALUE( env_t::show_month );
138 
139 	READ_NUM_VALUE( env_t::ground_object_probability );
140 	READ_NUM_VALUE( env_t::moving_object_probability );
141 
142 	READ_BOOL_VALUE( env_t::road_user_info );
143 	READ_BOOL_VALUE( env_t::tree_info );
144 	READ_BOOL_VALUE( env_t::ground_info );
145 	READ_BOOL_VALUE( env_t::townhall_info );
146 	READ_BOOL_VALUE( env_t::single_info );
147 
148 	READ_NUM_VALUE( env_t::compass_map_position );
149 	READ_NUM_VALUE( env_t::compass_screen_position );
150 
151 	READ_NUM_VALUE( sets->world_maximum_height );
152 	READ_NUM_VALUE( sets->world_minimum_height );
153 }
154 
init(settings_t const * const)155 void settings_display_stats_t::init(settings_t const* const)
156 {
157 	INIT_INIT
158 	INIT_NUM( "frames_per_second",env_t::fps, 10, 25, gui_numberinput_t::AUTOLINEAR, false );
159 	INIT_NUM( "simple_drawing_tile_size",env_t::simple_drawing_default, 2, 256, gui_numberinput_t::POWER2, false );
160 	INIT_BOOL( "simple_drawing_fast_forward",env_t::simple_drawing_fast_forward );
161 	INIT_NUM( "water_animation_ms", env_t::water_animation, 0, 1000, 25, false );
162 	INIT_NUM( "follow_convoi_underground", env_t::follow_convoi_underground, 0, 2, 1, true );
163 	SEPERATOR
164 	INIT_BOOL( "window_buttons_right", env_t::window_buttons_right );
165 	INIT_BOOL( "window_frame_active", env_t::window_frame_active );
166 	INIT_NUM( "default_window_title_color", env_t::default_window_title_color_rgb, 0, 16777215, gui_numberinput_t::AUTOLINEAR, 0 );
167 	INIT_NUM( "front_window_text_color", env_t::front_window_text_color_rgb, 0, 16777215, gui_numberinput_t::AUTOLINEAR, 0 );
168 	INIT_NUM( "bottom_window_text_color", env_t::bottom_window_text_color_rgb, 0, 16777215, gui_numberinput_t::AUTOLINEAR, 0 );
169 	INIT_NUM( "bottom_window_darkness", env_t::bottom_window_darkness, 0, 100, gui_numberinput_t::AUTOLINEAR, 0 );
170 	SEPERATOR
171 	INIT_BOOL( "show_tooltips", env_t::show_tooltips );
172 	INIT_NUM( "tooltip_background_color", env_t::tooltip_color_rgb, 0, 16777215, 1, 0 );
173 	INIT_NUM( "tooltip_text_color", env_t::tooltip_textcolor_rgb, 0, 16777215, 1, 0 );
174 	INIT_NUM( "tooltip_delay", env_t::tooltip_delay, 0, 10000, gui_numberinput_t::AUTOLINEAR, 0 );
175 	INIT_NUM( "tooltip_duration", env_t::tooltip_duration, 0, 30000, gui_numberinput_t::AUTOLINEAR, 0 );
176 	SEPERATOR
177 	INIT_NUM( "cursor_overlay_color", env_t::cursor_overlay_color_rgb, 0, 16777215, gui_numberinput_t::AUTOLINEAR, 0 );
178 	INIT_BOOL( "left_to_right_graphs", env_t::left_to_right_graphs );
179 	SEPERATOR
180 	INIT_BOOL( "player_finance_display_account", env_t::player_finance_display_account );
181 
182 	INIT_END
183 }
184 
read(settings_t * const)185 void settings_display_stats_t::read(settings_t* const)
186 {
187 	READ_INIT
188 	// all visual stuff
189 	READ_NUM_VALUE( env_t::fps );
190 	READ_NUM_VALUE( env_t::simple_drawing_default );
191 	READ_BOOL_VALUE( env_t::simple_drawing_fast_forward );
192 	READ_NUM_VALUE( env_t::water_animation );
193 	READ_NUM_VALUE( env_t::follow_convoi_underground );
194 
195 	READ_BOOL_VALUE( env_t::window_buttons_right );
196 	READ_BOOL_VALUE( env_t::window_frame_active );
197 	READ_NUM_VALUE( env_t::default_window_title_color_rgb );
198 	READ_NUM_VALUE( env_t::front_window_text_color_rgb );
199 	READ_NUM_VALUE( env_t::bottom_window_text_color_rgb );
200 	READ_NUM_VALUE( env_t::bottom_window_darkness );
201 
202 	READ_BOOL_VALUE( env_t::show_tooltips );
203 	READ_NUM_VALUE( env_t::tooltip_color_rgb );
204 	READ_NUM_VALUE( env_t::tooltip_textcolor_rgb );
205 	READ_NUM_VALUE( env_t::tooltip_delay );
206 	READ_NUM_VALUE( env_t::tooltip_duration );
207 
208 	READ_NUM_VALUE( env_t::cursor_overlay_color_rgb );
209 	READ_BOOL_VALUE( env_t::left_to_right_graphs );
210 
211 	READ_BOOL_VALUE( env_t::player_finance_display_account );
212 }
213 
init(settings_t const * const sets)214 void settings_routing_stats_t::init(settings_t const* const sets)
215 {
216 	INIT_INIT
217 	INIT_BOOL( "separate_halt_capacities", sets->is_separate_halt_capacities() );
218 	INIT_BOOL( "avoid_overcrowding", sets->is_avoid_overcrowding() );
219 	INIT_BOOL( "no_routing_over_overcrowded", sets->is_no_routing_over_overcrowding() );
220 	INIT_NUM( "station_coverage", sets->get_station_coverage(), 1, 8, gui_numberinput_t::AUTOLINEAR, false );
221 	INIT_NUM( "allow_merge_distant_halt", sets->get_allow_merge_distant_halt(), 0, 0x7FFFFFFFul, gui_numberinput_t::POWER2, false );
222 	SEPERATOR
223 	INIT_NUM( "max_route_steps", sets->get_max_route_steps(), 0, 0x7FFFFFFFul, gui_numberinput_t::POWER2, false );
224 	INIT_NUM( "max_choose_route_steps", sets->get_max_choose_route_steps(), 0, 0x7FFFFFFFul, gui_numberinput_t::POWER2, false );
225 	INIT_NUM( "max_hops", sets->get_max_hops(), 100, 65000, gui_numberinput_t::POWER2, false );
226 	INIT_NUM( "max_transfers", sets->get_max_transfers(), 1, 100, gui_numberinput_t::AUTOLINEAR, false );
227 	SEPERATOR
228 	INIT_NUM( "way_straight", sets->way_count_straight, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
229 	INIT_NUM( "way_curve", sets->way_count_curve, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
230 	INIT_NUM( "way_double_curve", sets->way_count_double_curve, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
231 	INIT_NUM( "way_90_curve", sets->way_count_90_curve, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
232 	INIT_NUM( "way_slope", sets->way_count_slope, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
233 	INIT_NUM( "way_tunnel", sets->way_count_tunnel, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
234 	INIT_NUM( "way_max_bridge_len", sets->way_max_bridge_len, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
235 	INIT_NUM( "way_leaving_road", sets->way_count_leaving_road, 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
236 
237 	INIT_END
238 }
239 
read(settings_t * const sets)240 void settings_routing_stats_t::read(settings_t* const sets)
241 {
242 	READ_INIT
243 	// routing of goods
244 	READ_BOOL_VALUE( sets->separate_halt_capacities );
245 	READ_BOOL_VALUE( sets->avoid_overcrowding );
246 	READ_BOOL_VALUE( sets->no_routing_over_overcrowding );
247 	READ_NUM_VALUE( sets->station_coverage_size );
248 	READ_NUM_VALUE( sets->allow_merge_distant_halt );
249 	READ_NUM_VALUE( sets->max_route_steps );
250 	READ_NUM_VALUE( sets->max_choose_route_steps );
251 	READ_NUM_VALUE( sets->max_hops );
252 	READ_NUM_VALUE( sets->max_transfers );
253 	// routing on ways
254 	READ_NUM_VALUE( sets->way_count_straight );
255 	READ_NUM_VALUE( sets->way_count_curve );
256 	READ_NUM_VALUE( sets->way_count_double_curve );
257 	READ_NUM_VALUE( sets->way_count_90_curve );
258 	READ_NUM_VALUE( sets->way_count_slope );
259 	READ_NUM_VALUE( sets->way_count_tunnel );
260 	READ_NUM_VALUE( sets->way_max_bridge_len );
261 	READ_NUM_VALUE( sets->way_count_leaving_road );
262 }
263 
264 
init(settings_t const * const sets)265 void settings_economy_stats_t::init(settings_t const* const sets)
266 {
267 	INIT_INIT
268 	INIT_NUM( "remove_dummy_player_months", sets->get_remove_dummy_player_months(), 0, MAX_PLAYER_HISTORY_YEARS*12, 12, false );
269 	INIT_NUM( "unprotect_abandoned_player_months", sets->get_unprotect_abandoned_player_months(), 0, MAX_PLAYER_HISTORY_YEARS*12, 12, false );
270 	INIT_NUM( "ai_construction_speed", sets->get_default_ai_construction_speed(), 0, 1000000000, 1000, false );
271 	SEPERATOR
272 
273 	INIT_COST( "starting_money", sets->get_starting_money(sets->get_starting_year()), 1, 0x7FFFFFFFul, 10000, false );
274 	INIT_NUM( "pay_for_total_distance", sets->get_pay_for_total_distance_mode(), 0, 2, gui_numberinput_t::AUTOLINEAR, true );
275 	INIT_NUM( "bonus_basefactor", sets->get_bonus_basefactor(), 0, 1000, gui_numberinput_t::AUTOLINEAR, false );
276 	INIT_BOOL_NEW( "first_beginner", sets->get_beginner_mode() );
277 	INIT_NUM( "beginner_price_factor", sets->get_beginner_price_factor(), 1, 25000, gui_numberinput_t::AUTOLINEAR, false );
278 	SEPERATOR
279 
280 	INIT_BOOL( "allow_buying_obsolete_vehicles", sets->get_allow_buying_obsolete_vehicles() );
281 	INIT_NUM( "used_vehicle_reduction", sets->get_used_vehicle_reduction(), 1, 1000, gui_numberinput_t::AUTOLINEAR, false );
282 	INIT_NUM( "max_rail_convoi_length", sets->get_max_rail_convoi_length(), 1, 254, gui_numberinput_t::AUTOLINEAR, false );
283 	INIT_NUM( "max_road_convoi_length", sets->get_max_road_convoi_length(), 1, 254, gui_numberinput_t::AUTOLINEAR, false );
284 	INIT_NUM( "max_ship_convoi_length", sets->get_max_ship_convoi_length(), 1, 254, gui_numberinput_t::AUTOLINEAR, false );
285 	INIT_NUM( "max_air_convoi_length", sets->get_max_air_convoi_length(), 1, 254, gui_numberinput_t::AUTOLINEAR, false );
286 	SEPERATOR
287 
288 	INIT_NUM( "toll_runningcost_percentage", sets->get_way_toll_runningcost_percentage(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
289 	INIT_NUM( "toll_waycost_percentage", sets->get_way_toll_waycost_percentage(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
290 	INIT_BOOL("disable_make_way_public", sets->get_disable_make_way_public());
291 	SEPERATOR
292 
293 	INIT_NUM( "just_in_time", sets->get_just_in_time(), 0, 2, gui_numberinput_t::AUTOLINEAR, false );
294 	INIT_NUM( "maximum_intransit_percentage", sets->get_factory_maximum_intransit_percentage(), 0, 32767, gui_numberinput_t::AUTOLINEAR, false );
295 	INIT_BOOL( "crossconnect_factories", sets->is_crossconnect_factories() );
296 	INIT_NUM( "crossconnect_factories_percentage", sets->get_crossconnect_factor(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
297 	INIT_NUM( "industry_increase_every", sets->get_industry_increase_every(), 0, 100000, 100, false );
298 	INIT_NUM( "min_factory_spacing", sets->get_min_factory_spacing(), 1, 32767, gui_numberinput_t::AUTOLINEAR, false );
299 	INIT_NUM( "max_factory_spacing_percent", sets->get_max_factory_spacing_percent(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
300 	INIT_NUM( "max_factory_spacing", sets->get_max_factory_spacing(), 1, 32767, gui_numberinput_t::AUTOLINEAR, false );
301 	INIT_NUM( "electric_promille", sets->get_electric_promille(), 0, 1000, gui_numberinput_t::AUTOLINEAR, false );
302 	INIT_BOOL( "allow_underground_transformers", sets->get_allow_underground_transformers() );
303 	INIT_NUM( "way_height_clearance", sets->get_way_height_clearance(), 1, 2, gui_numberinput_t::AUTOLINEAR, true );
304 	SEPERATOR
305 
306 	INIT_NUM( "passenger_factor",  sets->get_passenger_factor(), 0, 16, gui_numberinput_t::AUTOLINEAR, false );
307 	INIT_NUM( "minimum_city_distance", sets->get_minimum_city_distance(), 1, 20000, 10, false );
308 	INIT_NUM( "special_building_distance", sets->get_special_building_distance(), 1, 150, 1, false );
309 	INIT_NUM( "factory_worker_radius", sets->get_factory_worker_radius(), 0, 32767, gui_numberinput_t::AUTOLINEAR, false );
310 	INIT_NUM( "factory_worker_minimum_towns", sets->get_factory_worker_minimum_towns(), 0, 32767, gui_numberinput_t::AUTOLINEAR, false );
311 	INIT_NUM( "factory_worker_maximum_towns", sets->get_factory_worker_maximum_towns(), 0, 32767, gui_numberinput_t::AUTOLINEAR, false );
312 	INIT_NUM( "factory_arrival_periods", sets->get_factory_arrival_periods(), 1, 16, gui_numberinput_t::AUTOLINEAR, false );
313 	INIT_BOOL( "factory_enforce_demand", sets->get_factory_enforce_demand() );
314 	INIT_NUM( "factory_worker_percentage", sets->get_factory_worker_percentage(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
315 	INIT_NUM( "tourist_percentage", sets->get_tourist_percentage(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
316 	SEPERATOR
317 	INIT_NUM( "locality_factor[0].year", sets->locality_factor_per_year[0].year, 0, 2999, 10, false );
318 	INIT_NUM( "locality_factor[0].factor", sets->locality_factor_per_year[0].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
319 	INIT_NUM( "locality_factor[1].year", sets->locality_factor_per_year[1].year, 0, 2999, 10, false );
320 	INIT_NUM( "locality_factor[1].factor", sets->locality_factor_per_year[1].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
321 	INIT_NUM( "locality_factor[2].year", sets->locality_factor_per_year[2].year, 0, 2999, 10, false );
322 	INIT_NUM( "locality_factor[2].factor", sets->locality_factor_per_year[2].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
323 	INIT_NUM( "locality_factor[3].year", sets->locality_factor_per_year[3].year, 0, 2999, 10, false );
324 	INIT_NUM( "locality_factor[3].factor", sets->locality_factor_per_year[3].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
325 	INIT_NUM( "locality_factor[4].year", sets->locality_factor_per_year[4].year, 0, 2999, 10, false );
326 	INIT_NUM( "locality_factor[4].factor", sets->locality_factor_per_year[4].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
327 	INIT_NUM( "locality_factor[5].year", sets->locality_factor_per_year[5].year, 0, 2999, 10, false );
328 	INIT_NUM( "locality_factor[5].factor", sets->locality_factor_per_year[5].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
329 	INIT_NUM( "locality_factor[6].year", sets->locality_factor_per_year[6].year, 0, 2999, 10, false );
330 	INIT_NUM( "locality_factor[6].factor", sets->locality_factor_per_year[6].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
331 	INIT_NUM( "locality_factor[7].year", sets->locality_factor_per_year[7].year, 0, 2999, 10, false );
332 	INIT_NUM( "locality_factor[7].factor", sets->locality_factor_per_year[7].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
333 	INIT_NUM( "locality_factor[8].year", sets->locality_factor_per_year[8].year, 0, 2999, 10, false );
334 	INIT_NUM( "locality_factor[8].factor", sets->locality_factor_per_year[8].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
335 	INIT_NUM( "locality_factor[9].year", sets->locality_factor_per_year[9].year, 0, 2999, 10, false );
336 	INIT_NUM( "locality_factor[9].factor", sets->locality_factor_per_year[9].factor, 1, 0x7FFFFFFFu, gui_numberinput_t::POWER2, false );
337 	SEPERATOR
338 	INIT_NUM( "passenger_multiplier", sets->get_passenger_multiplier(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
339 	INIT_NUM( "mail_multiplier", sets->get_mail_multiplier(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
340 	INIT_NUM( "goods_multiplier", sets->get_goods_multiplier(), 0, 100, gui_numberinput_t::AUTOLINEAR, false );
341 //	INIT_NUM( "electricity_multiplier", sets->get_electricity_multiplier(), 0, 10000, 10, false );
342 	SEPERATOR
343 	INIT_NUM( "growthfactor_villages", sets->get_growthfactor_small(), 1, 10000, 10, false );
344 	INIT_NUM( "growthfactor_cities", sets->get_growthfactor_medium(), 1, 10000, 10, false );
345 	INIT_NUM( "growthfactor_capitals", sets->get_growthfactor_large(), 1, 10000, 10, false );
346 	SEPERATOR
347 	INIT_BOOL( "random_pedestrians", sets->get_random_pedestrians() );
348 	INIT_BOOL( "stop_pedestrians", sets->get_show_pax() );
349 	INIT_NUM( "citycar_level", sets->get_traffic_level(), 0, 16, 1, false );
350 	INIT_NUM( "default_citycar_life", sets->get_stadtauto_duration(), 1, 1200, 12, false );
351 
352 	INIT_END
353 }
354 
read(settings_t * const sets)355 void settings_economy_stats_t::read(settings_t* const sets)
356 {
357 	READ_INIT
358 	sint64 start_money_temp;
359 	READ_NUM_VALUE( sets->remove_dummy_player_months );
360 	READ_NUM_VALUE( sets->unprotect_abandoned_player_months );
361 	READ_NUM_VALUE( sets->default_ai_construction_speed );
362 	env_t::default_ai_construction_speed = sets->get_default_ai_construction_speed();
363 	READ_COST_VALUE( start_money_temp );
364 	if(  sets->get_starting_money(sets->get_starting_year())!=start_money_temp  ) {
365 		// because this will render the table based values invalid, we do this only when needed
366 		sets->starting_money = start_money_temp;
367 	}
368 	READ_NUM_VALUE( sets->pay_for_total_distance );
369 	READ_NUM_VALUE( sets->bonus_basefactor );
370 	READ_BOOL_VALUE_NEW( sets->beginner_mode );
371 	READ_NUM_VALUE( sets->beginner_price_factor );
372 
373 	READ_BOOL_VALUE( sets->allow_buying_obsolete_vehicles );
374 	READ_NUM_VALUE( sets->used_vehicle_reduction );
375 	READ_NUM_VALUE( sets->max_rail_convoi_length );
376 	READ_NUM_VALUE( sets->max_road_convoi_length );
377 	READ_NUM_VALUE( sets->max_ship_convoi_length );
378 	READ_NUM_VALUE( sets->max_air_convoi_length );
379 
380 	READ_NUM_VALUE( sets->way_toll_runningcost_percentage );
381 	READ_NUM_VALUE( sets->way_toll_waycost_percentage );
382 	READ_BOOL_VALUE(sets->disable_make_way_public);
383 
384 	READ_NUM_VALUE( env_t::just_in_time );
385 	sets->just_in_time = env_t::just_in_time;
386 	READ_NUM_VALUE( sets->factory_maximum_intransit_percentage );
387 	READ_BOOL_VALUE( sets->crossconnect_factories );
388 	READ_NUM_VALUE( sets->crossconnect_factor );
389 	READ_NUM_VALUE( sets->industry_increase );
390 	READ_NUM_VALUE( sets->min_factory_spacing );
391 	READ_NUM_VALUE( sets->max_factory_spacing_percentage );
392 	READ_NUM_VALUE( sets->max_factory_spacing );
393 	READ_NUM_VALUE( sets->electric_promille );
394 	READ_BOOL_VALUE( sets->allow_underground_transformers );
395 	READ_NUM_VALUE( sets->way_height_clearance );
396 
397 	READ_NUM_VALUE( sets->passenger_factor );
398 	READ_NUM_VALUE( sets->minimum_city_distance );
399 	READ_NUM_VALUE( sets->special_building_distance );
400 	READ_NUM_VALUE( sets->factory_worker_radius );
401 	READ_NUM_VALUE( sets->factory_worker_minimum_towns );
402 	READ_NUM_VALUE( sets->factory_worker_maximum_towns );
403 	READ_NUM_VALUE( sets->factory_arrival_periods );
404 	READ_BOOL_VALUE( sets->factory_enforce_demand );
405 	READ_NUM_VALUE( sets->factory_worker_percentage );
406 	READ_NUM_VALUE( sets->tourist_percentage );
407 	for(  int i=0;  i<10;  i++  ) {
408 		READ_NUM_VALUE( sets->locality_factor_per_year[i].year );
409 		READ_NUM_VALUE( sets->locality_factor_per_year[i].factor );
410 	}
411 	READ_NUM_VALUE( sets->passenger_multiplier );
412 	READ_NUM_VALUE( sets->mail_multiplier );
413 	READ_NUM_VALUE( sets->goods_multiplier );
414 //	READ_NUM_VALUE( sets->set_electricity_multiplier );
415 	READ_NUM_VALUE( sets->growthfactor_small );
416 	READ_NUM_VALUE( sets->growthfactor_medium );
417 	READ_NUM_VALUE( sets->growthfactor_large );
418 	READ_BOOL( sets->set_random_pedestrians );
419 	READ_BOOL( sets->set_show_pax );
420 	READ_NUM( sets->set_traffic_level );
421 	READ_NUM_VALUE( sets->stadtauto_duration );
422 }
423 
424 
init(settings_t const * const sets)425 void settings_costs_stats_t::init(settings_t const* const sets)
426 {
427 	INIT_INIT
428 	INIT_NUM( "maintenance_building", sets->maint_building, 1, 100000000, 100, false );
429 	INIT_COST( "cost_multiply_dock", -sets->cst_multiply_dock, 1, 100000000, 10, false );
430 	INIT_COST( "cost_multiply_station", -sets->cst_multiply_station, 1, 100000000, 10, false );
431 	INIT_COST( "cost_multiply_roadstop", -sets->cst_multiply_roadstop, 1, 100000000, 10, false );
432 	INIT_COST( "cost_multiply_airterminal", -sets->cst_multiply_airterminal, 1, 100000000, 10, false );
433 	INIT_COST( "cost_multiply_post", -sets->cst_multiply_post, 1, 100000000, 10, false );
434 	INIT_COST( "cost_multiply_headquarter", -sets->cst_multiply_headquarter, 1, 100000000, 10, false );
435 	INIT_COST( "cost_depot_air", -sets->cst_depot_air, 1, 100000000, 10, false );
436 	INIT_COST( "cost_depot_rail", -sets->cst_depot_rail, 1, 100000000, 10, false );
437 	INIT_COST( "cost_depot_road", -sets->cst_depot_road, 1, 100000000, 10, false );
438 	INIT_COST( "cost_depot_ship", -sets->cst_depot_ship, 1, 100000000, 10, false );
439 	INIT_COST( "cost_buy_land", -sets->cst_buy_land, 1, 100000000, 10, false );
440 	INIT_COST( "cost_alter_land", -sets->cst_alter_land, 1, 100000000, 10, false );
441 	INIT_COST( "cost_set_slope", -sets->cst_set_slope, 1, 100000000, 10, false );
442 	INIT_COST( "cost_alter_climate", -sets->cst_alter_climate, 1, 100000000, 10, false );
443 	INIT_COST( "cost_found_city", -sets->cst_found_city, 1, 100000000, 10, false );
444 	INIT_COST( "cost_multiply_found_industry", -sets->cst_multiply_found_industry, 1, 100000000, 10, false );
445 	INIT_COST( "cost_remove_tree", -sets->cst_remove_tree, 1, 100000000, 10, false );
446 	INIT_COST( "cost_multiply_remove_haus", -sets->cst_multiply_remove_haus, 1, 100000000, 10, false );
447 	INIT_COST( "cost_multiply_remove_field", -sets->cst_multiply_remove_field, 1, 100000000, 10, false );
448 	INIT_COST( "cost_transformer", -sets->cst_transformer, 1, 100000000, 10, false );
449 	INIT_COST( "cost_maintain_transformer", -sets->cst_maintain_transformer, 1, 100000000, 10, false );
450 	INIT_NUM("cost_make_public_months", sets->cst_make_public_months, 0, 36000, gui_numberinput_t::AUTOLINEAR, false );
451 	INIT_END
452 }
453 
454 
read(settings_t * const sets)455 void settings_costs_stats_t::read(settings_t* const sets)
456 {
457 	READ_INIT
458 	(void)booliter;
459 	READ_NUM_VALUE( sets->maint_building );
460 	READ_COST_VALUE( sets->cst_multiply_dock )*(-1);
461 	READ_COST_VALUE( sets->cst_multiply_station )*(-1);
462 	READ_COST_VALUE( sets->cst_multiply_roadstop )*(-1);
463 	READ_COST_VALUE( sets->cst_multiply_airterminal )*(-1);
464 	READ_COST_VALUE( sets->cst_multiply_post )*(-1);
465 	READ_COST_VALUE( sets->cst_multiply_headquarter )*(-1);
466 	READ_COST_VALUE( sets->cst_depot_air )*(-1);
467 	READ_COST_VALUE( sets->cst_depot_rail )*(-1);
468 	READ_COST_VALUE( sets->cst_depot_road )*(-1);
469 	READ_COST_VALUE( sets->cst_depot_ship )*(-1);
470 	READ_COST_VALUE( sets->cst_buy_land )*(-1);
471 	READ_COST_VALUE( sets->cst_alter_land )*(-1);
472 	READ_COST_VALUE( sets->cst_set_slope )*(-1);
473 	READ_COST_VALUE( sets->cst_alter_climate )*(-1);
474 	READ_COST_VALUE( sets->cst_found_city )*(-1);
475 	READ_COST_VALUE( sets->cst_multiply_found_industry )*(-1);
476 	READ_COST_VALUE( sets->cst_remove_tree )*(-1);
477 	READ_COST_VALUE( sets->cst_multiply_remove_haus )*(-1);
478 	READ_COST_VALUE( sets->cst_multiply_remove_field )*(-1);
479 	READ_COST_VALUE( sets->cst_transformer )*(-1);
480 	READ_COST_VALUE( sets->cst_maintain_transformer )*(-1);
481 	READ_NUM_VALUE(sets->cst_make_public_months);
482 }
483 
484 
485 #include "../descriptor/ground_desc.h"
486 
487 
init(settings_t * const sets)488 void settings_climates_stats_t::init(settings_t* const sets)
489 {
490 	int mountain_height_start = (int)sets->get_max_mountain_height();
491 	int mountain_roughness_start = (int)(sets->get_map_roughness()*20.0 + 0.5)-8;
492 
493 	local_sets = sets;
494 	INIT_INIT
495 	INIT_NUM_NEW( "height_map_conversion_version", env_t::pak_height_conversion_factor, 1, 2, 0, false );
496 	SEPERATOR
497 	INIT_NUM_NEW( "Water level", sets->get_groundwater(), sets->get_minimumheight()+10, 0, gui_numberinput_t::AUTOLINEAR, false );
498 	INIT_NUM_NEW( "Mountain height", mountain_height_start, 0, min(1000,100*(11-mountain_roughness_start)), 10, false );
499 	INIT_NUM_NEW( "Map roughness", mountain_roughness_start, 0, min(10, 11-((mountain_height_start+99)/100)), gui_numberinput_t::AUTOLINEAR, false );
500 	SEPERATOR
501 	INIT_LB( "Summer snowline" );
502 	summer = new_component<gui_label_buf_t>();
503 
504 	INIT_NUM( "Winter snowline", sets->get_winter_snowline(), sets->get_groundwater(), 24, gui_numberinput_t::AUTOLINEAR, false );
505 	SEPERATOR
506 	// other climate borders ...
507 	sint16 arctic = 0;
508 	for(  int i=desert_climate;  i!=arctic_climate;  i++  ) {
509 		INIT_NUM( ground_desc_t::get_climate_name_from_bit((climate)i), sets->get_climate_borders()[i], sets->get_groundwater(), 24, gui_numberinput_t::AUTOLINEAR, false );
510 		if(sets->get_climate_borders()[i]>arctic) {
511 			arctic = sets->get_climate_borders()[i];
512 		}
513 	}	cbuffer_t buf;
514 
515 	summer->buf().printf("%s %i", translator::translate( "Summer snowline" ), arctic );
516 	summer->update();
517 	SEPERATOR
518 	INIT_BOOL( "lake", sets->get_lake() );
519 	INIT_NUM_NEW( "Number of rivers", sets->get_river_number(), 0, 1024, gui_numberinput_t::AUTOLINEAR, false );
520 	INIT_NUM_NEW( "minimum length of rivers", sets->get_min_river_length(), 0, max(16,sets->get_max_river_length())-16, gui_numberinput_t::AUTOLINEAR, false );
521 	INIT_NUM_NEW( "maximum length of rivers", sets->get_max_river_length(), sets->get_min_river_length()+16, 8196, gui_numberinput_t::AUTOLINEAR, false );
522 	// add listener to all of them
523 	FOR(slist_tpl<gui_numberinput_t*>, const n, numinp) {
524 		n->add_listener(this);
525 	}
526 	// the following are independent and thus need no listener
527 	SEPERATOR
528 	INIT_BOOL( "no tree", sets->get_no_trees() );
529 	INIT_NUM_NEW( "forest_base_size", sets->get_forest_base_size(), 10, 255, 1, false );
530 	INIT_NUM_NEW( "forest_map_size_divisor", sets->get_forest_map_size_divisor(), 2, 255, 1, false );
531 	INIT_NUM_NEW( "forest_count_divisor", sets->get_forest_count_divisor(), 2, 255, 1, false );
532 	INIT_NUM_NEW( "forest_inverse_spare_tree_density", sets->get_forest_inverse_spare_tree_density(), 33, 10000, 10, false );
533 	INIT_NUM( "max_no_of_trees_on_square", sets->get_max_no_of_trees_on_square(), 1, 5, 1, true );
534 	INIT_NUM_NEW( "tree_climates", sets->get_tree_climates(), 0, 255, 1, false );
535 	INIT_NUM_NEW( "no_tree_climates", sets->get_no_tree_climates(), 0, 255, 1, false );
536 
537 	INIT_END
538 }
539 
540 
read(settings_t * const sets)541 void settings_climates_stats_t::read(settings_t* const sets)
542 {
543 	READ_INIT
544 	READ_NUM_VALUE_NEW( env_t::pak_height_conversion_factor );
545 	READ_NUM_VALUE_NEW( sets->groundwater );
546 	READ_NUM_VALUE_NEW( sets->max_mountain_height );
547 	double n = 0;
548 	READ_NUM_VALUE_NEW( n );
549 	if(  new_world  ) {
550 		sets->map_roughness = (n+8.0)/20.0;
551 	}
552 	READ_NUM_VALUE( sets->winter_snowline );
553 	// other climate borders ...
554 	sint16 arctic = 0;
555 	for(  int i=desert_climate;  i!=arctic_climate;  i++  ) {
556 		sint16 ch;
557 		READ_NUM_VALUE( ch );
558 		sets->climate_borders[i] = ch;
559 		if(  ch>arctic  ) {
560 			arctic = ch;
561 		}
562 	}
563 	summer->buf().printf("%s %i", translator::translate( "Summer snowline" ), arctic );
564 	summer->update();
565 	READ_BOOL_VALUE( sets->lake );
566 	READ_NUM_VALUE_NEW( sets->river_number );
567 	READ_NUM_VALUE_NEW( sets->min_river_length );
568 	READ_NUM_VALUE_NEW( sets->max_river_length );
569 	READ_BOOL_VALUE( sets->no_trees );
570 	READ_NUM_VALUE_NEW( sets->forest_base_size );
571 	READ_NUM_VALUE_NEW( sets->forest_map_size_divisor );
572 	READ_NUM_VALUE_NEW( sets->forest_count_divisor );
573 	READ_NUM_VALUE_NEW( sets->forest_inverse_spare_tree_density );
574 	READ_NUM_VALUE( sets->max_no_of_trees_on_square );
575 	READ_NUM_VALUE_NEW( sets->tree_climates );
576 	READ_NUM_VALUE_NEW( sets->no_tree_climates );
577 }
578 
579 
action_triggered(gui_action_creator_t * comp,value_t)580 bool settings_climates_stats_t::action_triggered(gui_action_creator_t *comp, value_t)
581 {
582 	welt_gui_t *welt_gui = dynamic_cast<welt_gui_t *>(win_get_magic( magic_welt_gui_t ));
583 	read( local_sets );
584 	uint i = 0;
585 	FORX(slist_tpl<gui_numberinput_t*>, const n, numinp, ++i) {
586 		if (n == comp && i < 3 && welt_gui) {
587 			// update world preview
588 			welt_gui->update_preview();
589 		}
590 	}
591 	return true;
592 }
593