3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "constants.h"
26 #include "util/string.h"
28 void set_default_settings(Settings *settings)
31 settings->setDefault("language", "");
32 settings->setDefault("name", "");
33 settings->setDefault("bind_address", "");
34 settings->setDefault("serverlist_url", "servers.minetest.net");
37 settings->setDefault("address", "");
38 settings->setDefault("enable_sound", "true");
39 settings->setDefault("sound_volume", "0.8");
40 settings->setDefault("enable_mesh_cache", "false");
41 settings->setDefault("mesh_generation_interval", "0");
42 settings->setDefault("meshgen_block_cache_size", "20");
43 settings->setDefault("enable_vbo", "true");
44 settings->setDefault("free_move", "false");
45 settings->setDefault("fast_move", "false");
46 settings->setDefault("noclip", "false");
47 settings->setDefault("screenshot_path", ".");
48 settings->setDefault("screenshot_format", "png");
49 settings->setDefault("screenshot_quality", "0");
50 settings->setDefault("client_unload_unused_data_timeout", "600");
51 settings->setDefault("client_mapblock_limit", "5000");
52 settings->setDefault("enable_build_where_you_stand", "false" );
53 settings->setDefault("send_pre_v25_init", "false");
54 settings->setDefault("curl_timeout", "5000");
55 settings->setDefault("curl_parallel_limit", "8");
56 settings->setDefault("curl_file_download_timeout", "300000");
57 settings->setDefault("curl_verify_cert", "true");
58 settings->setDefault("enable_remote_media_server", "true");
59 settings->setDefault("enable_client_modding", "false");
62 settings->setDefault("remote_port", "30000");
63 settings->setDefault("keymap_forward", "KEY_KEY_W");
64 settings->setDefault("keymap_autorun", "");
65 settings->setDefault("keymap_backward", "KEY_KEY_S");
66 settings->setDefault("keymap_left", "KEY_KEY_A");
67 settings->setDefault("keymap_right", "KEY_KEY_D");
68 settings->setDefault("keymap_jump", "KEY_SPACE");
69 settings->setDefault("keymap_sneak", "KEY_LSHIFT");
70 settings->setDefault("keymap_drop", "KEY_KEY_Q");
71 settings->setDefault("keymap_zoom", "KEY_KEY_Z");
72 settings->setDefault("keymap_inventory", "KEY_KEY_I");
73 settings->setDefault("keymap_special1", "KEY_KEY_E");
74 settings->setDefault("keymap_chat", "KEY_KEY_T");
75 settings->setDefault("keymap_cmd", "/");
76 settings->setDefault("keymap_cmd_local", ".");
77 settings->setDefault("keymap_minimap", "KEY_F9");
78 settings->setDefault("keymap_console", "KEY_F10");
79 settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
80 settings->setDefault("keymap_freemove", "KEY_KEY_K");
81 settings->setDefault("keymap_fastmove", "KEY_KEY_J");
82 settings->setDefault("keymap_noclip", "KEY_KEY_H");
83 settings->setDefault("keymap_cinematic", "");
84 settings->setDefault("keymap_toggle_hud", "KEY_F1");
85 settings->setDefault("keymap_toggle_chat", "KEY_F2");
86 settings->setDefault("keymap_toggle_force_fog_off", "KEY_F3");
88 settings->setDefault("keymap_toggle_update_camera", "KEY_F4");
90 settings->setDefault("keymap_toggle_update_camera", "");
92 settings->setDefault("keymap_toggle_debug", "KEY_F5");
93 settings->setDefault("keymap_toggle_profiler", "KEY_F6");
94 settings->setDefault("keymap_camera_mode", "KEY_F7");
95 settings->setDefault("keymap_screenshot", "KEY_F12");
96 settings->setDefault("keymap_increase_viewing_range_min", "+");
97 settings->setDefault("keymap_decrease_viewing_range_min", "-");
98 // Some (temporary) keys for debugging
99 settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P");
100 settings->setDefault("keymap_quicktune_prev", "KEY_HOME");
101 settings->setDefault("keymap_quicktune_next", "KEY_END");
102 settings->setDefault("keymap_quicktune_dec", "KEY_NEXT");
103 settings->setDefault("keymap_quicktune_inc", "KEY_PRIOR");
107 settings->setDefault("show_debug", "false");
109 settings->setDefault("show_debug", "true");
111 settings->setDefault("fsaa", "0");
112 settings->setDefault("undersampling", "0");
113 settings->setDefault("enable_fog", "true");
114 settings->setDefault("fog_start", "0.4");
115 settings->setDefault("3d_mode", "none");
116 settings->setDefault("3d_paralax_strength", "0.025");
117 settings->setDefault("tooltip_show_delay", "400");
118 settings->setDefault("zoom_fov", "15");
119 settings->setDefault("fps_max", "60");
120 settings->setDefault("pause_fps_max", "20");
121 settings->setDefault("viewing_range", "100");
122 settings->setDefault("screenW", "800");
123 settings->setDefault("screenH", "600");
124 settings->setDefault("fullscreen", "false");
125 settings->setDefault("fullscreen_bpp", "24");
126 settings->setDefault("vsync", "false");
127 settings->setDefault("fov", "72");
128 settings->setDefault("leaves_style", "fancy");
129 settings->setDefault("connected_glass", "false");
130 settings->setDefault("smooth_lighting", "true");
131 settings->setDefault("display_gamma", "2.2");
132 settings->setDefault("texture_path", "");
133 settings->setDefault("shader_path", "");
134 settings->setDefault("video_driver", "opengl");
135 settings->setDefault("cinematic", "false");
136 settings->setDefault("camera_smoothing", "0");
137 settings->setDefault("cinematic_camera_smoothing", "0.7");
138 settings->setDefault("enable_clouds", "true");
139 settings->setDefault("view_bobbing_amount", "1.0");
140 settings->setDefault("fall_bobbing_amount", "0.0");
141 settings->setDefault("enable_3d_clouds", "true");
142 settings->setDefault("cloud_height", "120");
143 settings->setDefault("cloud_radius", "12");
144 settings->setDefault("menu_clouds", "true");
145 settings->setDefault("opaque_water", "false");
146 settings->setDefault("console_height", "1.0");
147 settings->setDefault("console_color", "(0,0,0)");
148 settings->setDefault("console_alpha", "200");
149 settings->setDefault("selectionbox_color", "(0,0,0)");
150 settings->setDefault("selectionbox_width", "2");
151 settings->setDefault("node_highlighting", "box");
152 settings->setDefault("crosshair_color", "(255,255,255)");
153 settings->setDefault("crosshair_alpha", "255");
154 settings->setDefault("hud_scaling", "1.0");
155 settings->setDefault("gui_scaling", "1.0");
156 settings->setDefault("gui_scaling_filter", "false");
157 settings->setDefault("gui_scaling_filter_txr2img", "true");
158 settings->setDefault("desynchronize_mapblock_texture_animation", "true");
159 settings->setDefault("hud_hotbar_max_width", "1.0");
160 settings->setDefault("enable_local_map_saving", "false");
161 settings->setDefault("show_entity_selectionbox", "true");
162 settings->setDefault("texture_clean_transparent", "false");
163 settings->setDefault("texture_min_size", "64");
164 settings->setDefault("ambient_occlusion_gamma", "2.2");
165 settings->setDefault("enable_shaders", "true");
166 settings->setDefault("enable_particles", "true");
168 settings->setDefault("enable_minimap", "true");
169 settings->setDefault("minimap_shape_round", "true");
170 settings->setDefault("minimap_double_scan_height", "true");
173 settings->setDefault("directional_colored_fog", "true");
174 settings->setDefault("view_bobbing", "true");
175 settings->setDefault("inventory_items_animations", "false");
176 settings->setDefault("mip_map", "false");
177 settings->setDefault("anisotropic_filter", "false");
178 settings->setDefault("bilinear_filter", "false");
179 settings->setDefault("trilinear_filter", "false");
180 settings->setDefault("tone_mapping", "false");
181 settings->setDefault("enable_bumpmapping", "false");
182 settings->setDefault("enable_parallax_occlusion", "false");
183 settings->setDefault("generate_normalmaps", "false");
184 settings->setDefault("normalmaps_strength", "0.6");
185 settings->setDefault("normalmaps_smooth", "1");
186 settings->setDefault("parallax_occlusion_mode", "1");
187 settings->setDefault("parallax_occlusion_iterations", "4");
188 settings->setDefault("parallax_occlusion_scale", "0.08");
189 settings->setDefault("parallax_occlusion_bias", "0.04");
190 settings->setDefault("enable_waving_water", "false");
191 settings->setDefault("water_wave_height", "1.0");
192 settings->setDefault("water_wave_length", "20.0");
193 settings->setDefault("water_wave_speed", "5.0");
194 settings->setDefault("enable_waving_leaves", "false");
195 settings->setDefault("enable_waving_plants", "false");
199 settings->setDefault("invert_mouse", "false");
200 settings->setDefault("mouse_sensitivity", "0.2");
201 settings->setDefault("repeat_rightclick_time", "0.25");
202 settings->setDefault("random_input", "false");
203 settings->setDefault("aux1_descends", "false");
204 settings->setDefault("doubletap_jump", "false");
205 settings->setDefault("always_fly_fast", "true");
206 settings->setDefault("continuous_forward", "false");
207 settings->setDefault("enable_joysticks", "false");
208 settings->setDefault("joystick_id", "0");
209 settings->setDefault("joystick_type", "");
210 settings->setDefault("repeat_joystick_button_time", "0.17");
211 settings->setDefault("joystick_frustum_sensitivity", "170");
214 settings->setDefault("main_menu_path", "");
215 settings->setDefault("main_menu_mod_mgr", "1");
216 settings->setDefault("main_menu_game_mgr", "0");
217 settings->setDefault("modstore_download_url", "https://forum.minetest.net/media/");
218 settings->setDefault("modstore_listmods_url", "https://forum.minetest.net/mmdb/mods/");
219 settings->setDefault("modstore_details_url", "https://forum.minetest.net/mmdb/mod/*/");
220 settings->setDefault("serverlist_file", "favoriteservers.txt");
223 settings->setDefault("freetype", "true");
224 settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "Arimo-Regular.ttf"));
225 settings->setDefault("font_shadow", "1");
226 settings->setDefault("font_shadow_alpha", "127");
227 settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "Cousine-Regular.ttf"));
228 settings->setDefault("fallback_font_path", porting::getDataPath("fonts" DIR_DELIM "DroidSansFallbackFull.ttf"));
230 settings->setDefault("fallback_font_shadow", "1");
231 settings->setDefault("fallback_font_shadow_alpha", "128");
233 std::string font_size_str = std::to_string(TTF_DEFAULT_FONT_SIZE);
235 settings->setDefault("fallback_font_size", font_size_str);
237 settings->setDefault("freetype", "false");
238 settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "mono_dejavu_sans"));
239 settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "mono_dejavu_sans"));
241 std::string font_size_str = std::to_string(DEFAULT_FONT_SIZE);
243 settings->setDefault("font_size", font_size_str);
244 settings->setDefault("mono_font_size", font_size_str);
248 settings->setDefault("disable_escape_sequences", "false");
251 settings->setDefault("enable_ipv6", "true");
252 settings->setDefault("ipv6_server", "false");
253 settings->setDefault("workaround_window_size","5");
254 settings->setDefault("max_packets_per_iteration","1024");
255 settings->setDefault("port", "30000");
256 settings->setDefault("strict_protocol_version_checking", "false");
257 settings->setDefault("player_transfer_distance", "0");
258 settings->setDefault("max_simultaneous_block_sends_per_client", "10");
259 settings->setDefault("max_simultaneous_block_sends_server_total", "40");
260 settings->setDefault("time_send_interval", "5");
262 settings->setDefault("default_game", "minetest");
263 settings->setDefault("motd", "");
264 settings->setDefault("max_users", "15");
265 settings->setDefault("creative_mode", "false");
266 settings->setDefault("show_statusline_on_connect", "true");
267 settings->setDefault("enable_damage", "true");
268 settings->setDefault("default_password", "");
269 settings->setDefault("default_privs", "interact, shout");
270 settings->setDefault("enable_pvp", "true");
271 settings->setDefault("disallow_empty_password", "false");
272 settings->setDefault("disable_anticheat", "false");
273 settings->setDefault("enable_rollback_recording", "false");
275 settings->setDefault("deprecated_lua_api_handling", "legacy");
277 settings->setDefault("deprecated_lua_api_handling", "log");
280 settings->setDefault("kick_msg_shutdown", "Server shutting down.");
281 settings->setDefault("kick_msg_crash", "This server has experienced an internal error. You will now be disconnected.");
282 settings->setDefault("ask_reconnect_on_crash", "false");
284 settings->setDefault("profiler_print_interval", "0");
285 settings->setDefault("active_object_send_range_blocks", "3");
286 settings->setDefault("active_block_range", "3");
287 //settings->setDefault("max_simultaneous_block_sends_per_client", "1");
288 // This causes frametime jitter on client side, or does it?
289 settings->setDefault("max_block_send_distance", "9");
290 settings->setDefault("block_send_optimize_distance", "4");
291 settings->setDefault("server_side_occlusion_culling", "true");
292 settings->setDefault("max_clearobjects_extra_loaded_blocks", "4096");
293 settings->setDefault("time_speed", "72");
294 settings->setDefault("server_unload_unused_data_timeout", "29");
295 settings->setDefault("max_objects_per_block", "64");
296 settings->setDefault("server_map_save_interval", "5.3");
297 settings->setDefault("chat_message_max_size", "500");
298 settings->setDefault("chat_message_limit_per_10sec", "8.0");
299 settings->setDefault("chat_message_limit_trigger_kick", "50");
300 settings->setDefault("sqlite_synchronous", "2");
301 settings->setDefault("full_block_send_enable_min_time_from_building", "2.0");
302 settings->setDefault("dedicated_server_step", "0.1");
303 settings->setDefault("active_block_mgmt_interval", "2.0");
304 settings->setDefault("abm_interval", "1.0");
305 settings->setDefault("nodetimer_interval", "0.2");
306 settings->setDefault("ignore_world_load_errors", "false");
307 settings->setDefault("remote_media", "");
308 settings->setDefault("debug_log_level", "action");
309 settings->setDefault("emergequeue_limit_total", "256");
310 settings->setDefault("emergequeue_limit_diskonly", "32");
311 settings->setDefault("emergequeue_limit_generate", "32");
312 settings->setDefault("num_emerge_threads", "1");
313 settings->setDefault("secure.enable_security", "true");
314 settings->setDefault("secure.trusted_mods", "");
315 settings->setDefault("secure.http_mods", "");
318 settings->setDefault("movement_acceleration_default", "3");
319 settings->setDefault("movement_acceleration_air", "2");
320 settings->setDefault("movement_acceleration_fast", "10");
321 settings->setDefault("movement_speed_walk", "4");
322 settings->setDefault("movement_speed_crouch", "1.35");
323 settings->setDefault("movement_speed_fast", "20");
324 settings->setDefault("movement_speed_climb", "3");
325 settings->setDefault("movement_speed_jump", "6.5");
326 settings->setDefault("movement_liquid_fluidity", "1");
327 settings->setDefault("movement_liquid_fluidity_smooth", "0.5");
328 settings->setDefault("movement_liquid_sink", "10");
329 settings->setDefault("movement_gravity", "9.81");
332 settings->setDefault("liquid_loop_max", "100000");
333 settings->setDefault("liquid_queue_purge_time", "0");
334 settings->setDefault("liquid_update", "1.0");
337 settings->setDefault("mg_name", "v7");
338 settings->setDefault("water_level", "1");
339 settings->setDefault("mapgen_limit", "31000");
340 settings->setDefault("chunksize", "5");
341 settings->setDefault("mg_flags", "dungeons");
342 settings->setDefault("fixed_map_seed", "");
343 settings->setDefault("max_block_generate_distance", "7");
344 settings->setDefault("enable_mapgen_debug_info", "false");
346 // Server list announcing
347 settings->setDefault("server_announce", "false");
348 settings->setDefault("server_url", "");
349 settings->setDefault("server_address", "");
350 settings->setDefault("server_name", "");
351 settings->setDefault("server_description", "");
353 settings->setDefault("high_precision_fpu", "true");
354 settings->setDefault("enable_console", "false");
357 settings->setDefault("screenW", "0");
358 settings->setDefault("screenH", "0");
359 settings->setDefault("enable_shaders", "false");
360 settings->setDefault("fullscreen", "true");
361 settings->setDefault("video_driver", "ogles1");
362 settings->setDefault("touchtarget", "true");
363 settings->setDefault("TMPFolder","/sdcard/" PROJECT_NAME_C "/tmp/");
364 settings->setDefault("touchscreen_threshold","20");
365 settings->setDefault("smooth_lighting", "false");
366 settings->setDefault("max_simultaneous_block_sends_per_client", "3");
367 settings->setDefault("emergequeue_limit_diskonly", "8");
368 settings->setDefault("emergequeue_limit_generate", "8");
369 settings->setDefault("max_block_generate_distance", "3");
370 settings->setDefault("enable_3d_clouds", "false");
371 settings->setDefault("fps_max", "30");
372 settings->setDefault("pause_fps_max", "10");
373 settings->setDefault("max_objects_per_block", "20");
374 settings->setDefault("sqlite_synchronous", "1");
375 settings->setDefault("gui_scaling", "1.1");
376 settings->setDefault("server_map_save_interval", "15");
377 settings->setDefault("client_mapblock_limit", "500");
378 settings->setDefault("active_block_range", "1");
379 settings->setDefault("chunksize", "3");
381 settings->setDefault("viewing_range", "25");
382 settings->setDefault("inventory_image_hack", "false");
384 // Check for a device with a small screen
385 float x_inches = ((double) porting::getDisplaySize().X /
386 (160 * porting::getDisplayDensity()));
387 if (x_inches < 3.5) {
388 settings->setDefault("hud_scaling", "0.6");
389 } else if (x_inches < 4.5) {
390 settings->setDefault("hud_scaling", "0.7");
392 settings->setDefault("curl_verify_cert","false");
394 settings->setDefault("screen_dpi", "72");
398 void override_default_settings(Settings *settings, Settings *from)
400 std::vector<std::string> names = from->getNames();
401 for (size_t i = 0; i < names.size(); i++) {
402 const std::string &name = names[i];
403 settings->setDefault(name, from->get(name));