From 2f59a0c840e9101c87e2d59fabf34116b3328121 Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Sat, 10 Dec 2016 10:31:17 -0800 Subject: Process ABMs in a spherical volume instead of cubic Increase active_block_range default to a 3 mapblock radius. --- minetest.conf.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 867d98584..b1d6c86bd 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -913,7 +913,7 @@ # How large area of blocks are subject to the active block stuff, stated in mapblocks (16 nodes). # In active blocks objects are loaded and ABMs run. # type: int -# active_block_range = 2 +# active_block_range = 3 # From how far blocks are sent to clients, stated in mapblocks (16 nodes). # type: int -- cgit v1.2.3 From 094a5a73d3b9817d07c52754749f0828c4005b8c Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 8 Dec 2016 17:37:13 -0800 Subject: Redo light.cpp. Remake the light_decode_table. The table starts out without pre-filled in values since those are always discarded by the code apparently. We calculate a pseudo curve with gamma power function, and then apply a new adjustment table. The adjustment table is setup to make the default gamma of 2.2 look decent: not too dark at light level 3 or so, but too dark at 1 and below to be playable. The curve is much smoother than before and looks reasonable at the whole range, offering a pleasant decay of light levels away from lights. The `display_gamma` setting now actually does something logical: the game is darker at values below 2.2, and brighter at values above 2.2. At 3.0, the game is very bright, but still has a good light scale. At 1.1 or so, the bottom 5 light levels are virtually black, but you can still see enough detail at light levels 7-8, so the range and spread is adequate. I must add that my monitor is somewhat dark to begin with, since I have a `hc` screen that doesn't dynamic range colors or try to pull up `black` pixels for me (it is tuned for accurate color and light levels), so this should look even better on more dynamic display tunings. --- builtin/settingtypes.txt | 4 +- minetest.conf.example | 2 +- src/defaultsettings.cpp | 2 +- src/light.cpp | 351 ++++------------------------------------------- 4 files changed, 28 insertions(+), 331 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 3a740f3ca..8668e1472 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -442,9 +442,9 @@ fov (Field of view) int 72 30 160 # This requires the "zoom" privilege on the server. zoom_fov (Field of view for zoom) int 15 15 160 -# Adjust the gamma encoding for the light tables. Lower numbers are brighter. +# Adjust the gamma encoding for the light tables. Higher numbers are brighter. # This setting is for the client only and is ignored by the server. -display_gamma (Gamma) float 1.8 1.0 3.0 +display_gamma (Gamma) float 2.2 1.0 3.0 # Path to texture directory. All textures are first searched from here. texture_path (Texture path) path diff --git a/minetest.conf.example b/minetest.conf.example index b1d6c86bd..262f95115 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -508,7 +508,7 @@ # Adjust the gamma encoding for the light tables. Lower numbers are brighter. # This setting is for the client only and is ignored by the server. # type: float min: 1 max: 3 -# display_gamma = 1.8 +# display_gamma = 2.2 # Path to texture directory. All textures are first searched from here. # type: path diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 5bcd7da3d..52f4cfec8 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -112,7 +112,7 @@ void set_default_settings(Settings *settings) settings->setDefault("leaves_style", "fancy"); settings->setDefault("connected_glass", "false"); settings->setDefault("smooth_lighting", "true"); - settings->setDefault("display_gamma", "1.8"); + settings->setDefault("display_gamma", "2.2"); settings->setDefault("texture_path", ""); settings->setDefault("shader_path", ""); settings->setDefault("video_driver", "opengl"); diff --git a/src/light.cpp b/src/light.cpp index 5dc01fcf0..4a3ca5a60 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -26,29 +26,9 @@ with this program; if not, write to the Free Software Foundation, Inc., // Length of LIGHT_MAX+1 means LIGHT_MAX is the last value. // LIGHT_SUN is read as LIGHT_MAX from here. -u8 light_LUT[LIGHT_MAX+1] = -{ - /* Middle-raised variation of a_n+1 = a_n * 0.786 - * Length of LIGHT_MAX+1 means LIGHT_MAX is the last value. - * LIGHT_SUN is read as LIGHT_MAX from here. - */ - 8, - 11+2, - 14+7, - 18+10, - 22+15, - 29+20, - 37+20, - 47+15, - 60+10, - 76+7, - 97+5, - 123+2, - 157, - 200, - 255, -}; +u8 light_LUT[LIGHT_MAX+1]; +// the const ref to light_LUT is what is actually used in the code. const u8 *light_decode_table = light_LUT; /** Initialize or update the light value tables using the specified \p gamma. @@ -65,26 +45,26 @@ void set_light_table(float gamma) { static const float brightness_step = 255.0f / (LIGHT_MAX + 1); - /* These are adjustment values that are added to the calculated light value - * after gamma is applied. Currently they are used so that given a gamma - * of 1.8 the light values set by this function are the same as those - * hardcoded in the initalizer list for the declaration of light_LUT. - */ + // this table is pure arbitrary values, made so that + // at gamma 2.2 the game looks not too dark at light=1, + // and mostly linear for the rest of the scale. + // we could try to inverse the gamma power function, but this + // is simpler and quicker. static const int adjustments[LIGHT_MAX + 1] = { - 7, - 7, - 7, - 5, - 2, - 0, - -7, - -20, - -31, - -39, - -43, - -45, - -40, - -25, + -67, + -91, + -125, + -115, + -104, + -85, + -70, + -63, + -56, + -49, + -42, + -35, + -28, + -22, 0 }; @@ -93,296 +73,13 @@ void set_light_table(float gamma) float brightness = brightness_step; for (size_t i = 0; i < LIGHT_MAX; i++) { - light_LUT[i] = (u8)(255 * powf(brightness / 255.0f, gamma)); + light_LUT[i] = (u8)(255 * powf(brightness / 255.0f, 1.0 / gamma)); light_LUT[i] = rangelim(light_LUT[i] + adjustments[i], 0, 255); - if (i > 1 && light_LUT[i] < light_LUT[i-1]) - light_LUT[i] = light_LUT[i-1] + 1; + if (i > 1 && light_LUT[i] < light_LUT[i - 1]) + light_LUT[i] = light_LUT[i - 1] + 1; brightness += brightness_step; } light_LUT[LIGHT_MAX] = 255; } #endif - - -#if 0 -/* -Made using this and: -- adding 220 as the second last one -- replacing the third last one (212) with 195 - -#!/usr/bin/python - -from math import * -from sys import stdout - -# We want 0 at light=0 and 255 at light=LIGHT_MAX -LIGHT_MAX = 14 -#FACTOR = 0.69 -#FACTOR = 0.75 -FACTOR = 0.83 -START_FROM_ZERO = False - -L = [] -if START_FROM_ZERO: - for i in range(1,LIGHT_MAX+1): - L.append(int(round(255.0 * FACTOR ** (i-1)))) - L.append(0) -else: - for i in range(1,LIGHT_MAX+1): - L.append(int(round(255.0 * FACTOR ** (i-1)))) - L.append(255) - -L.reverse() -for i in L: - stdout.write(str(i)+",\n") -*/ -u8 light_decode_table[LIGHT_MAX+1] = -{ -23, -27, -33, -40, -48, -57, -69, -83, -100, -121, -146, -176, -195, -220, -255, -}; -#endif - -#if 0 -// This is good -// a_n+1 = a_n * 0.786 -// Length of LIGHT_MAX+1 means LIGHT_MAX is the last value. -// LIGHT_SUN is read as LIGHT_MAX from here. -u8 light_decode_table[LIGHT_MAX+1] = -{ -8, -11, -14, -18, -22, -29, -37, -47, -60, -76, -97, -123, -157, -200, -255, -}; -#endif - -#if 0 -// Use for debugging in dark -u8 light_decode_table[LIGHT_MAX+1] = -{ -58, -64, -72, -80, -88, -98, -109, -121, -135, -150, -167, -185, -206, -229, -255, -}; -#endif - -// This is reasonable with classic lighting with a light source -/*u8 light_decode_table[LIGHT_MAX+1] = -{ -2, -3, -4, -6, -9, -13, -18, -25, -32, -35, -45, -57, -69, -79, -255 -};*/ - - -// As in minecraft, a_n+1 = a_n * 0.8 -// NOTE: This doesn't really work that well because this defines -// LIGHT_MAX as dimmer than LIGHT_SUN -// NOTE: Uh, this has had 34 left out; forget this. -/*u8 light_decode_table[LIGHT_MAX+1] = -{ -8, -11, -14, -17, -21, -27, -42, -53, -66, -83, -104, -130, -163, -204, -255, -};*/ - -// This was a quick try of more light, manually quickly made -/*u8 light_decode_table[LIGHT_MAX+1] = -{ -0, -7, -11, -15, -21, -29, -42, -53, -69, -85, -109, -135, -167, -205, -255, -};*/ - -// This was used for a long time, manually made -/*u8 light_decode_table[LIGHT_MAX+1] = -{ -0, -6, -8, -11, -14, -19, -26, -34, -45, -61, -81, -108, -143, -191, -255, -};*/ - -/*u8 light_decode_table[LIGHT_MAX+1] = -{ -0, -3, -6, -10, -18, -25, -35, -50, -75, -95, -120, -150, -185, -215, -255, -};*/ -/*u8 light_decode_table[LIGHT_MAX+1] = -{ -0, -5, -12, -22, -35, -50, -65, -85, -100, -120, -140, -160, -185, -215, -255, -};*/ -// LIGHT_MAX is 14, 0-14 is 15 values -/*u8 light_decode_table[LIGHT_MAX+1] = -{ -0, -9, -12, -14, -16, -20, -26, -34, -45, -61, -81, -108, -143, -191, -255, -};*/ - -#if 0 -/* -#!/usr/bin/python - -from math import * -from sys import stdout - -# We want 0 at light=0 and 255 at light=LIGHT_MAX -LIGHT_MAX = 14 -#FACTOR = 0.69 -FACTOR = 0.75 - -L = [] -for i in range(1,LIGHT_MAX+1): - L.append(int(round(255.0 * FACTOR ** (i-1)))) -L.append(0) - -L.reverse() -for i in L: - stdout.write(str(i)+",\n") -*/ -u8 light_decode_table[LIGHT_MAX+1] = -{ -0, -6, -8, -11, -14, -19, -26, -34, -45, -61, -81, -108, -143, -191, -255, -}; -#endif - - -- cgit v1.2.3 From 6718a95103b2a6c308da121a1340dfdcad2e069d Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Mon, 2 Jan 2017 22:42:50 +0100 Subject: Fix display gamma documentation Overlooked in #4873 --- minetest.conf.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minetest.conf.example') diff --git a/minetest.conf.example b/minetest.conf.example index 262f95115..bf70f5e51 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -505,7 +505,7 @@ # type: int min: 15 max: 160 # zoom_fov = 15 -# Adjust the gamma encoding for the light tables. Lower numbers are brighter. +# Adjust the gamma encoding for the light tables. Higher numbers are brighter. # This setting is for the client only and is ignored by the server. # type: float min: 1 max: 3 # display_gamma = 2.2 -- cgit v1.2.3 From 7ae7f1ea4cbbda7d7849a1240ce30d867e850bfb Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sun, 9 Oct 2016 14:36:22 -0400 Subject: Enable mod security by default --- builtin/settingtypes.txt | 2 +- minetest.conf.example | 2 +- src/defaultsettings.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 8668e1472..779224be4 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -1186,7 +1186,7 @@ mgvalleys_np_inter_valley_slope (Valley Slope) noise_params 0.5, 0.5, (128, 128, [*Security] # Prevent mods from doing insecure things like running shell commands. -secure.enable_security (Enable mod security) bool false +secure.enable_security (Enable mod security) bool true # Comma-separated list of trusted mods that are allowed to access insecure # functions even when mod security is on (via request_insecure_environment()). diff --git a/minetest.conf.example b/minetest.conf.example index bf70f5e51..13b2dc7a7 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1530,7 +1530,7 @@ # Prevent mods from doing insecure things like running shell commands. # type: bool -# secure.enable_security = false +# secure.enable_security = true # Comma-separated list of trusted mods that are allowed to access insecure # functions even when mod security is on (via request_insecure_environment()). diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 52f4cfec8..1096b8904 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -303,7 +303,7 @@ void set_default_settings(Settings *settings) settings->setDefault("emergequeue_limit_diskonly", "32"); settings->setDefault("emergequeue_limit_generate", "32"); settings->setDefault("num_emerge_threads", "1"); - settings->setDefault("secure.enable_security", "false"); + settings->setDefault("secure.enable_security", "true"); settings->setDefault("secure.trusted_mods", ""); settings->setDefault("secure.http_mods", ""); -- cgit v1.2.3 From e12019cfd9ff4e9afa1d7dd326a0094b15fb9b2b Mon Sep 17 00:00:00 2001 From: paramat Date: Sun, 15 Jan 2017 01:21:36 +0000 Subject: Documentation: Correct biome heat / humidity noise parameters When the new set of biomes was added in MTGame the 'spread' for heat and humidity noise parameters was increased to 1000, i forgot to update settingtypes.txt and minetest.conf. --- builtin/settingtypes.txt | 4 ++-- minetest.conf.example | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 779224be4..2dfe86e04 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -910,9 +910,9 @@ emergequeue_limit_generate (Limit of emerge queues to generate) int 32 num_emerge_threads (Number of emerge threads) int 1 # Noise parameters for biome API temperature, humidity and biome blend. -mg_biome_np_heat (Mapgen biome heat noise parameters) noise_params 50, 50, (750, 750, 750), 5349, 3, 0.5, 2.0 +mg_biome_np_heat (Mapgen biome heat noise parameters) noise_params 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 mg_biome_np_heat_blend (Mapgen heat blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 -mg_biome_np_humidity (Mapgen biome humidity noise parameters) noise_params 50, 50, (750, 750, 750), 842, 3, 0.5, 2.0 +mg_biome_np_humidity (Mapgen biome humidity noise parameters) noise_params 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 [***Mapgen v5] diff --git a/minetest.conf.example b/minetest.conf.example index 13b2dc7a7..3b686aa61 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1131,13 +1131,13 @@ # Noise parameters for biome API temperature, humidity and biome blend. # type: noise_params -# mg_biome_np_heat = 50, 50, (750, 750, 750), 5349, 3, 0.5, 2.0 +# mg_biome_np_heat = 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 # type: noise_params # mg_biome_np_heat_blend = 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 # type: noise_params -# mg_biome_np_humidity = 50, 50, (750, 750, 750), 842, 3, 0.5, 2.0 +# mg_biome_np_humidity = 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 # type: noise_params # mg_biome_np_humidity_blend = 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 -- cgit v1.2.3 From 6d5a40713347424084af8ba04e76278961506881 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sat, 21 Jan 2017 19:30:42 +0100 Subject: Add show_statusline_on_connect setting (#5084) Add show_statusline_on_connect setting --- builtin/settingtypes.txt | 3 +++ minetest.conf.example | 6 +++++- src/defaultsettings.cpp | 1 + src/server.cpp | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 2dfe86e04..0f416bc9a 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -703,6 +703,9 @@ map-dir (Map directory) path # Setting it to -1 disables the feature. item_entity_ttl (Item entity TTL) int 900 +# If enabled, show the server status message on player connection. +show_statusline_on_connect (Status message on connection) bool true + # Enable players getting damage and dying. enable_damage (Damage) bool false diff --git a/minetest.conf.example b/minetest.conf.example index 3b686aa61..515b6cfd4 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -841,6 +841,10 @@ # type: int # item_entity_ttl = 900 +# If enabled, show the server status message on player connection. +# type: bool +# show_statusline_on_connect = true + # Enable players getting damage and dying. # type: bool # enable_damage = false @@ -1558,7 +1562,7 @@ # profiler.default_report_format = txt # The file path relative to your worldpath in which profiles will be saved to. -# +# # type: string # profiler.report_path = "" diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 59cfdd50d..e154a63c8 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -255,6 +255,7 @@ void set_default_settings(Settings *settings) settings->setDefault("motd", ""); settings->setDefault("max_users", "15"); settings->setDefault("creative_mode", "false"); + settings->setDefault("show_statusline_on_connect", "true"); settings->setDefault("enable_damage", "true"); settings->setDefault("give_initial_stuff", "false"); settings->setDefault("default_password", ""); diff --git a/src/server.cpp b/src/server.cpp index 1656b9f5a..7e1ab30ac 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1118,7 +1118,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id) SendDeathscreen(peer_id, false, v3f(0,0,0)); // Note things in chat if not in simple singleplayer mode - if(!m_simple_singleplayer_mode) { + if (!m_simple_singleplayer_mode && g_settings->getBool("show_statusline_on_connect")) { // Send information about server to player in chat SendChatMessage(peer_id, getStatusString()); } -- cgit v1.2.3 From 59fdf57134f62be8b8b4801c5f0fc4a2fca25f43 Mon Sep 17 00:00:00 2001 From: paramat Date: Sun, 22 Jan 2017 04:21:29 +0000 Subject: Zoom FOV: Reduce minimum zoom FOV to 7 degrees The default of 15 is unchanged. 7 degrees is x10 magnification which is common for binoculars. Alter hardcoded limits in camera.cpp: Minimum 7 degrees. Maximum 160 degrees to match upper limits in advanced settings. --- builtin/settingtypes.txt | 2 +- minetest.conf.example | 2 +- src/camera.cpp | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 0f416bc9a..581eef315 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -440,7 +440,7 @@ fov (Field of view) int 72 30 160 # Field of view while zooming in degrees. # This requires the "zoom" privilege on the server. -zoom_fov (Field of view for zoom) int 15 15 160 +zoom_fov (Field of view for zoom) int 15 7 160 # Adjust the gamma encoding for the light tables. Higher numbers are brighter. # This setting is for the client only and is ignored by the server. diff --git a/minetest.conf.example b/minetest.conf.example index 515b6cfd4..642b028c7 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -502,7 +502,7 @@ # Field of view while zooming in degrees. # This requires the "zoom" privilege on the server. -# type: int min: 15 max: 160 +# type: int min: 7 max: 160 # zoom_fov = 15 # Adjust the gamma encoding for the light tables. Higher numbers are brighter. diff --git a/src/camera.cpp b/src/camera.cpp index 2ad835817..a7679e43a 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -393,8 +393,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, } else { fov_degrees = m_cache_fov; } - fov_degrees = MYMAX(fov_degrees, 10.0); - fov_degrees = MYMIN(fov_degrees, 170.0); + fov_degrees = rangelim(fov_degrees, 7.0, 160.0); // FOV and aspect ratio m_aspect = (f32) porting::getWindowSize().X / (f32) porting::getWindowSize().Y; -- cgit v1.2.3 From 0c9189d10989f85cd5148107b643dc17a49c06ff Mon Sep 17 00:00:00 2001 From: Ezhh Date: Sun, 29 Jan 2017 16:10:17 +0000 Subject: Add console height setting (#5136) --- builtin/settingtypes.txt | 3 +++ minetest.conf.example | 4 ++++ src/defaultsettings.cpp | 1 + src/game.cpp | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 581eef315..c81dde7de 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -477,6 +477,9 @@ fall_bobbing_amount (Fall bobbing) float 0.0 # - pageflip: quadbuffer based 3d. 3d_mode (3D mode) enum none none,anaglyph,interlaced,topbottom,sidebyside,pageflip +# In-game chat console height, between 0.1 (10%) and 1.0 (100%). +console_height (Console height) float 1.0 0.1 1.0 + # In-game chat console background color (R,G,B). console_color (Console color) string (0,0,0) diff --git a/minetest.conf.example b/minetest.conf.example index 642b028c7..5c7533e93 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -548,6 +548,10 @@ # type: enum values: none, anaglyph, interlaced, topbottom, sidebyside, pageflip # 3d_mode = none +# In-game chat console height, between 0.1 (10%) and 1.0 (100%). +# type: float +# console_height = 1.0 + # In-game chat console background color (R,G,B). # type: string # console_color = (0,0,0) diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index e154a63c8..84046f61c 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -138,6 +138,7 @@ void set_default_settings(Settings *settings) settings->setDefault("cloud_radius", "12"); settings->setDefault("menu_clouds", "true"); settings->setDefault("opaque_water", "false"); + settings->setDefault("console_height", "1.0"); settings->setDefault("console_color", "(0,0,0)"); settings->setDefault("console_alpha", "200"); settings->setDefault("selectionbox_color", "(0,0,0)"); diff --git a/src/game.cpp b/src/game.cpp index 4b4597a7a..1cb054cab 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2627,7 +2627,8 @@ void Game::processKeyInput(VolatileRunFlags *flags, } else if (wasKeyDown(KeyType::CMD)) { openConsole(0.2, L"/"); } else if (wasKeyDown(KeyType::CONSOLE)) { - openConsole(1); + openConsole(core::clamp( + g_settings->getFloat("console_height"), 0.1f, 1.0f)); } else if (wasKeyDown(KeyType::FREEMOVE)) { toggleFreeMove(statustext_time); } else if (wasKeyDown(KeyType::JUMP)) { -- cgit v1.2.3 From 5707b739f38cc5cf651de5b69d91d4f46511dac0 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 8 Feb 2017 23:00:37 -0800 Subject: Change default nodetimer_interval to 0.2s. (#5193) We want to reduce the chance that we get lots and lots of node timers all happening once a second, because we're better off doing small bits of work as they are available. Reducing this to 0.2 seconds will greatly reduce the total amount of nodetimers that elapse at the same instance, while not effecting total work load. This results in a far better chance of the server keeping up with work loads. --- builtin/settingtypes.txt | 2 +- minetest.conf.example | 2 +- src/defaultsettings.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index c81dde7de..0e8783f83 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -840,7 +840,7 @@ active_block_mgmt_interval (Active Block Management interval) float 2.0 abm_interval (Active Block Modifier interval) float 1.0 # Length of time between NodeTimer execution cycles -nodetimer_interval (NodeTimer interval) float 1.0 +nodetimer_interval (NodeTimer interval) float 0.2 # If enabled, invalid world data won't cause the server to shut down. # Only enable this if you know what you are doing. diff --git a/minetest.conf.example b/minetest.conf.example index 5c7533e93..a90cc7d8e 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1027,7 +1027,7 @@ # Length of time between NodeTimer execution cycles # type: float -# nodetimer_interval = 1.0 +# nodetimer_interval = 0.2 # If enabled, invalid world data won't cause the server to shut down. # Only enable this if you know what you are doing. diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 84046f61c..bdf1f92ca 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -295,7 +295,7 @@ void set_default_settings(Settings *settings) settings->setDefault("dedicated_server_step", "0.1"); settings->setDefault("active_block_mgmt_interval", "2.0"); settings->setDefault("abm_interval", "1.0"); - settings->setDefault("nodetimer_interval", "1.0"); + settings->setDefault("nodetimer_interval", "0.2"); settings->setDefault("ignore_world_load_errors", "false"); settings->setDefault("remote_media", ""); settings->setDefault("debug_log_level", "action"); -- cgit v1.2.3 From d34f149bdc4f72db904d948413fa6b3f649dca7b Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 6 Mar 2017 08:35:13 +0000 Subject: Climb speed: Increase default setting from 2 to 3 --- builtin/settingtypes.txt | 2 +- minetest.conf.example | 2 +- src/defaultsettings.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 0e8783f83..4e800e25b 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -799,7 +799,7 @@ movement_acceleration_fast (Fast mode acceleration) float 10 movement_speed_walk (Walking speed) float 4 movement_speed_crouch (Crouch speed) float 1.35 movement_speed_fast (Fast mode speed) float 20 -movement_speed_climb (Climbing speed) float 2 +movement_speed_climb (Climbing speed) float 3 movement_speed_jump (Jumping speed) float 6.5 movement_speed_descend (Descending speed) float 6 movement_liquid_fluidity (Liquid fluidity) float 1 diff --git a/minetest.conf.example b/minetest.conf.example index a90cc7d8e..d53a00fd9 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -965,7 +965,7 @@ # movement_speed_fast = 20 # type: float -# movement_speed_climb = 2 +# movement_speed_climb = 3 # type: float # movement_speed_jump = 6.5 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index b333ff087..e9ee1135f 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -314,7 +314,7 @@ void set_default_settings(Settings *settings) settings->setDefault("movement_speed_walk", "4"); settings->setDefault("movement_speed_crouch", "1.35"); settings->setDefault("movement_speed_fast", "20"); - settings->setDefault("movement_speed_climb", "2"); + settings->setDefault("movement_speed_climb", "3"); settings->setDefault("movement_speed_jump", "6.5"); settings->setDefault("movement_liquid_fluidity", "1"); settings->setDefault("movement_liquid_fluidity_smooth", "0.5"); -- cgit v1.2.3 From ba4b704ebf24952ab9a84c914b8ad6c45dabfaba Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Mon, 27 Feb 2017 23:06:15 -0800 Subject: Allow server side occlusion culling. --- builtin/settingtypes.txt | 6 +++++ minetest.conf.example | 6 +++++ src/clientiface.cpp | 8 ++++++ src/clientmap.cpp | 67 +----------------------------------------------- src/defaultsettings.cpp | 1 + src/map.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++ src/map.h | 4 +++ 7 files changed, 92 insertions(+), 66 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4e800e25b..ffd872c20 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -864,6 +864,12 @@ liquid_update (Liquid update tick) float 1.0 # Stated in mapblocks (16 nodes) block_send_optimize_distance (block send optimize distance) int 4 2 +# If enabled the server will perform map block occlusion culling based on +# on the eye position of the player. This can reduce the number of blocks +# sent to the client 50-80%. The client will not longer receive most invisible +# so that the utility of noclip mode is reduced. +server_side_occlusion_culling (Server side occlusion culling) bool false + [*Mapgen] # Name of map generator to be used when creating a new world. diff --git a/minetest.conf.example b/minetest.conf.example index d53a00fd9..08d00d62a 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1056,6 +1056,12 @@ # type: int min: 2 # block_send_optimize_distance = 4 +# If enabled the server will perform map block occlusion culling based on +# on the eye position of the player. This can reduce the number of blocks +# sent to the client 50-80%. The client will not longer receive most invisible +# so that the utility of noclip mode is reduced. +server_side_occlusion_culling = false + ## Mapgen # Name of map generator to be used when creating a new world. diff --git a/src/clientiface.cpp b/src/clientiface.cpp index 0eb68c9c1..76a34c392 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -197,6 +197,9 @@ void RemoteClient::GetNextBlocks ( s32 nearest_sent_d = -1; //bool queue_is_full = false; + const v3s16 cam_pos_nodes = floatToInt(camera_pos, BS); + const bool occ_cull = g_settings->getBool("server_side_occlusion_culling"); + s16 d; for(d = d_start; d <= d_max; d++) { /* @@ -298,6 +301,11 @@ void RemoteClient::GetNextBlocks ( if(block->getDayNightDiff() == false) continue; } + + if (occ_cull && !block_is_invalid && + env->getMap().isBlockOccluded(block, cam_pos_nodes)) { + continue; + } } /* diff --git a/src/clientmap.cpp b/src/clientmap.cpp index fb70a97e9..4cae03bf2 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -109,35 +109,6 @@ void ClientMap::OnRegisterSceneNode() ISceneNode::OnRegisterSceneNode(); } -static bool isOccluded(Map *map, v3s16 p0, v3s16 p1, float step, float stepfac, - float start_off, float end_off, u32 needed_count, INodeDefManager *nodemgr) -{ - float d0 = (float)BS * p0.getDistanceFrom(p1); - v3s16 u0 = p1 - p0; - v3f uf = v3f(u0.X, u0.Y, u0.Z) * BS; - uf.normalize(); - v3f p0f = v3f(p0.X, p0.Y, p0.Z) * BS; - u32 count = 0; - for(float s=start_off; sgetNodeNoEx(p); - bool is_transparent = false; - const ContentFeatures &f = nodemgr->get(n); - if(f.solidness == 0) - is_transparent = (f.visual_solidness != 2); - else - is_transparent = (f.solidness != 2); - if(!is_transparent){ - count++; - if(count >= needed_count) - return true; - } - step *= stepfac; - } - return false; -} - void ClientMap::getBlocksInViewRange(v3s16 cam_pos_nodes, v3s16 *p_blocks_min, v3s16 *p_blocks_max) { @@ -273,43 +244,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver) /* Occlusion culling */ - v3s16 cpn = block->getPos() * MAP_BLOCKSIZE; - cpn += v3s16(MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2); - float step = BS * 1; - float stepfac = 1.1; - float startoff = BS * 1; - // The occlusion search of 'isOccluded()' must stop short of the target - // point by distance 'endoff' (end offset) to not enter the target mapblock. - // For the 8 mapblock corners 'endoff' must therefore be the maximum diagonal - // of a mapblock, because we must consider all view angles. - // sqrt(1^2 + 1^2 + 1^2) = 1.732 - float endoff = -BS * MAP_BLOCKSIZE * 1.732050807569; - v3s16 spn = cam_pos_nodes; - s16 bs2 = MAP_BLOCKSIZE / 2 + 1; - // to reduce the likelihood of falsely occluded blocks - // require at least two solid blocks - // this is a HACK, we should think of a more precise algorithm - u32 needed_count = 2; - if (occlusion_culling_enabled && - // For the central point of the mapblock 'endoff' can be halved - isOccluded(this, spn, cpn, - step, stepfac, startoff, endoff / 2.0f, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(bs2,bs2,bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(bs2,bs2,-bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(bs2,-bs2,bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(bs2,-bs2,-bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(-bs2,bs2,bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(-bs2,bs2,-bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef) && - isOccluded(this, spn, cpn + v3s16(-bs2,-bs2,-bs2), - step, stepfac, startoff, endoff, needed_count, m_nodedef)) { + if (occlusion_culling_enabled && isBlockOccluded(block, cam_pos_nodes)) { blocks_occlusion_culled++; continue; } diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index e9ee1135f..483c9cff6 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -282,6 +282,7 @@ void set_default_settings(Settings *settings) // This causes frametime jitter on client side, or does it? settings->setDefault("max_block_send_distance", "9"); settings->setDefault("block_send_optimize_distance", "4"); + settings->setDefault("server_side_occlusion_culling", "false"); settings->setDefault("max_clearobjects_extra_loaded_blocks", "4096"); settings->setDefault("time_speed", "72"); settings->setDefault("server_unload_unused_data_timeout", "29"); diff --git a/src/map.cpp b/src/map.cpp index a1502befa..43a49dc2f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1157,6 +1157,72 @@ void Map::removeNodeTimer(v3s16 p) block->m_node_timers.remove(p_rel); } +bool Map::isOccluded(v3s16 p0, v3s16 p1, float step, float stepfac, + float start_off, float end_off, u32 needed_count) +{ + float d0 = (float)BS * p0.getDistanceFrom(p1); + v3s16 u0 = p1 - p0; + v3f uf = v3f(u0.X, u0.Y, u0.Z) * BS; + uf.normalize(); + v3f p0f = v3f(p0.X, p0.Y, p0.Z) * BS; + u32 count = 0; + for(float s=start_off; sget(n); + if(f.drawtype == NDT_NORMAL){ + // not transparent, see ContentFeature::updateTextures + count++; + if(count >= needed_count) + return true; + } + step *= stepfac; + } + return false; +} + +bool Map::isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes) { + v3s16 cpn = block->getPos() * MAP_BLOCKSIZE; + cpn += v3s16(MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2); + float step = BS * 1; + float stepfac = 1.1; + float startoff = BS * 1; + // The occlusion search of 'isOccluded()' must stop short of the target + // point by distance 'endoff' (end offset) to not enter the target mapblock. + // For the 8 mapblock corners 'endoff' must therefore be the maximum diagonal + // of a mapblock, because we must consider all view angles. + // sqrt(1^2 + 1^2 + 1^2) = 1.732 + float endoff = -BS * MAP_BLOCKSIZE * 1.732050807569; + v3s16 spn = cam_pos_nodes; + s16 bs2 = MAP_BLOCKSIZE / 2 + 1; + // to reduce the likelihood of falsely occluded blocks + // require at least two solid blocks + // this is a HACK, we should think of a more precise algorithm + u32 needed_count = 2; + + return ( + // For the central point of the mapblock 'endoff' can be halved + isOccluded(spn, cpn, + step, stepfac, startoff, endoff / 2.0f, needed_count) && + isOccluded(spn, cpn + v3s16(bs2,bs2,bs2), + step, stepfac, startoff, endoff, needed_count) && + isOccluded(spn, cpn + v3s16(bs2,bs2,-bs2), + step, stepfac, startoff, endoff, needed_count) && + isOccluded(spn, cpn + v3s16(bs2,-bs2,bs2), + step, stepfac, startoff, endoff, needed_count) && + isOccluded(spn, cpn + v3s16(bs2,-bs2,-bs2), + step, stepfac, startoff, endoff, needed_count) && + isOccluded(spn, cpn + v3s16(-bs2,bs2,bs2), + step, stepfac, startoff, endoff, needed_count) && + isOccluded(spn, cpn + v3s16(-bs2,bs2,-bs2), + step, stepfac, startoff, endoff, needed_count) && + isOccluded(spn, cpn + v3s16(-bs2,-bs2,bs2), + step, stepfac, startoff, endoff, needed_count) && + isOccluded(spn, cpn + v3s16(-bs2,-bs2,-bs2), + step, stepfac, startoff, endoff, needed_count)); +} + /* ServerMap */ diff --git a/src/map.h b/src/map.h index c4181a49f..aeb05c704 100644 --- a/src/map.h +++ b/src/map.h @@ -314,6 +314,7 @@ public: void transforming_liquid_add(v3s16 p); s32 transforming_liquid_size(); + bool isBlockOccluded(MapBlock *block, v3s16 cam_pos_nodes); protected: friend class LuaVoxelManip; @@ -335,6 +336,9 @@ protected: // This stores the properties of the nodes on the map. INodeDefManager *m_nodedef; + bool isOccluded(v3s16 p0, v3s16 p1, float step, float stepfac, + float start_off, float end_off, u32 needed_count); + private: f32 m_transforming_liquid_loop_count_multiplier; u32 m_unprocessed_count; -- cgit v1.2.3 From ff8069694748707d4435ebd109c99ff20212826f Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Fri, 3 Mar 2017 12:40:50 -0800 Subject: Enable server side occlusion culling by default. --- builtin/settingtypes.txt | 2 +- minetest.conf.example | 2 +- src/defaultsettings.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ffd872c20..cba03e983 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -868,7 +868,7 @@ block_send_optimize_distance (block send optimize distance) int 4 2 # on the eye position of the player. This can reduce the number of blocks # sent to the client 50-80%. The client will not longer receive most invisible # so that the utility of noclip mode is reduced. -server_side_occlusion_culling (Server side occlusion culling) bool false +server_side_occlusion_culling (Server side occlusion culling) bool true [*Mapgen] diff --git a/minetest.conf.example b/minetest.conf.example index 08d00d62a..8caeeb7d2 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1060,7 +1060,7 @@ # on the eye position of the player. This can reduce the number of blocks # sent to the client 50-80%. The client will not longer receive most invisible # so that the utility of noclip mode is reduced. -server_side_occlusion_culling = false +server_side_occlusion_culling = true ## Mapgen diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 483c9cff6..d67a60b07 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -282,7 +282,7 @@ void set_default_settings(Settings *settings) // This causes frametime jitter on client side, or does it? settings->setDefault("max_block_send_distance", "9"); settings->setDefault("block_send_optimize_distance", "4"); - settings->setDefault("server_side_occlusion_culling", "false"); + settings->setDefault("server_side_occlusion_culling", "true"); settings->setDefault("max_clearobjects_extra_loaded_blocks", "4096"); settings->setDefault("time_speed", "72"); settings->setDefault("server_unload_unused_data_timeout", "29"); -- cgit v1.2.3 From 44ca9c9cb2079fa97068adb8ee894c5ae13a9975 Mon Sep 17 00:00:00 2001 From: nerzhul Date: Mon, 13 Mar 2017 15:55:30 +0100 Subject: [CSM] Add enable_client_modding param (default: false) --- builtin/settingtypes.txt | 3 +++ minetest.conf.example | 5 +++++ src/client.cpp | 10 +++++++++- src/client.h | 2 ++ src/clientenvironment.cpp | 4 +++- src/defaultsettings.cpp | 1 + src/game.cpp | 21 +++++++++++++-------- src/network/clientpackethandler.cpp | 6 ++++-- src/script/cpp_api/s_client.cpp | 3 +-- 9 files changed, 41 insertions(+), 14 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index cba03e983..ff17973fa 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -264,6 +264,9 @@ show_entity_selectionbox (Show entity selection boxes) bool true # when connecting to the server. enable_remote_media_server (Connect to external media server) bool true +# Enable Lua modding support on client. +enable_client_modding (Client modding) bool false + # URL to the server list displayed in the Multiplayer Tab. serverlist_url (Serverlist URL) string servers.minetest.net diff --git a/minetest.conf.example b/minetest.conf.example index 8caeeb7d2..283dc13f1 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -282,6 +282,11 @@ # type: bool # enable_remote_media_server = true +# Enable Lua modding support on client. +# This support is experimental and API can change. +# type: bool +enable_client_modding (Client modding) bool false + # URL to the server list displayed in the Multiplayer Tab. # type: string # serverlist_url = servers.minetest.net diff --git a/src/client.cpp b/src/client.cpp index 049616c63..4ddabd814 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -248,7 +248,8 @@ Client::Client( m_recommended_send_interval(0.1), m_removed_sounds_check_timer(0), m_state(LC_Created), - m_localdb(NULL) + m_localdb(NULL), + m_script(NULL) { // Add local player m_env.setLocalPlayer(new LocalPlayer(this, playername)); @@ -262,6 +263,7 @@ Client::Client( g_settings->getBool("enable_bumpmapping") || g_settings->getBool("enable_parallax_occlusion")); + m_modding_enabled = g_settings->getBool("enable_client_modding"); m_script = new ClientScripting(this); m_env.setScript(m_script); } @@ -270,6 +272,11 @@ void Client::initMods() { m_script->loadMod(getBuiltinLuaPath() + DIR_DELIM "init.lua", BUILTIN_MOD_NAME); + // If modding is not enabled, don't load mods, just builtin + if (!m_modding_enabled) { + return; + } + ClientModConfiguration modconf(getClientModsLuaPath()); std::vector mods = modconf.getMods(); std::vector unsatisfied_mods = modconf.getUnsatisfiedMods(); @@ -327,6 +334,7 @@ const ModSpec* Client::getModSpec(const std::string &modname) const void Client::Stop() { + // Don't disable this part when modding is disabled, it's used in builtin m_script->on_shutdown(); //request all client managed threads to stop m_mesh_update_thread.stop(); diff --git a/src/client.h b/src/client.h index dc4469350..7f9cc559b 100644 --- a/src/client.h +++ b/src/client.h @@ -572,6 +572,7 @@ public: } ClientScripting *getScript() { return m_script; } + const bool moddingEnabled() const { return m_modding_enabled; } inline void pushToEventQueue(const ClientEvent &event) { @@ -722,6 +723,7 @@ private: bool m_cache_use_tangent_vertices; ClientScripting *m_script; + bool m_modding_enabled; DISABLE_CLASS_COPY(Client); }; diff --git a/src/clientenvironment.cpp b/src/clientenvironment.cpp index 1175d00c0..7a74c897c 100644 --- a/src/clientenvironment.cpp +++ b/src/clientenvironment.cpp @@ -245,7 +245,9 @@ void ClientEnvironment::step(float dtime) } } - m_script->environment_step(dtime); + if (m_client->moddingEnabled()) { + m_script->environment_step(dtime); + } /* A quick draft of lava damage diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index d67a60b07..fbf15b2ea 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -54,6 +54,7 @@ void set_default_settings(Settings *settings) settings->setDefault("curl_file_download_timeout", "300000"); settings->setDefault("curl_verify_cert", "true"); settings->setDefault("enable_remote_media_server", "true"); + settings->setDefault("enable_client_modding", "false"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/game.cpp b/src/game.cpp index 612bd2536..10ec5d594 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -179,6 +179,8 @@ struct LocalFormspecHandler : public TextDest { return; } } + + // Don't disable this part when modding is disabled, it's used in builtin m_client->getScript()->on_formspec_input(m_formname, fields); } @@ -3185,9 +3187,10 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash) for ( ; event.type != CE_NONE; event = client->getClientEvent()) { - if (event.type == CE_PLAYER_DAMAGE && - client->getHP() != 0) { - client->getScript()->on_damage_taken(event.player_damage.amount); + if (event.type == CE_PLAYER_DAMAGE && client->getHP() != 0) { + if (client->moddingEnabled()) { + client->getScript()->on_damage_taken(event.player_damage.amount); + } *damage_flash += 95.0 + 3.2 * event.player_damage.amount; *damage_flash = MYMIN(*damage_flash, 127.0); @@ -3202,6 +3205,7 @@ void Game::processClientEvents(CameraOrientation *cam, float *damage_flash) cam->camera_yaw = event.player_force_move.yaw; cam->camera_pitch = event.player_force_move.pitch; } else if (event.type == CE_DEATHSCREEN) { + // This should be enabled for death formspec in builtin client->getScript()->on_death(); /* Handle visualization */ @@ -3902,7 +3906,7 @@ void Game::handleDigging(GameRunData *runData, if (!runData->digging) { infostream << "Started digging" << std::endl; - if (client->getScript()->on_punchnode(nodepos, n)) + if (client->moddingEnabled() && client->getScript()->on_punchnode(nodepos, n)) return; client->interact(0, pointed); runData->digging = true; @@ -3971,7 +3975,7 @@ void Game::handleDigging(GameRunData *runData, } else { infostream << "Digging completed" << std::endl; client->setCrack(-1, v3s16(0, 0, 0)); - + runData->dig_time = 0; runData->digging = false; @@ -3993,9 +3997,10 @@ void Game::handleDigging(GameRunData *runData, bool is_valid_position; MapNode wasnode = map.getNodeNoEx(nodepos, &is_valid_position); if (is_valid_position) { - bool block = client->getScript()->on_dignode(nodepos, wasnode); - if (block) { - return; + if (client->moddingEnabled()) { + if (client->getScript()->on_dignode(nodepos, wasnode)) { + return; + } } client->removeNode(nodepos); } diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 97fa93e95..9bcc58110 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -413,7 +413,7 @@ void Client::handleCommand_ChatMessage(NetworkPacket* pkt) } // If chat message not consummed by client lua API - if (!m_script->on_receiving_message(wide_to_utf8(message))) { + if (!moddingEnabled() || !m_script->on_receiving_message(wide_to_utf8(message))) { pushToChatQueue(message); } } @@ -526,7 +526,9 @@ void Client::handleCommand_HP(NetworkPacket* pkt) player->hp = hp; - m_script->on_hp_modification(hp); + if (moddingEnabled()) { + m_script->on_hp_modification(hp); + } if (hp < oldhp) { // Add to ClientEvent queue diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index 8c5e3796b..154dd6194 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -155,8 +155,7 @@ bool ScriptApiClient::on_dignode(v3s16 p, MapNode node) // Call functions runCallbacks(2, RUN_CALLBACKS_MODE_OR); - bool blocked = lua_toboolean(L, -1); - return blocked; + return lua_toboolean(L, -1); } bool ScriptApiClient::on_punchnode(v3s16 p, MapNode node) -- cgit v1.2.3 From 4d5177ff708c7e696eead18200e240047ff520fe Mon Sep 17 00:00:00 2001 From: number Zero Date: Sat, 18 Feb 2017 21:53:05 +0300 Subject: Add mesh generation delay --- builtin/settingtypes.txt | 4 ++++ minetest.conf.example | 5 +++++ src/client.cpp | 9 ++++++++- src/client.h | 3 ++- src/defaultsettings.cpp | 1 + src/settings_translation_file.cpp | 2 ++ 6 files changed, 22 insertions(+), 2 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index ff17973fa..d2bdf030a 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -511,6 +511,10 @@ hud_hotbar_max_width (Maximum hotbar width) float 1.0 # Enables caching of facedir rotated meshes. enable_mesh_cache (Mesh cache) bool false +# Delay between mesh updates on the client in ms. Increasing this will slow +# down the rate of mesh updates, thus reducing jitter on slower clients. +mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50 + # Enables minimap. enable_minimap (Minimap) bool true diff --git a/minetest.conf.example b/minetest.conf.example index 283dc13f1..fd76d98e0 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -594,6 +594,11 @@ enable_client_modding (Client modding) bool false # type: bool # enable_mesh_cache = false +# Delay between mesh updates on the client in ms. Increasing this will slow +# down the rate of mesh updates, thus reducing jitter on slower clients. +# type: int min: 0 max: 50 +# mesh_generation_interval = 0 + # Enables minimap. # type: bool # enable_minimap = true diff --git a/src/client.cpp b/src/client.cpp index 0c4819bc5..8bbaa83bd 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -157,6 +157,12 @@ QueuedMeshUpdate *MeshUpdateQueue::pop() MeshUpdateThread */ +MeshUpdateThread::MeshUpdateThread() : UpdateThread("Mesh") +{ + m_generation_interval = g_settings->getU16("mesh_generation_interval"); + m_generation_interval = rangelim(m_generation_interval, 0, 50); +} + void MeshUpdateThread::enqueueUpdate(v3s16 p, MeshMakeData *data, bool ack_block_to_server, bool urgent) { @@ -168,7 +174,8 @@ void MeshUpdateThread::doUpdate() { QueuedMeshUpdate *q; while ((q = m_queue_in.pop())) { - + if (m_generation_interval) + sleep_ms(m_generation_interval); ScopeProfiler sp(g_profiler, "Client: Mesh making"); MapBlockMesh *mesh_new = new MapBlockMesh(q->data, m_camera_offset); diff --git a/src/client.h b/src/client.h index b1310424d..4a4d296f2 100644 --- a/src/client.h +++ b/src/client.h @@ -120,13 +120,14 @@ class MeshUpdateThread : public UpdateThread { private: MeshUpdateQueue m_queue_in; + int m_generation_interval; protected: virtual void doUpdate(); public: - MeshUpdateThread() : UpdateThread("Mesh") {} + MeshUpdateThread(); void enqueueUpdate(v3s16 p, MeshMakeData *data, bool ack_block_to_server, bool urgent); diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index fbf15b2ea..396b69b3a 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -38,6 +38,7 @@ void set_default_settings(Settings *settings) settings->setDefault("enable_sound", "true"); settings->setDefault("sound_volume", "0.8"); settings->setDefault("enable_mesh_cache", "false"); + settings->setDefault("mesh_generation_interval", "0"); settings->setDefault("enable_vbo", "true"); settings->setDefault("free_move", "false"); settings->setDefault("fast_move", "false"); diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp index 39223d9ce..9ec21c415 100644 --- a/src/settings_translation_file.cpp +++ b/src/settings_translation_file.cpp @@ -245,6 +245,8 @@ fake_function() { gettext("Maximum proportion of current window to be used for hotbar.\nUseful if there's something to be displayed right or left of hotbar."); gettext("Mesh cache"); gettext("Enables caching of facedir rotated meshes."); + gettext("Mapblock mesh generation delay"); + gettext("Delay between mesh updates on the client in ms. Increasing this will slow\ndown the rate of mesh updates, thus reducing jitter on slower clients."); gettext("Minimap"); gettext("Enables minimap."); gettext("Round minimap"); -- cgit v1.2.3 From e70e15134c95d37241bb6f6124105c0f1c08ab8a Mon Sep 17 00:00:00 2001 From: red-001 Date: Fri, 24 Mar 2017 23:43:36 +0000 Subject: Change command prefix to "." and add "help" command. --- builtin/client/chatcommands.lua | 22 +++++++++---- builtin/common/chatcommands.lua | 73 ++++++++++++++++++++++++++++++++++++++++- builtin/game/chatcommands.lua | 55 ------------------------------- builtin/settingtypes.txt | 4 +++ minetest.conf.example | 5 +++ src/client/keys.h | 1 + src/defaultsettings.cpp | 1 + src/game.cpp | 3 ++ src/guiKeyChangeMenu.cpp | 2 ++ 9 files changed, 103 insertions(+), 63 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index 43b4d9a72..7a1b4b6b7 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -2,27 +2,35 @@ core.register_on_sending_chat_messages(function(message) - if not (message:sub(1,1) == "/") then - return false + local first_char = message:sub(1,1) + if first_char == "/" or first_char == "." then + core.display_chat_message("issued command: " .. message) end - core.display_chat_message("issued command: " .. message) + if first_char ~= "." then + return false + end - local cmd, param = string.match(message, "^/([^ ]+) *(.*)") + local cmd, param = string.match(message, "^%.([^ ]+) *(.*)") if not param then param = "" end - local cmd_def = core.registered_chatcommands[cmd] + if not cmd then + core.display_chat_message("-!- Empty command") + return true + end + local cmd_def = core.registered_chatcommands[cmd] if cmd_def then core.set_last_run_mod(cmd_def.mod_origin) local _, message = cmd_def.func(param) if message then core.display_chat_message(message) end - return true + else + core.display_chat_message("-!- Invalid command: " .. cmd) end - return false + return true end) diff --git a/builtin/common/chatcommands.lua b/builtin/common/chatcommands.lua index ef3a24410..05dd94e8d 100644 --- a/builtin/common/chatcommands.lua +++ b/builtin/common/chatcommands.lua @@ -27,4 +27,75 @@ function core.override_chatcommand(name, redefinition) rawset(chatcommand, k, v) end core.registered_chatcommands[name] = chatcommand -end \ No newline at end of file +end + +local cmd_marker = "/" + +if INIT == "client" then + cmd_marker = "." +end + +local function do_help_cmd(name, param) + local function format_help_line(cmd, def) + local msg = core.colorize("#00ffff", cmd_marker .. cmd) + if def.params and def.params ~= "" then + msg = msg .. " " .. def.params + end + if def.description and def.description ~= "" then + msg = msg .. ": " .. def.description + end + return msg + end + if param == "" then + local cmds = {} + for cmd, def in pairs(core.registered_chatcommands) do + if INIT == "client" or core.check_player_privs(name, def.privs) then + cmds[#cmds + 1] = cmd + end + end + table.sort(cmds) + return true, "Available commands: " .. table.concat(cmds, " ") .. "\n" + .. "Use '"..cmd_marker.."help ' to get more information," + .. " or '"..cmd_marker.."help all' to list everything." + elseif param == "all" then + local cmds = {} + for cmd, def in pairs(core.registered_chatcommands) do + if INIT == "client" or core.check_player_privs(name, def.privs) then + cmds[#cmds + 1] = format_help_line(cmd, def) + end + end + table.sort(cmds) + return true, "Available commands:\n"..table.concat(cmds, "\n") + elseif INIT == "game" and param == "privs" then + local privs = {} + for priv, def in pairs(core.registered_privileges) do + privs[#privs + 1] = priv .. ": " .. def.description + end + table.sort(privs) + return true, "Available privileges:\n"..table.concat(privs, "\n") + else + local cmd = param + local def = core.registered_chatcommands[cmd] + if not def then + return false, "Command not available: "..cmd + else + return true, format_help_line(cmd, def) + end + end +end + +if INIT == "client" then + core.register_chatcommand("help", { + params = "[all/]", + description = "Get help for commands", + func = function(param) + return do_help_cmd(nil, param) + end, + }) +else + core.register_chatcommand("help", { + params = "[all/privs/]", + description = "Get help for commands or list privileges", + func = do_help_cmd, + }) +end diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 745b012e6..b4fa4f828 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -82,61 +82,6 @@ core.register_chatcommand("admin", { end, }) -core.register_chatcommand("help", { - privs = {}, - params = "[all/privs/]", - description = "Get help for commands or list privileges", - func = function(name, param) - local function format_help_line(cmd, def) - local msg = core.colorize("#00ffff", "/"..cmd) - if def.params and def.params ~= "" then - msg = msg .. " " .. def.params - end - if def.description and def.description ~= "" then - msg = msg .. ": " .. def.description - end - return msg - end - if param == "" then - local msg = "" - local cmds = {} - for cmd, def in pairs(core.registered_chatcommands) do - if core.check_player_privs(name, def.privs) then - cmds[#cmds + 1] = cmd - end - end - table.sort(cmds) - return true, "Available commands: " .. table.concat(cmds, " ") .. "\n" - .. "Use '/help ' to get more information," - .. " or '/help all' to list everything." - elseif param == "all" then - local cmds = {} - for cmd, def in pairs(core.registered_chatcommands) do - if core.check_player_privs(name, def.privs) then - cmds[#cmds + 1] = format_help_line(cmd, def) - end - end - table.sort(cmds) - return true, "Available commands:\n"..table.concat(cmds, "\n") - elseif param == "privs" then - local privs = {} - for priv, def in pairs(core.registered_privileges) do - privs[#privs + 1] = priv .. ": " .. def.description - end - table.sort(privs) - return true, "Available privileges:\n"..table.concat(privs, "\n") - else - local cmd = param - local def = core.registered_chatcommands[cmd] - if not def then - return false, "Command not available: "..cmd - else - return true, format_help_line(cmd, def) - end - end - end, -}) - core.register_chatcommand("privs", { params = "", description = "Print privileges of player", diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index d2bdf030a..e63697f61 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -156,6 +156,10 @@ keymap_chat (Chat key) key KEY_KEY_T # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_cmd (Command key) key / +# Key for opening the chat window to type local commands. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_cmd_local (Command key) key . + # Key for opening the chat console. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keyman_console (Console key) key KEY_F10 diff --git a/minetest.conf.example b/minetest.conf.example index fd76d98e0..78488432f 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -148,6 +148,11 @@ # type: key # keymap_cmd = / +# Key for opening the chat window to type local commands. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_cmd_local = . + # Key for opening the chat console. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # type: key diff --git a/src/client/keys.h b/src/client/keys.h index 6467c443e..25f3e44d2 100644 --- a/src/client/keys.h +++ b/src/client/keys.h @@ -42,6 +42,7 @@ public: INVENTORY, CHAT, CMD, + CMD_LOCAL, CONSOLE, MINIMAP, FREEMOVE, diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 396b69b3a..5b66c583a 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -72,6 +72,7 @@ void set_default_settings(Settings *settings) settings->setDefault("keymap_special1", "KEY_KEY_E"); settings->setDefault("keymap_chat", "KEY_KEY_T"); settings->setDefault("keymap_cmd", "/"); + settings->setDefault("keymap_cmd_local", "."); settings->setDefault("keymap_minimap", "KEY_F9"); settings->setDefault("keymap_console", "KEY_F10"); settings->setDefault("keymap_rangeselect", "KEY_KEY_R"); diff --git a/src/game.cpp b/src/game.cpp index 9d52e4326..62d2405f2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1034,6 +1034,7 @@ void KeyCache::populate() key[KeyType::INVENTORY] = getKeySetting("keymap_inventory"); key[KeyType::CHAT] = getKeySetting("keymap_chat"); key[KeyType::CMD] = getKeySetting("keymap_cmd"); + key[KeyType::CMD_LOCAL] = getKeySetting("keymap_cmd_local"); key[KeyType::CONSOLE] = getKeySetting("keymap_console"); key[KeyType::MINIMAP] = getKeySetting("keymap_minimap"); key[KeyType::FREEMOVE] = getKeySetting("keymap_freemove"); @@ -2449,6 +2450,8 @@ void Game::processKeyInput() openConsole(0.2, L""); } else if (wasKeyDown(KeyType::CMD)) { openConsole(0.2, L"/"); + } else if (wasKeyDown(KeyType::CMD_LOCAL)) { + openConsole(0.2, L"."); } else if (wasKeyDown(KeyType::CONSOLE)) { openConsole(core::clamp(g_settings->getFloat("console_height"), 0.1f, 1.0f)); } else if (wasKeyDown(KeyType::FREEMOVE)) { diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp index 07137d1bc..e85ee8271 100644 --- a/src/guiKeyChangeMenu.cpp +++ b/src/guiKeyChangeMenu.cpp @@ -53,6 +53,7 @@ enum GUI_ID_KEY_CINEMATIC_BUTTON, GUI_ID_KEY_CHAT_BUTTON, GUI_ID_KEY_CMD_BUTTON, + GUI_ID_KEY_CMD_LOCAL_BUTTON, GUI_ID_KEY_CONSOLE_BUTTON, GUI_ID_KEY_SNEAK_BUTTON, GUI_ID_KEY_DROP_BUTTON, @@ -408,6 +409,7 @@ void GUIKeyChangeMenu::init_keys() this->add_key(GUI_ID_KEY_INVENTORY_BUTTON, wgettext("Inventory"), "keymap_inventory"); this->add_key(GUI_ID_KEY_CHAT_BUTTON, wgettext("Chat"), "keymap_chat"); this->add_key(GUI_ID_KEY_CMD_BUTTON, wgettext("Command"), "keymap_cmd"); + this->add_key(GUI_ID_KEY_CMD_LOCAL_BUTTON, wgettext("Local command"), "keymap_cmd_local"); this->add_key(GUI_ID_KEY_CONSOLE_BUTTON, wgettext("Console"), "keymap_console"); this->add_key(GUI_ID_KEY_FLY_BUTTON, wgettext("Toggle fly"), "keymap_freemove"); this->add_key(GUI_ID_KEY_FAST_BUTTON, wgettext("Toggle fast"), "keymap_fastmove"); -- cgit v1.2.3 From ec0c4d33db9e0b7b3e541757e34c04c08c3b48c9 Mon Sep 17 00:00:00 2001 From: paramat Date: Thu, 23 Mar 2017 00:18:59 +0000 Subject: Map generation limit: Make per-world The setting limits map generation but affects nothing else. Add 'mapgen_limit' to global mapgen parameters. Move 'blockpos_over_mapgen_limit()' to the only place it is called from: map.cpp. Allow teleportation to any part of the world even if over the set mapgen limit. Simplify the reading of this limit in mgvalleys. Remove the 'map_generation_limit' setting. --- builtin/game/chatcommands.lua | 2 +- builtin/settingtypes.txt | 11 ++++------- minetest.conf.example | 11 ++++------- src/defaultsettings.cpp | 2 +- src/map.cpp | 13 +++++++++++++ src/map.h | 1 + src/mapblock.h | 14 +------------- src/mapgen.cpp | 24 ++++++++++++++---------- src/mapgen.h | 3 +++ src/mapgen_valleys.cpp | 9 +++------ src/mapgen_valleys.h | 2 -- 11 files changed, 45 insertions(+), 47 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index b4fa4f828..16f5f3be9 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -303,7 +303,7 @@ core.register_chatcommand("teleport", { p.y = tonumber(p.y) p.z = tonumber(p.z) if p.x and p.y and p.z then - local lm = tonumber(minetest.setting_get("map_generation_limit") or 31000) + local lm = 31000 if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then return false, "Cannot teleport out of map bounds!" end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index e63697f61..c9e0f7b87 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -893,13 +893,10 @@ water_level (Water level) int 1 # From how far blocks are generated for clients, stated in mapblocks (16 nodes). max_block_generate_distance (Max block generate distance) int 6 -# Where the map generator stops. -# Please note: -# - Limited to 31000 (setting above has no effect) -# - The map generator works in groups of 80x80x80 nodes (5x5x5 MapBlocks). -# - Those groups have an offset of -32, -32 nodes from the origin. -# - Only groups which are within the map_generation_limit are generated -map_generation_limit (Map generation limit) int 31000 0 31000 +# Limit of map generation, in nodes, in all 6 directions from (0, 0, 0). +# Only mapchunks completely within the mapgen limit are generated. +# Value is stored per-world. +mapgen_limit (Map generation limit) int 31000 0 31000 # Global map generation attributes. # In Mapgen v6 the 'decorations' flag controls all decorations except trees diff --git a/minetest.conf.example b/minetest.conf.example index 78488432f..a45a9948a 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1092,14 +1092,11 @@ server_side_occlusion_culling = true # type: int # max_block_generate_distance = 6 -# Where the map generator stops. -# Please note: -# - Limited to 31000 (setting above has no effect) -# - The map generator works in groups of 80x80x80 nodes (5x5x5 MapBlocks). -# - Those groups have an offset of -32, -32 nodes from the origin. -# - Only groups which are within the map_generation_limit are generated +# Limit of map generation, in nodes, in all 6 directions from (0, 0, 0). +# Only mapchunks completely within the mapgen limit are generated. +# Value is stored per-world. # type: int min: 0 max: 31000 -# map_generation_limit = 31000 +# mapgen_limit = 31000 # Global map generation attributes. # In Mapgen v6 the 'decorations' flag controls all decorations except trees diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 5b66c583a..4b50b991b 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -333,10 +333,10 @@ void set_default_settings(Settings *settings) // Mapgen settings->setDefault("mg_name", "v7"); settings->setDefault("water_level", "1"); + settings->setDefault("mapgen_limit", "31000"); settings->setDefault("chunksize", "5"); settings->setDefault("mg_flags", "dungeons"); settings->setDefault("fixed_map_seed", ""); - settings->setDefault("map_generation_limit", "31000"); settings->setDefault("max_block_generate_distance", "7"); settings->setDefault("enable_mapgen_debug_info", "false"); diff --git a/src/map.cpp b/src/map.cpp index 504760d09..b690ea3b3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1367,6 +1367,19 @@ s16 ServerMap::getWaterLevel() return getMapgenParams()->water_level; } +bool ServerMap::blockpos_over_mapgen_limit(v3s16 p) +{ + const s16 mapgen_limit_bp = rangelim( + getMapgenParams()->mapgen_limit, 0, MAX_MAP_GENERATION_LIMIT) / + MAP_BLOCKSIZE; + return p.X < -mapgen_limit_bp || + p.X > mapgen_limit_bp || + p.Y < -mapgen_limit_bp || + p.Y > mapgen_limit_bp || + p.Z < -mapgen_limit_bp || + p.Z > mapgen_limit_bp; +} + bool ServerMap::initBlockMake(v3s16 blockpos, BlockMakeData *data) { s16 csize = getMapgenParams()->chunksize; diff --git a/src/map.h b/src/map.h index aeb05c704..ea8dc76d1 100644 --- a/src/map.h +++ b/src/map.h @@ -379,6 +379,7 @@ public: /* Blocks are generated by using these and makeBlock(). */ + bool blockpos_over_mapgen_limit(v3s16 p); bool initBlockMake(v3s16 blockpos, BlockMakeData *data); void finishBlockMake(BlockMakeData *data, std::map *changed_blocks); diff --git a/src/mapblock.h b/src/mapblock.h index be2edc791..c48f337e0 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "modifiedstate.h" #include "util/numeric.h" // getContainerPos #include "settings.h" +#include "mapgen.h" class Map; class NodeMetadataList; @@ -689,19 +690,6 @@ inline bool blockpos_over_max_limit(v3s16 p) p.Z > max_limit_bp; } -inline bool blockpos_over_mapgen_limit(v3s16 p) -{ - const s16 mapgen_limit_bp = rangelim( - g_settings->getS16("map_generation_limit"), 0, MAX_MAP_GENERATION_LIMIT) / - MAP_BLOCKSIZE; - return p.X < -mapgen_limit_bp || - p.X > mapgen_limit_bp || - p.Y < -mapgen_limit_bp || - p.Y > mapgen_limit_bp || - p.Z < -mapgen_limit_bp || - p.Z > mapgen_limit_bp; -} - /* Returns the position of the block where the node is located */ diff --git a/src/mapgen.cpp b/src/mapgen.cpp index a0b9990b7..6f3ea7cb0 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -97,11 +97,12 @@ STATIC_ASSERT( Mapgen::Mapgen() { - generating = false; - id = -1; - seed = 0; - water_level = 0; - flags = 0; + generating = false; + id = -1; + seed = 0; + water_level = 0; + mapgen_limit = 0; + flags = 0; vm = NULL; ndef = NULL; @@ -114,11 +115,12 @@ Mapgen::Mapgen() Mapgen::Mapgen(int mapgenid, MapgenParams *params, EmergeManager *emerge) : gennotify(emerge->gen_notify_on, &emerge->gen_notify_on_deco_ids) { - generating = false; - id = mapgenid; - water_level = params->water_level; - flags = params->flags; - csize = v3s16(1, 1, 1) * (params->chunksize * MAP_BLOCKSIZE); + generating = false; + id = mapgenid; + water_level = params->water_level; + mapgen_limit = params->mapgen_limit; + flags = params->flags; + csize = v3s16(1, 1, 1) * (params->chunksize * MAP_BLOCKSIZE); /* We are losing half our entropy by doing this, but it is necessary to @@ -1005,6 +1007,7 @@ void MapgenParams::readParams(const Settings *settings) this->mgtype = Mapgen::getMapgenType(mg_name); settings->getS16NoEx("water_level", water_level); + settings->getS16NoEx("mapgen_limit", mapgen_limit); settings->getS16NoEx("chunksize", chunksize); settings->getFlagStrNoEx("mg_flags", flags, flagdesc_mapgen); @@ -1022,6 +1025,7 @@ void MapgenParams::writeParams(Settings *settings) const settings->set("mg_name", Mapgen::getMapgenName(mgtype)); settings->setU64("seed", seed); settings->setS16("water_level", water_level); + settings->setS16("mapgen_limit", mapgen_limit); settings->setS16("chunksize", chunksize); settings->setFlagStr("mg_flags", flags, flagdesc_mapgen, U32_MAX); diff --git a/src/mapgen.h b/src/mapgen.h index 7aac1e6a0..c4e1652e8 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -124,6 +124,7 @@ struct MapgenParams { s16 chunksize; u64 seed; s16 water_level; + s16 mapgen_limit; u32 flags; BiomeParams *bparams; @@ -133,6 +134,7 @@ struct MapgenParams { chunksize(5), seed(0), water_level(1), + mapgen_limit(MAX_MAP_GENERATION_LIMIT), flags(MG_CAVES | MG_LIGHT | MG_DECORATIONS), bparams(NULL) { @@ -158,6 +160,7 @@ class Mapgen { public: s32 seed; int water_level; + int mapgen_limit; u32 flags; bool generating; int id; diff --git a/src/mapgen_valleys.cpp b/src/mapgen_valleys.cpp index ccf797eff..76a7a0582 100644 --- a/src/mapgen_valleys.cpp +++ b/src/mapgen_valleys.cpp @@ -70,9 +70,6 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeMa // NOTE: MapgenValleys has a hard dependency on BiomeGenOriginal this->m_bgen = (BiomeGenOriginal *)biomegen; - this->map_gen_limit = MYMIN(MAX_MAP_GENERATION_LIMIT, - g_settings->getU16("map_generation_limit")); - BiomeParamsOriginal *bp = (BiomeParamsOriginal *)params->bparams; this->spflags = params->spflags; @@ -621,7 +618,7 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth) const float massive_cave_threshold = 0.6f; // mct: 1 = small rare caves, 0.5 1/3rd ground volume, 0 = 1/2 ground volume. - float yblmin = -map_gen_limit + massive_cave_blend * 1.5f; + float yblmin = -mapgen_limit + massive_cave_blend * 1.5f; float yblmax = massive_cave_depth - massive_cave_blend * 1.5f; bool made_a_big_one = false; @@ -646,11 +643,11 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth) // lava_depth varies between one and ten as you approach // the bottom of the world. - s16 lava_depth = ceil((lava_max_height - node_min.Y + 1) * 10.f / map_gen_limit); + s16 lava_depth = ceil((lava_max_height - node_min.Y + 1) * 10.f / mapgen_limit); // This allows random lava spawns to be less common at the surface. s16 lava_chance = MYCUBE(lava_features_lim) * lava_depth; // water_depth varies between ten and one on the way down. - s16 water_depth = ceil((map_gen_limit - abs(node_min.Y) + 1) * 10.f / map_gen_limit); + s16 water_depth = ceil((mapgen_limit - abs(node_min.Y) + 1) * 10.f / mapgen_limit); // This allows random water spawns to be more common at the surface. s16 water_chance = MYCUBE(water_features_lim) * water_depth; diff --git a/src/mapgen_valleys.h b/src/mapgen_valleys.h index 6dd7ebc47..4a7a11bcc 100644 --- a/src/mapgen_valleys.h +++ b/src/mapgen_valleys.h @@ -101,8 +101,6 @@ public: private: BiomeGenOriginal *m_bgen; - float map_gen_limit; - bool humid_rivers; bool use_altitude_chill; float humidity_adjust; -- cgit v1.2.3 From 859141a0ce38fbd606d95ae7a2f0999acf2fbe84 Mon Sep 17 00:00:00 2001 From: paramat Date: Sun, 12 Mar 2017 13:26:09 +0000 Subject: Cavegen/Mgv5/Mgv7: Add optional giant caverns Add to MapgenBasic for use by multiple mapgens. Add to mgv5 and mgv7, enabled by default. Similar to mgvalleys caverns but half the scale. Parameters for upper y limit, distance caverns taper to full size, and noise threshold (full cavern size). As with mgvalleys caverns are generated first and classic caves are disabled in any mapchunk containing a cavern, to avoid excessive spreading volumes of liquids. This also avoids floating blobs of liquid where a large classic cave has overgenerated out into a neighbouring previously-generated mapchunk. --- builtin/settingtypes.txt | 23 ++++++++++++ minetest.conf.example | 30 +++++++++++++++ src/cavegen.cpp | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ src/cavegen.h | 30 +++++++++++++++ src/mapgen.cpp | 12 ++++++ src/mapgen.h | 5 +++ src/mapgen_v5.cpp | 86 +++++++++++++++++++++++-------------------- src/mapgen_v5.h | 10 ++++- src/mapgen_v7.cpp | 53 ++++++++++++++++++++++----- src/mapgen_v7.h | 13 +++++-- 10 files changed, 303 insertions(+), 54 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index c9e0f7b87..bbee77749 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -940,12 +940,25 @@ mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_ # Controls width of tunnels, a smaller value creates wider tunnels. mgv5_cave_width (Mapgen v5 cave width) float 0.125 +# Y-level of cavern upper limit. +mgv5_cavern_limit (Mapgen v5 cavern limit) int -256 + +# Y-distance over which caverns expand to full size. +mgv5_cavern_taper (Mapgen v5 cavern taper) int 256 + +# Defines full size of caverns, smaller values create larger caverns. +mgv5_cavern_threshold (Mapgen v5 cavern threshold) float 0.7 + mgv5_np_filler_depth (Mapgen v5 filler depth noise parameters) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 mgv5_np_factor (Mapgen v5 factor noise parameters) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 mgv5_np_height (Mapgen v5 height noise parameters) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0 mgv5_np_cave1 (Mapgen v5 cave1 noise parameters) noise_params 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0 mgv5_np_cave2 (Mapgen v5 cave2 noise parameters) noise_params 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 +mgv5_np_cavern (Mapgen v5 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 # TODO +# Noise parameters in group format, unsupported by advanced settings +# menu but settable in minetest.conf. +# See documentation of noise parameter formats in minetest.conf.example. #mgv5_np_ground = { # offset = 0 # scale = 40 @@ -1007,6 +1020,15 @@ mgv7_floatland_level (Mapgen v7 floatland level) int 1280 # Y-level to which floatland shadows extend. mgv7_shadow_limit (Mapgen v7 shadow limit) int 1024 +# Y-level of cavern upper limit. +mgv7_cavern_limit (Mapgen v7 cavern limit) int -256 + +# Y-distance over which caverns expand to full size. +mgv7_cavern_taper (Mapgen v7 cavern taper) int 256 + +# Defines full size of caverns, smaller values create larger caverns. +mgv7_cavern_threshold (Mapgen v7 cavern threshold) float 0.7 + mgv7_np_terrain_base (Mapgen v7 terrain base noise parameters) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 mgv7_np_terrain_alt (Mapgen v7 terrain altitude noise parameters) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0 mgv7_np_terrain_persist (Mapgen v7 terrain persistation noise parameters) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0 @@ -1018,6 +1040,7 @@ mgv7_np_floatland_base (Mapgen v7 floatland base terrain noise parameters) noise mgv7_np_float_base_height (Mapgen v7 floatland base terrain height noise parameters) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0 mgv7_np_mountain (Mapgen v7 mountain noise parameters) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0 mgv7_np_ridge (Mapgen v7 river channel wall noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 +mgv7_np_cavern (Mapgen v7 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 mgv7_np_cave1 (Mapgen v7 cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 diff --git a/minetest.conf.example b/minetest.conf.example index a45a9948a..5927cdb03 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1174,6 +1174,18 @@ server_side_occlusion_culling = true # type: float # mgv5_cave_width = 0.125 +# Y-level of cavern upper limit. +# type: int +# mgv5_cavern_limit = -256 + +# Y-distance over which caverns expand to full size. +# type: int +# mgv5_cavern_taper = 256 + +# Defines full size of caverns, smaller values create larger caverns. +# type: float +# mgv5_cavern_threshold = 0.7 + # type: noise_params # mgv5_np_filler_depth = 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 @@ -1189,6 +1201,9 @@ server_side_occlusion_culling = true # type: noise_params # mgv5_np_cave2 = 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 +# type: noise_params +# mgv5_np_cavern = 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 + # Noise parameters in group format, unsupported by advanced settings # menu but settable in minetest.conf. # See documentation of noise parameter formats above. @@ -1284,6 +1299,18 @@ server_side_occlusion_culling = true # type: int # mgv7_shadow_limit = 1024 +# Y-level of cavern upper limit. +# type: int +# mgv7_cavern_limit = -256 + +# Y-distance over which caverns expand to full size. +# type: int +# mgv7_cavern_taper = 256 + +# Defines full size of caverns, smaller values create larger caverns. +# type: float +# mgv7_cavern_threshold = 0.7 + # type: noise_params # mgv7_np_terrain_base = 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 @@ -1317,6 +1344,9 @@ server_side_occlusion_culling = true # type: noise_params # mgv7_np_ridge = 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 +# type: noise_params +# mgv7_np_cavern = 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 + # type: noise_params # mgv7_np_cave1 = 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 diff --git a/src/cavegen.cpp b/src/cavegen.cpp index 1005640c1..6275c516e 100644 --- a/src/cavegen.cpp +++ b/src/cavegen.cpp @@ -150,6 +150,101 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm, } +//// +//// CavernsNoise +//// + +CavernsNoise::CavernsNoise( + INodeDefManager *nodedef, v3s16 chunksize, NoiseParams *np_cavern, + s32 seed, float cavern_limit, float cavern_taper, float cavern_threshold) +{ + assert(nodedef); + + m_ndef = nodedef; + + m_csize = chunksize; + m_cavern_limit = cavern_limit; + m_cavern_taper = cavern_taper; + m_cavern_threshold = cavern_threshold; + + m_ystride = m_csize.X; + m_zstride_1d = m_csize.X * (m_csize.Y + 1); + + // Noise is created using 1-down overgeneration + // A Nx-by-1-by-Nz-sized plane is at the bottom of the desired for + // re-carving the solid overtop placed for blocking sunlight + noise_cavern = new Noise(np_cavern, seed, m_csize.X, m_csize.Y + 1, m_csize.Z); + + c_water_source = m_ndef->getId("mapgen_water_source"); + if (c_water_source == CONTENT_IGNORE) + c_water_source = CONTENT_AIR; + + c_lava_source = m_ndef->getId("mapgen_lava_source"); + if (c_lava_source == CONTENT_IGNORE) + c_lava_source = CONTENT_AIR; +} + + +CavernsNoise::~CavernsNoise() +{ + delete noise_cavern; +} + + +bool CavernsNoise::generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax) +{ + assert(vm); + + // Calculate noise + noise_cavern->perlinMap3D(nmin.X, nmin.Y - 1, nmin.Z); + + // Cache cavern_amp values + float cavern_amp[m_csize.Y + 1]; + u8 cavern_amp_index = 0; // Index zero at column top + for (s16 y = nmax.Y; y >= nmin.Y - 1; y--, cavern_amp_index++) { + cavern_amp[cavern_amp_index] = + MYMIN((m_cavern_limit - y) / (float)m_cavern_taper, 1.0f); + } + + //// Place nodes + bool has_cavern = false; + v3s16 em = vm->m_area.getExtent(); + u32 index2d = 0; + + for (s16 z = nmin.Z; z <= nmax.Z; z++) + for (s16 x = nmin.X; x <= nmax.X; x++, index2d++) { + // Reset cave_amp index to column top + cavern_amp_index = 0; + // Initial voxelmanip index at column top + u32 vi = vm->m_area.index(x, nmax.Y, z); + // Initial 3D noise index at column top + u32 index3d = (z - nmin.Z) * m_zstride_1d + m_csize.Y * m_ystride + + (x - nmin.X); + // Don't excavate the overgenerated stone at node_max.Y + 1, + // this creates a 'roof' over the cavern, preventing light in + // caverns at mapchunk borders when generating mapchunks upwards. + // This 'roof' is excavated when the mapchunk above is generated. + for (s16 y = nmax.Y; y >= nmin.Y - 1; y--, + index3d -= m_ystride, + vm->m_area.add_y(em, vi, -1), + cavern_amp_index++) { + content_t c = vm->m_data[vi].getContent(); + float nabs_cavern = fabs(noise_cavern->result[index3d]); + // Caverns generate first but still remove lava and water in case + // of overgenerated classic caves. + if (nabs_cavern * cavern_amp[cavern_amp_index] > m_cavern_threshold && + (m_ndef->get(c).is_ground_content || + c == c_lava_source || c == c_water_source)) { + vm->m_data[vi] = MapNode(CONTENT_AIR); + has_cavern = true; + } + } + } + + return has_cavern; +} + + //// //// CavesRandomWalk //// diff --git a/src/cavegen.h b/src/cavegen.h index 2bf503d47..e322c181c 100644 --- a/src/cavegen.h +++ b/src/cavegen.h @@ -62,6 +62,36 @@ private: Noise *noise_cave2; }; +/* + CavernsNoise is a cave digging algorithm +*/ +class CavernsNoise { +public: + CavernsNoise(INodeDefManager *nodedef, v3s16 chunksize, NoiseParams *np_cavern, + s32 seed, float cavern_limit, float cavern_taper, float cavern_threshold); + ~CavernsNoise(); + + bool generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax); + +private: + INodeDefManager *m_ndef; + + // configurable parameters + v3s16 m_csize; + float m_cavern_limit; + float m_cavern_taper; + float m_cavern_threshold; + + // intermediate state variables + u16 m_ystride; + u16 m_zstride_1d; + + Noise *noise_cavern; + + content_t c_water_source; + content_t c_lava_source; +}; + /* CavesRandomWalk is an implementation of a cave-digging algorithm that operates on the principle of a "random walk" to approximate the stochiastic diff --git a/src/mapgen.cpp b/src/mapgen.cpp index b6e8c0fd1..c63c426fa 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -840,6 +840,18 @@ void MapgenBasic::generateCaves(s16 max_stone_y, s16 large_cave_depth) } +bool MapgenBasic::generateCaverns(s16 max_stone_y) +{ + if (node_min.Y > max_stone_y || node_min.Y > cavern_limit) + return false; + + CavernsNoise caverns_noise(ndef, csize, &np_cavern, + seed, cavern_limit, cavern_taper, cavern_threshold); + + return caverns_noise.generateCaverns(vm, node_min, node_max); +} + + void MapgenBasic::generateDungeons(s16 max_stone_y, MgStoneType stone_type) { if (max_stone_y < node_min.Y) diff --git a/src/mapgen.h b/src/mapgen.h index c4e1652e8..f738b1bce 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -243,6 +243,7 @@ public: virtual ~MapgenBasic(); virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth); + virtual bool generateCaverns(s16 max_stone_y); virtual void generateDungeons(s16 max_stone_y, MgStoneType stone_type); virtual MgStoneType generateBiomes(); virtual void dustTopNodes(); @@ -282,7 +283,11 @@ protected: NoiseParams np_cave1; NoiseParams np_cave2; + NoiseParams np_cavern; float cave_width; + float cavern_limit; + float cavern_taper; + float cavern_threshold; }; #endif diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp index 9f189e253..b983026e6 100644 --- a/src/mapgen_v5.cpp +++ b/src/mapgen_v5.cpp @@ -41,15 +41,19 @@ with this program; if not, write to the Free Software Foundation, Inc., FlagDesc flagdesc_mapgen_v5[] = { - {NULL, 0} + {"caverns", MGV5_CAVERNS}, + {NULL, 0} }; MapgenV5::MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge) : MapgenBasic(mapgenid, params, emerge) { - this->spflags = params->spflags; - this->cave_width = params->cave_width; + this->spflags = params->spflags; + this->cave_width = params->cave_width; + this->cavern_limit = params->cavern_limit; + this->cavern_taper = params->cavern_taper; + this->cavern_threshold = params->cavern_threshold; // Terrain noise noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z); @@ -59,9 +63,10 @@ MapgenV5::MapgenV5(int mapgenid, MapgenV5Params *params, EmergeManager *emerge) // 3D terrain noise // 1-up 1-down overgeneration noise_ground = new Noise(¶ms->np_ground, seed, csize.X, csize.Y + 2, csize.Z); - - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; + // 1 down overgeneration + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cavern = params->np_cavern; } @@ -76,47 +81,55 @@ MapgenV5::~MapgenV5() MapgenV5Params::MapgenV5Params() { - spflags = 0; - cave_width = 0.125; + spflags = MGV5_CAVERNS; + cave_width = 0.125; + cavern_limit = -256; + cavern_taper = 256; + cavern_threshold = 0.7; np_filler_depth = NoiseParams(0, 1, v3f(150, 150, 150), 261, 4, 0.7, 2.0); np_factor = NoiseParams(0, 1, v3f(250, 250, 250), 920381, 3, 0.45, 2.0); np_height = NoiseParams(0, 10, v3f(250, 250, 250), 84174, 4, 0.5, 2.0); + np_ground = NoiseParams(0, 40, v3f(80, 80, 80), 983240, 4, 0.55, 2.0, NOISE_FLAG_EASED); np_cave1 = NoiseParams(0, 12, v3f(50, 50, 50), 52534, 4, 0.5, 2.0); np_cave2 = NoiseParams(0, 12, v3f(50, 50, 50), 10325, 4, 0.5, 2.0); - np_ground = NoiseParams(0, 40, v3f(80, 80, 80), 983240, 4, 0.55, 2.0, NOISE_FLAG_EASED); + np_cavern = NoiseParams(0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0); } -//#define CAVE_NOISE_SCALE 12.0 -//#define CAVE_NOISE_THRESHOLD (1.5/CAVE_NOISE_SCALE) = 0.125 - - void MapgenV5Params::readParams(const Settings *settings) { - settings->getFlagStrNoEx("mgv5_spflags", spflags, flagdesc_mapgen_v5); - settings->getFloatNoEx("mgv5_cave_width", cave_width); + settings->getFlagStrNoEx("mgv5_spflags", spflags, flagdesc_mapgen_v5); + settings->getFloatNoEx("mgv5_cave_width", cave_width); + settings->getS16NoEx("mgv5_cavern_limit", cavern_limit); + settings->getS16NoEx("mgv5_cavern_taper", cavern_taper); + settings->getFloatNoEx("mgv5_cavern_threshold", cavern_threshold); settings->getNoiseParams("mgv5_np_filler_depth", np_filler_depth); settings->getNoiseParams("mgv5_np_factor", np_factor); settings->getNoiseParams("mgv5_np_height", np_height); + settings->getNoiseParams("mgv5_np_ground", np_ground); settings->getNoiseParams("mgv5_np_cave1", np_cave1); settings->getNoiseParams("mgv5_np_cave2", np_cave2); - settings->getNoiseParams("mgv5_np_ground", np_ground); + settings->getNoiseParams("mgv5_np_cavern", np_cavern); } void MapgenV5Params::writeParams(Settings *settings) const { - settings->setFlagStr("mgv5_spflags", spflags, flagdesc_mapgen_v5, U32_MAX); - settings->setFloat("mgv5_cave_width", cave_width); + settings->setFlagStr("mgv5_spflags", spflags, flagdesc_mapgen_v5, U32_MAX); + settings->setFloat("mgv5_cave_width", cave_width); + settings->setS16("mgv5_cavern_limit", cavern_limit); + settings->setS16("mgv5_cavern_taper", cavern_taper); + settings->setFloat("mgv5_cavern_threshold", cavern_threshold); settings->setNoiseParams("mgv5_np_filler_depth", np_filler_depth); settings->setNoiseParams("mgv5_np_factor", np_factor); settings->setNoiseParams("mgv5_np_height", np_height); + settings->setNoiseParams("mgv5_np_ground", np_ground); settings->setNoiseParams("mgv5_np_cave1", np_cave1); settings->setNoiseParams("mgv5_np_cave2", np_cave2); - settings->setNoiseParams("mgv5_np_ground", np_ground); + settings->setNoiseParams("mgv5_np_cavern", np_cavern); } @@ -190,9 +203,21 @@ void MapgenV5::makeChunk(BlockMakeData *data) biomegen->calcBiomeNoise(node_min); MgStoneType stone_type = generateBiomes(); - // Generate caves - if ((flags & MG_CAVES) && (stone_surface_max_y >= node_min.Y)) - generateCaves(stone_surface_max_y, MGV5_LARGE_CAVE_DEPTH); + // Generate caverns, tunnels and classic caves + if (flags & MG_CAVES) { + bool has_cavern = false; + // Generate caverns + if (spflags & MGV5_CAVERNS) + has_cavern = generateCaverns(stone_surface_max_y); + // Generate tunnels and classic caves + if (has_cavern) + // Disable classic caves in this mapchunk by setting + // 'large cave depth' to world base. Avoids excessive liquid in + // large caverns and floating blobs of overgenerated liquid. + generateCaves(stone_surface_max_y, -MAX_MAP_GENERATION_LIMIT); + else + generateCaves(stone_surface_max_y, MGV5_LARGE_CAVE_DEPTH); + } // Generate dungeons and desert temples if (flags & MG_DUNGEONS) @@ -223,23 +248,6 @@ void MapgenV5::makeChunk(BlockMakeData *data) } -//bool is_cave(u32 index) { -// double d1 = contour(noise_cave1->result[index]); -// double d2 = contour(noise_cave2->result[index]); -// return d1*d2 > CAVE_NOISE_THRESHOLD; -//} - -//bool val_is_ground(v3s16 p, u32 index, u32 index2d) { -// double f = 0.55 + noise_factor->result[index2d]; -// if(f < 0.01) -// f = 0.01; -// else if(f >= 1.0) -// f *= 1.6; -// double h = WATER_LEVEL + 10 * noise_height->result[index2d]; -// return (noise_ground->result[index] * f > (double)p.Y - h); -//} - - int MapgenV5::generateBaseTerrain() { u32 index = 0; diff --git a/src/mapgen_v5.h b/src/mapgen_v5.h index ddb090a9c..034d53560 100644 --- a/src/mapgen_v5.h +++ b/src/mapgen_v5.h @@ -25,6 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #define MGV5_LARGE_CAVE_DEPTH -256 +///////// Mapgen V5 flags +#define MGV5_CAVERNS 0x01 + class BiomeManager; extern FlagDesc flagdesc_mapgen_v5[]; @@ -33,12 +36,17 @@ extern FlagDesc flagdesc_mapgen_v5[]; struct MapgenV5Params : public MapgenParams { u32 spflags; float cave_width; + s16 cavern_limit; + s16 cavern_taper; + float cavern_threshold; + NoiseParams np_filler_depth; NoiseParams np_factor; NoiseParams np_height; + NoiseParams np_ground; NoiseParams np_cave1; NoiseParams np_cave2; - NoiseParams np_ground; + NoiseParams np_cavern; MapgenV5Params(); ~MapgenV5Params() {} diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 04a9e3c16..760299fd6 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -41,10 +41,11 @@ with this program; if not, write to the Free Software Foundation, Inc., FlagDesc flagdesc_mapgen_v7[] = { - {"mountains", MGV7_MOUNTAINS}, - {"ridges", MGV7_RIDGES}, - {"floatlands", MGV7_FLOATLANDS}, - {NULL, 0} + {"mountains", MGV7_MOUNTAINS}, + {"ridges", MGV7_RIDGES}, + {"floatlands", MGV7_FLOATLANDS}, + {"caverns", MGV7_CAVERNS}, + {NULL, 0} }; @@ -60,6 +61,9 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge) this->float_mount_height = params->float_mount_height; this->floatland_level = params->floatland_level; this->shadow_limit = params->shadow_limit; + this->cavern_limit = params->cavern_limit; + this->cavern_taper = params->cavern_taper; + this->cavern_threshold = params->cavern_threshold; //// Terrain noise noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Z); @@ -76,9 +80,10 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge) // 1-up 1-down overgeneration noise_mountain = new Noise(¶ms->np_mountain, seed, csize.X, csize.Y + 2, csize.Z); noise_ridge = new Noise(¶ms->np_ridge, seed, csize.X, csize.Y + 2, csize.Z); - - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; + // 1 down overgeneration + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cavern = params->np_cavern; } @@ -100,12 +105,15 @@ MapgenV7::~MapgenV7() MapgenV7Params::MapgenV7Params() { - spflags = MGV7_MOUNTAINS | MGV7_RIDGES; + spflags = MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS; cave_width = 0.09; float_mount_density = 0.6; float_mount_height = 128.0; floatland_level = 1280; shadow_limit = 1024; + cavern_limit = -256; + cavern_taper = 256; + cavern_threshold = 0.7; np_terrain_base = NoiseParams(4, 70, v3f(600, 600, 600), 82341, 5, 0.6, 2.0); np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6, 2.0); @@ -118,6 +126,7 @@ MapgenV7Params::MapgenV7Params() np_float_base_height = NoiseParams(48, 24, v3f(300, 300, 300), 907, 4, 0.7, 2.0); np_mountain = NoiseParams(-0.6, 1, v3f(250, 350, 250), 5333, 5, 0.63, 2.0); np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75, 2.0); + np_cavern = NoiseParams(0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0); np_cave1 = NoiseParams(0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0); np_cave2 = NoiseParams(0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0); } @@ -131,6 +140,9 @@ void MapgenV7Params::readParams(const Settings *settings) settings->getFloatNoEx("mgv7_float_mount_height", float_mount_height); settings->getS16NoEx("mgv7_floatland_level", floatland_level); settings->getS16NoEx("mgv7_shadow_limit", shadow_limit); + settings->getS16NoEx("mgv7_cavern_limit", cavern_limit); + settings->getS16NoEx("mgv7_cavern_taper", cavern_taper); + settings->getFloatNoEx("mgv7_cavern_threshold", cavern_threshold); settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base); settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt); @@ -143,6 +155,7 @@ void MapgenV7Params::readParams(const Settings *settings) settings->getNoiseParams("mgv7_np_float_base_height", np_float_base_height); settings->getNoiseParams("mgv7_np_mountain", np_mountain); settings->getNoiseParams("mgv7_np_ridge", np_ridge); + settings->getNoiseParams("mgv7_np_cavern", np_cavern); settings->getNoiseParams("mgv7_np_cave1", np_cave1); settings->getNoiseParams("mgv7_np_cave2", np_cave2); } @@ -156,6 +169,9 @@ void MapgenV7Params::writeParams(Settings *settings) const settings->setFloat("mgv7_float_mount_height", float_mount_height); settings->setS16("mgv7_floatland_level", floatland_level); settings->setS16("mgv7_shadow_limit", shadow_limit); + settings->setS16("mgv7_cavern_limit", cavern_limit); + settings->setS16("mgv7_cavern_taper", cavern_taper); + settings->setFloat("mgv7_cavern_threshold", cavern_threshold); settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base); settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt); @@ -168,6 +184,7 @@ void MapgenV7Params::writeParams(Settings *settings) const settings->setNoiseParams("mgv7_np_float_base_height", np_float_base_height); settings->setNoiseParams("mgv7_np_mountain", np_mountain); settings->setNoiseParams("mgv7_np_ridge", np_ridge); + settings->setNoiseParams("mgv7_np_cavern", np_cavern); settings->setNoiseParams("mgv7_np_cave1", np_cave1); settings->setNoiseParams("mgv7_np_cave2", np_cave2); } @@ -256,9 +273,23 @@ void MapgenV7::makeChunk(BlockMakeData *data) biomegen->calcBiomeNoise(node_min); MgStoneType stone_type = generateBiomes(); - if (flags & MG_CAVES) - generateCaves(stone_surface_max_y, water_level); + // Generate caverns, tunnels and classic caves + if (flags & MG_CAVES) { + bool has_cavern = false; + // Generate caverns + if (spflags & MGV7_CAVERNS) + has_cavern = generateCaverns(stone_surface_max_y); + // Generate tunnels and classic caves + if (has_cavern) + // Disable classic caves in this mapchunk by setting + // 'large cave depth' to world base. Avoids excessive liquid in + // large caverns and floating blobs of overgenerated liquid. + generateCaves(stone_surface_max_y, -MAX_MAP_GENERATION_LIMIT); + else + generateCaves(stone_surface_max_y, water_level); + } + // Generate dungeons if (flags & MG_DUNGEONS) generateDungeons(stone_surface_max_y, stone_type); @@ -274,8 +305,10 @@ void MapgenV7::makeChunk(BlockMakeData *data) //printf("makeChunk: %dms\n", t.stop()); + // Update liquids updateLiquid(&data->transforming_liquid, full_node_min, full_node_max); + // Calculate lighting // Limit floatland shadow bool propagate_shadow = !((spflags & MGV7_FLOATLANDS) && node_min.Y <= shadow_limit && node_max.Y >= shadow_limit); diff --git a/src/mapgen_v7.h b/src/mapgen_v7.h index 3972387a7..71a341afe 100644 --- a/src/mapgen_v7.h +++ b/src/mapgen_v7.h @@ -23,10 +23,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapgen.h" -////////////// Mapgen V7 flags -#define MGV7_MOUNTAINS 0x01 -#define MGV7_RIDGES 0x02 -#define MGV7_FLOATLANDS 0x04 +//////////// Mapgen V7 flags +#define MGV7_MOUNTAINS 0x01 +#define MGV7_RIDGES 0x02 +#define MGV7_FLOATLANDS 0x04 +#define MGV7_CAVERNS 0x08 class BiomeManager; @@ -40,6 +41,9 @@ struct MapgenV7Params : public MapgenParams { float float_mount_height; s16 floatland_level; s16 shadow_limit; + s16 cavern_limit; + s16 cavern_taper; + float cavern_threshold; NoiseParams np_terrain_base; NoiseParams np_terrain_alt; @@ -52,6 +56,7 @@ struct MapgenV7Params : public MapgenParams { NoiseParams np_float_base_height; NoiseParams np_mountain; NoiseParams np_ridge; + NoiseParams np_cavern; NoiseParams np_cave1; NoiseParams np_cave2; -- cgit v1.2.3 From 460e094a9fbfe589d138c71f12a8bb87627d7a94 Mon Sep 17 00:00:00 2001 From: paramat Date: Tue, 4 Apr 2017 11:59:52 +0100 Subject: Mapgen documentation: Add descriptions to noise parameters Shorten 'readable names'. Add a new advanced settings menu section for Biome API noises. Various minor edits and improvements. --- builtin/settingtypes.txt | 267 +++++++++++++++++++++++++++++++---------------- minetest.conf.example | 84 ++++++++++++--- 2 files changed, 249 insertions(+), 102 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index bbee77749..dc3164e44 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -929,36 +929,62 @@ emergequeue_limit_generate (Limit of emerge queues to generate) int 32 # at the cost of slightly buggy caves. num_emerge_threads (Number of emerge threads) int 1 -# Noise parameters for biome API temperature, humidity and biome blend. -mg_biome_np_heat (Mapgen biome heat noise parameters) noise_params 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 -mg_biome_np_heat_blend (Mapgen heat blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 -mg_biome_np_humidity (Mapgen biome humidity noise parameters) noise_params 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 -mg_biome_np_humidity_blend (Mapgen biome humidity blend noise parameters) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 +[***Biome API temperature and humidity noise parameters] + +# Temperature variation for biomes. +mg_biome_np_heat (Heat noise) noise_params 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 + +# Small-scale temperature variation for blending biomes on borders. +mg_biome_np_heat_blend (Heat blend noise) noise_params 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 + +# Humidity variation for biomes. +mg_biome_np_humidity (Humidity noise) noise_params 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 + +# Small-scale humidity variation for blending biomes on borders. +mg_biome_np_humidity_blend (Humidity blend noise) noise_params 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 [***Mapgen v5] +# Map generation attributes specific to Mapgen v5. +# Flags that are not specified in the flag string are not modified from the default. +# Flags starting with 'no' are used to explicitly disable them. +mgv5_spflags (Mapgen v5 specific flags) flags caverns caverns,nocaverns + # Controls width of tunnels, a smaller value creates wider tunnels. -mgv5_cave_width (Mapgen v5 cave width) float 0.125 +mgv5_cave_width (Cave width) float 0.125 # Y-level of cavern upper limit. -mgv5_cavern_limit (Mapgen v5 cavern limit) int -256 +mgv5_cavern_limit (Cavern limit) int -256 # Y-distance over which caverns expand to full size. -mgv5_cavern_taper (Mapgen v5 cavern taper) int 256 +mgv5_cavern_taper (Cavern taper) int 256 # Defines full size of caverns, smaller values create larger caverns. -mgv5_cavern_threshold (Mapgen v5 cavern threshold) float 0.7 - -mgv5_np_filler_depth (Mapgen v5 filler depth noise parameters) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 -mgv5_np_factor (Mapgen v5 factor noise parameters) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 -mgv5_np_height (Mapgen v5 height noise parameters) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0 -mgv5_np_cave1 (Mapgen v5 cave1 noise parameters) noise_params 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0 -mgv5_np_cave2 (Mapgen v5 cave2 noise parameters) noise_params 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 -mgv5_np_cavern (Mapgen v5 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 +mgv5_cavern_threshold (Cavern threshold) float 0.7 + +# Variation of biome filler depth. +mgv5_np_filler_depth (Filler depth noise) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 + +# Variation of terrain vertical scale. +mgv5_np_factor (Factor noise) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 + +# Y-level of average terrain surface. +mgv5_np_height (Height noise) noise_params 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0 + +# First of 2 3D noises that together define tunnels. +mgv5_np_cave1 (Cave1 noise) noise_params 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0 + +# Second of 2 3D noises that together define tunnels. +mgv5_np_cave2 (Cave2 noise) noise_params 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 + +# 3D noise defining giant caverns. +mgv5_np_cavern (Cavern noise) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 + # TODO # Noise parameters in group format, unsupported by advanced settings # menu but settable in minetest.conf. # See documentation of noise parameter formats in minetest.conf.example. +# 3D noise defining terrain. #mgv5_np_ground = { # offset = 0 # scale = 40 @@ -973,27 +999,52 @@ mgv5_np_cavern (Mapgen v5 cavern noise parameters) noise_params 0, 1, (384, 128, [***Mapgen v6] # Map generation attributes specific to Mapgen v6. -# When snowbiomes are enabled jungles are automatically enabled, the 'jungles' flag is ignored. +# The 'snowbiomes' flag enables the new 5 biome system. +# When the new biome system is enabled jungles are automatically enabled and +# the 'jungles' flag is ignored. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgv6_spflags (Mapgen v6 flags) flags jungles,biomeblend,mudflow,snowbiomes,trees jungles,biomeblend,mudflow,snowbiomes,flat,trees,nojungles,nobiomeblend,nomudflow,nosnowbiomes,noflat,notrees - -# Controls size of deserts and beaches in Mapgen v6. -# When snowbiomes are enabled 'mgv6_freq_desert' is ignored. -mgv6_freq_desert (Mapgen v6 desert frequency) float 0.45 -mgv6_freq_beach (Mapgen v6 beach frequency) float 0.15 - -mgv6_np_terrain_base (Mapgen v6 terrain base noise parameters) noise_params -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0 -mgv6_np_terrain_higher (Mapgen v6 terrain altitude noise parameters) noise_params 20, 16, (500, 500, 500), 85039, 5, 0.6, 2.0 -mgv6_np_steepness (Mapgen v6 steepness noise parameters) noise_params 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2.0 -mgv6_np_height_select (Mapgen v6 height select noise parameters) noise_params 0.5, 1, (250, 250, 250), 4213, 5, 0.69, 2.0 -mgv6_np_mud (Mapgen v6 mud noise parameters) noise_params 4, 2, (200, 200, 200), 91013, 3, 0.55, 2.0 -mgv6_np_beach (Mapgen v6 beach noise parameters) noise_params 0, 1, (250, 250, 250), 59420, 3, 0.50, 2.0 -mgv6_np_biome (Mapgen v6 biome noise parameters) noise_params 0, 1, (500, 500, 500), 9130, 3, 0.50, 2.0 -mgv6_np_cave (Mapgen v6 cave noise parameters) noise_params 6, 6, (250, 250, 250), 34329, 3, 0.50, 2.0 -mgv6_np_humidity (Mapgen v6 humidity noise parameters) noise_params 0.5, 0.5, (500, 500, 500), 72384, 3, 0.50, 2.0 -mgv6_np_trees (Mapgen v6 trees noise parameters) noise_params 0, 1, (125, 125, 125), 2, 4, 0.66, 2.0 -mgv6_np_apple_trees (Mapgen v6 apple trees noise parameters) noise_params 0, 1, (100, 100, 100), 342902, 3, 0.45, 2.0 +mgv6_spflags (Mapgen v6 specific flags) flags jungles,biomeblend,mudflow,snowbiomes,trees jungles,biomeblend,mudflow,snowbiomes,flat,trees,nojungles,nobiomeblend,nomudflow,nosnowbiomes,noflat,notrees + +# Deserts occur when np_biome exceeds this value. +# When the new biome system is enabled, this is ignored. +mgv6_freq_desert (Desert noise threshold) float 0.45 + +# Sandy beaches occur when np_beach exceeds this value. +mgv6_freq_beach (Beach noise threshold) float 0.15 + +# Y-level of lower terrain and lakebeds. +mgv6_np_terrain_base (Terrain base noise) noise_params -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0 + +# Y-level of higher (cliff-top) terrain. +mgv6_np_terrain_higher (Terrain higher noise) noise_params 20, 16, (500, 500, 500), 85039, 5, 0.6, 2.0 + +# Varies steepness of cliffs. +mgv6_np_steepness (Steepness noise) noise_params 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2.0 + +# Defines areas of 'terrain_higher' (cliff-top terrain). +mgv6_np_height_select (Height select noise) noise_params 0.5, 1, (250, 250, 250), 4213, 5, 0.69, 2.0 + +# Varies depth of biome surface nodes. +mgv6_np_mud (Mud noise) noise_params 4, 2, (200, 200, 200), 91013, 3, 0.55, 2.0 + +# Defines areas with sandy beaches. +mgv6_np_beach (Beach noise) noise_params 0, 1, (250, 250, 250), 59420, 3, 0.50, 2.0 + +# Temperature variation for biomes. +mgv6_np_biome (Biome noise) noise_params 0, 1, (500, 500, 500), 9130, 3, 0.50, 2.0 + +# Variation of number of caves. +mgv6_np_cave (Cave noise) noise_params 6, 6, (250, 250, 250), 34329, 3, 0.50, 2.0 + +# Humidity variation for biomes. +mgv6_np_humidity (Humidity noise) noise_params 0.5, 0.5, (500, 500, 500), 72384, 3, 0.50, 2.0 + +# Defines tree areas and tree density. +mgv6_np_trees (Trees noise) noise_params 0, 1, (125, 125, 125), 2, 4, 0.66, 2.0 + +# Defines areas where trees have apples. +mgv6_np_apple_trees (Apple trees noise) noise_params 0, 1, (100, 100, 100), 342902, 3, 0.45, 2.0 [***Mapgen v7] @@ -1002,47 +1053,77 @@ mgv6_np_apple_trees (Mapgen v6 apple trees noise parameters) noise_params 0, 1, # Floatlands are currently experimental and subject to change. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgv7_spflags (Mapgen v7 flags) flags mountains,ridges mountains,ridges,floatlands,nomountains,noridges,nofloatlands +mgv7_spflags (Mapgen v7 specific flags) flags mountains,ridges,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns # Controls width of tunnels, a smaller value creates wider tunnels. -mgv7_cave_width (Mapgen v7 cave width) float 0.09 +mgv7_cave_width (Cave width) float 0.09 # Controls the density of floatland mountain terrain. # Is an offset added to the 'np_mountain' noise value. -mgv7_float_mount_density (Mapgen v7 floatland mountain density) float 0.6 +mgv7_float_mount_density (Floatland mountain density) float 0.6 # Typical maximum height, above and below midpoint, of floatland mountain terrain. -mgv7_float_mount_height (Mapgen v7 floatland mountain height) float 128.0 +mgv7_float_mount_height (Floatland mountain height) float 128.0 # Y-level of floatland midpoint and lake surface. -mgv7_floatland_level (Mapgen v7 floatland level) int 1280 +mgv7_floatland_level (Floatland level) int 1280 # Y-level to which floatland shadows extend. -mgv7_shadow_limit (Mapgen v7 shadow limit) int 1024 +mgv7_shadow_limit (Shadow limit) int 1024 # Y-level of cavern upper limit. -mgv7_cavern_limit (Mapgen v7 cavern limit) int -256 +mgv7_cavern_limit (Cavern limit) int -256 # Y-distance over which caverns expand to full size. -mgv7_cavern_taper (Mapgen v7 cavern taper) int 256 +mgv7_cavern_taper (Cavern taper) int 256 # Defines full size of caverns, smaller values create larger caverns. -mgv7_cavern_threshold (Mapgen v7 cavern threshold) float 0.7 - -mgv7_np_terrain_base (Mapgen v7 terrain base noise parameters) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 -mgv7_np_terrain_alt (Mapgen v7 terrain altitude noise parameters) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0 -mgv7_np_terrain_persist (Mapgen v7 terrain persistation noise parameters) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0 -mgv7_np_height_select (Mapgen v7 height select noise parameters) noise_params -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0 -mgv7_np_filler_depth (Mapgen v7 filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 -mgv7_np_mount_height (Mapgen v7 mount height noise parameters) noise_params 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0 -mgv7_np_ridge_uwater (Mapgen v7 river course noise parameters) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0 -mgv7_np_floatland_base (Mapgen v7 floatland base terrain noise parameters) noise_params -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0 -mgv7_np_float_base_height (Mapgen v7 floatland base terrain height noise parameters) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0 -mgv7_np_mountain (Mapgen v7 mountain noise parameters) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0 -mgv7_np_ridge (Mapgen v7 river channel wall noise parameters) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 -mgv7_np_cavern (Mapgen v7 cavern noise parameters) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 -mgv7_np_cave1 (Mapgen v7 cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +mgv7_cavern_threshold (Cavern threshold) float 0.7 + +# Y-level of higher (cliff-top) terrain. +mgv7_np_terrain_base (Terrain base noise) noise_params 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 + +# Y-level of lower terrain and lakebeds. +mgv7_np_terrain_alt (Terrain alt noise) noise_params 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0 + +# Varies roughness of terrain. +# Defines the 'persistence' value for terrain_base and terrain_alt noises. +mgv7_np_terrain_persist (Terrain persistence noise) noise_params 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0 + +# Defines areas of higher (cliff-top) terrain and affects steepness of cliffs. +mgv7_np_height_select (Height select noise) noise_params -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0 + +# Variation of biome filler depth. +mgv7_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 + +# Variation of maximum mountain height (in nodes). +mgv7_np_mount_height (Mountain height noise) noise_params 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0 + +# Defines large-scale river channel structure. +mgv7_np_ridge_uwater (Ridge underwater noise) noise_params 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0 + +# Defines areas of floatland smooth terrain. +# Smooth floatlands occur when noise > 0. +mgv7_np_floatland_base (Floatland base noise) noise_params -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0 + +# Variation of hill height and lake depth on floatland smooth terrain. +mgv7_np_float_base_height (Floatland base height noise) noise_params 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0 + +# 3D noise defining mountain structure and height. +# Also defines structure of floatland mountain terrain. +mgv7_np_mountain (Mountain noise) noise_params -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0 + +# 3D noise defining structure of river canyon walls. +mgv7_np_ridge (Ridge noise) noise_params 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 + +# 3D noise defining giant caverns. +mgv7_np_cavern (Cavern noise) noise_params 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 + +# First of 2 3D noises that together define tunnels. +mgv7_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 + +# Second of 2 3D noises that together define tunnels. +mgv7_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 [***Mapgen flat] @@ -1050,46 +1131,49 @@ mgv7_np_cave2 (Mapgen v7 cave2 noise parameters) noise_params 0, 12, (67, 67, 67 # Occasional lakes and hills can be added to the flat world. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgflat_spflags (Mapgen flat flags) flags lakes,hills,,nolakes,nohills +mgflat_spflags (Mapgen flat specific flags) flags lakes,hills,,nolakes,nohills # Y of flat ground. -mgflat_ground_level (Mapgen flat ground level) int 8 +mgflat_ground_level (Ground level) int 8 # Y of upper limit of large pseudorandom caves. -mgflat_large_cave_depth (Mapgen flat large cave depth) int -33 +mgflat_large_cave_depth (Large cave depth) int -33 # Controls width of tunnels, a smaller value creates wider tunnels. -mgflat_cave_width (Mapgen flat cave width) float 0.09 +mgflat_cave_width (Cave width) float 0.09 # Terrain noise threshold for lakes. # Controls proportion of world area covered by lakes. # Adjust towards 0.0 for a larger proportion. -mgflat_lake_threshold (Mapgen flat lake threshold) float -0.45 +mgflat_lake_threshold (Lake threshold) float -0.45 # Controls steepness/depth of lake depressions. -mgflat_lake_steepness (Mapgen flat lake steepness) float 48.0 +mgflat_lake_steepness (Lake steepness) float 48.0 # Terrain noise threshold for hills. # Controls proportion of world area covered by hills. # Adjust towards 0.0 for a larger proportion. -mgflat_hill_threshold (Mapgen flat hill threshold) float 0.45 +mgflat_hill_threshold (Hill threshold) float 0.45 # Controls steepness/height of hills. -mgflat_hill_steepness (Mapgen flat hill steepness) float 64.0 +mgflat_hill_steepness (Hill steepness) float 64.0 -# Determines terrain shape. -# The 3 numbers in brackets control the scale of the -# terrain, the 3 numbers should be identical. -mgflat_np_terrain (Mapgen flat terrain noise parameters) noise_params 0, 1, (600, 600, 600), 7244, 5, 0.6, 2.0 +# Defines location and terrain of optional hills and lakes. +mgflat_np_terrain (Terrain noise) noise_params 0, 1, (600, 600, 600), 7244, 5, 0.6, 2.0 -mgflat_np_filler_depth (Mapgen flat filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 -mgflat_np_cave1 (Mapgen flat cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgflat_np_cave2 (Mapgen flat cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +# Variation of biome filler depth. +mgflat_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 + +# First of 2 3D noises that together define tunnels. +mgflat_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 + +# Second of 2 3D noises that together define tunnels. +mgflat_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 [***Mapgen fractal] # Controls width of tunnels, a smaller value creates wider tunnels. -mgfractal_cave_width (Mapgen fractal cave width) float 0.09 +mgfractal_cave_width (Cave width) float 0.09 # Choice of 18 fractals from 9 formulas. # 1 = 4D "Roundy" mandelbrot set. @@ -1110,48 +1194,55 @@ mgfractal_cave_width (Mapgen fractal cave width) float 0.09 # 16 = 3D "Cosine Mandelbulb" julia set. # 17 = 4D "Mandelbulb" mandelbrot set. # 18 = 4D "Mandelbulb" julia set. -mgfractal_fractal (Mapgen fractal fractal) int 1 1 18 +mgfractal_fractal (Fractal type) int 1 1 18 # Iterations of the recursive function. # Controls the amount of fine detail. -mgfractal_iterations (Mapgen fractal iterations) int 11 +mgfractal_iterations (Iterations) int 11 # Approximate (X,Y,Z) scale of fractal in nodes. -mgfractal_scale (Mapgen fractal scale) v3f (4096.0, 1024.0, 4096.0) +mgfractal_scale (Scale) v3f (4096.0, 1024.0, 4096.0) # (X,Y,Z) offset of fractal from world centre in units of 'scale'. # Used to move a suitable spawn area of low land close to (0, 0). # The default is suitable for mandelbrot sets, it needs to be edited for julia sets. # Range roughly -2 to 2. Multiply by 'scale' for offset in nodes. -mgfractal_offset (Mapgen fractal offset) v3f (1.79, 0.0, 0.0) +mgfractal_offset (Offset) v3f (1.79, 0.0, 0.0) # W co-ordinate of the generated 3D slice of a 4D fractal. # Determines which 3D slice of the 4D shape is generated. # Has no effect on 3D fractals. # Range roughly -2 to 2. -mgfractal_slice_w (Mapgen fractal slice w) float 0.0 +mgfractal_slice_w (Slice w) float 0.0 # Julia set only: X component of hypercomplex constant determining julia shape. # Range roughly -2 to 2. -mgfractal_julia_x (Mapgen fractal julia x) float 0.33 +mgfractal_julia_x (Julia x) float 0.33 # Julia set only: Y component of hypercomplex constant determining julia shape. # Range roughly -2 to 2. -mgfractal_julia_y (Mapgen fractal julia y) float 0.33 +mgfractal_julia_y (Julia y) float 0.33 # Julia set only: Z component of hypercomplex constant determining julia shape. # Range roughly -2 to 2. -mgfractal_julia_z (Mapgen fractal julia z) float 0.33 +mgfractal_julia_z (Julia z) float 0.33 # Julia set only: W component of hypercomplex constant determining julia shape. # Has no effect on 3D fractals. # Range roughly -2 to 2. -mgfractal_julia_w (Mapgen fractal julia w) float 0.33 +mgfractal_julia_w (Julia w) float 0.33 + +# Y-level of seabed. +mgfractal_np_seabed (Seabed noise) noise_params -14, 9, (600, 600, 600), 41900, 5, 0.6, 2.0 + +# Variation of biome filler depth. +mgfractal_np_filler_depth (Filler depth noise) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 + +# First of 2 3D noises that together define tunnels. +mgfractal_np_cave1 (Cave1 noise) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgfractal_np_seabed (Mapgen fractal seabed noise parameters) noise_params -14, 9, (600, 600, 600), 41900, 5, 0.6, 2.0 -mgfractal_np_filler_depth (Mapgen fractal filler depth noise parameters) noise_params 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 -mgfractal_np_cave1 (Mapgen fractal cave1 noise parameters) noise_params 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 -mgfractal_np_cave2 (Mapgen fractal cave2 noise parameters) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +# Second of 2 3D noises that together define tunnels. +mgfractal_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 # Mapgen Valleys parameters [***Mapgen Valleys] diff --git a/minetest.conf.example b/minetest.conf.example index 5927cdb03..292a645e3 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1155,21 +1155,32 @@ server_side_occlusion_culling = true # Only the group format supports noise flags which are needed for eased noise. # Mgv5 uses eased noise for np_ground so this is shown in group format below. -# Noise parameters for biome API temperature, humidity and biome blend. +#### Biome API temperature and humidity noise parameters + +# Temperature variation for biomes. # type: noise_params # mg_biome_np_heat = 50, 50, (1000, 1000, 1000), 5349, 3, 0.5, 2.0 +# Small-scale temperature variation for blending biomes on borders. # type: noise_params # mg_biome_np_heat_blend = 0, 1.5, (8, 8, 8), 13, 2, 1.0, 2.0 +# Humidity variation for biomes. # type: noise_params # mg_biome_np_humidity = 50, 50, (1000, 1000, 1000), 842, 3, 0.5, 2.0 +# Small-scale humidity variation for blending biomes on borders. # type: noise_params # mg_biome_np_humidity_blend = 0, 1.5, (8, 8, 8), 90003, 2, 1.0, 2.0 #### Mapgen v5 +# Map generation attributes specific to Mapgen v5. +# Flags that are not specified in the flag string are not modified from the default. +# Flags starting with 'no' are used to explicitly disable them. +# type: flags possible values: caverns, nocaverns +# mgv5_spflags = caverns + # Controls width of tunnels, a smaller value creates wider tunnels. # type: float # mgv5_cave_width = 0.125 @@ -1186,27 +1197,36 @@ server_side_occlusion_culling = true # type: float # mgv5_cavern_threshold = 0.7 +# Variation of biome filler depth. # type: noise_params # mgv5_np_filler_depth = 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 +# Variation of terrain vertical scale. +# When noise is < -0.55 terrain is near-flat. # type: noise_params # mgv5_np_factor = 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 +# Y-level of average terrain surface. # type: noise_params # mgv5_np_height = 0, 10, (250, 250, 250), 84174, 4, 0.5, 2.0 +# First of 2 3D noises that together define tunnels. # type: noise_params # mgv5_np_cave1 = 0, 12, (50, 50, 50), 52534, 4, 0.5, 2.0 +# Second of 2 3D noises that together define tunnels. # type: noise_params # mgv5_np_cave2 = 0, 12, (50, 50, 50), 10325, 4, 0.5, 2.0 +# 3D noise defining giant caverns. # type: noise_params # mgv5_np_cavern = 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 -# Noise parameters in group format, unsupported by advanced settings +# Noise parameter in group format, unsupported by advanced settings # menu but settable in minetest.conf. # See documentation of noise parameter formats above. +# 3D noise defining terrain. +# type: noise_params # mgv5_np_ground = { # offset = 0, # scale = 40, @@ -1221,50 +1241,64 @@ server_side_occlusion_culling = true #### Mapgen v6 # Map generation attributes specific to Mapgen v6. -# When snowbiomes are enabled jungles are automatically enabled, the 'jungles' flag is ignored. +# The 'snowbiomes' flag enables the new 5 biome system. +# When the new biome system is enabled jungles are automatically enabled and +# the 'jungles' flag is ignored. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. # type: flags possible values: jungles, biomeblend, mudflow, snowbiomes, flat, trees, nojungles, nobiomeblend, nomudflow, nosnowbiomes, noflat, notrees # mgv6_spflags = jungles,biomeblend,mudflow,snowbiomes,trees -# Controls size of deserts and beaches in Mapgen v6. -# When snowbiomes are enabled 'mgv6_freq_desert' is ignored. +# Deserts occur when np_biome exceeds this value. +# When the new biome system is enabled, this is ignored. # type: float # mgv6_freq_desert = 0.45 +# Sandy beaches occur when np_beach exceeds this value. # type: float # mgv6_freq_beach = 0.15 +# Y-level of lower terrain and lakebeds. # type: noise_params # mgv6_np_terrain_base = -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0 +# Y-level of higher (cliff-top) terrain. # type: noise_params # mgv6_np_terrain_higher = 20, 16, (500, 500, 500), 85039, 5, 0.6, 2.0 +# Varies steepness of cliffs. # type: noise_params # mgv6_np_steepness = 0.85, 0.5, (125, 125, 125), -932, 5, 0.7, 2.0 +# Defines areas of 'terrain_higher' (cliff-top terrain). # type: noise_params # mgv6_np_height_select = 0.5, 1, (250, 250, 250), 4213, 5, 0.69, 2.0 +# Varies depth of biome surface nodes. # type: noise_params # mgv6_np_mud = 4, 2, (200, 200, 200), 91013, 3, 0.55, 2.0 +# Defines areas with sandy beaches. # type: noise_params # mgv6_np_beach = 0, 1, (250, 250, 250), 59420, 3, 0.50, 2.0 +# Temperature variation for biomes. # type: noise_params # mgv6_np_biome = 0, 1, (500, 500, 500), 9130, 3, 0.50, 2.0 +# Variation of number of caves. # type: noise_params # mgv6_np_cave = 6, 6, (250, 250, 250), 34329, 3, 0.50, 2.0 +# Humidity variation for biomes. # type: noise_params # mgv6_np_humidity = 0.5, 0.5, (500, 500, 500), 72384, 3, 0.50, 2.0 +# Defines tree areas and tree density. # type: noise_params # mgv6_np_trees = 0, 1, (125, 125, 125), 2, 4, 0.66, 2.0 +# Defines areas where trees have apples. # type: noise_params # mgv6_np_apple_trees = 0, 1, (100, 100, 100), 342902, 3, 0.45, 2.0 @@ -1275,8 +1309,8 @@ server_side_occlusion_culling = true # Floatlands are currently experimental and subject to change. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -# type: flags possible values: mountains, ridges, floatlands, nomountains, noridges, nofloatlands -# mgv7_spflags = mountains,ridges +# type: flags possible values: mountains, ridges, floatlands, caverns, nomountains, noridges, nofloatlands, nocaverns +# mgv7_spflags = mountains,ridges,nofloatlands,caverns # Controls width of tunnels, a smaller value creates wider tunnels. # type: float @@ -1311,45 +1345,62 @@ server_side_occlusion_culling = true # type: float # mgv7_cavern_threshold = 0.7 +# Y-level of higher (cliff-top) terrain. # type: noise_params # mgv7_np_terrain_base = 4, 70, (600, 600, 600), 82341, 5, 0.6, 2.0 +# Y-level of lower terrain and lakebeds. # type: noise_params # mgv7_np_terrain_alt = 4, 25, (600, 600, 600), 5934, 5, 0.6, 2.0 +# Varies roughness of terrain. +# Defines the 'persistence' value for terrain_base and terrain_alt noises. # type: noise_params # mgv7_np_terrain_persist = 0.6, 0.1, (2000, 2000, 2000), 539, 3, 0.6, 2.0 +# Defines areas of higher (cliff-top) terrain and affects steepness of cliffs. # type: noise_params # mgv7_np_height_select = -8, 16, (500, 500, 500), 4213, 6, 0.7, 2.0 +# Variation of biome filler depth. # type: noise_params # mgv7_np_filler_depth = 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 +# Variation of maximum mountain height (in nodes). # type: noise_params # mgv7_np_mount_height = 256, 112, (1000, 1000, 1000), 72449, 3, 0.6, 2.0 +# Defines large-scale river channel structure. # type: noise_params # mgv7_np_ridge_uwater = 0, 1, (1000, 1000, 1000), 85039, 5, 0.6, 2.0 +# Defines areas of floatland smooth terrain. +# Smooth floatlands occur when noise > 0. # type: noise_params # mgv7_np_floatland_base = -0.6, 1.5, (600, 600, 600), 114, 5, 0.6, 2.0 +# Variation of hill height and lake depth on floatland smooth terrain. # type: noise_params # mgv7_np_float_base_height = 48, 24, (300, 300, 300), 907, 4, 0.7, 2.0 +# 3D noise defining mountain structure and height. +# Also defines structure of floatland mountain terrain. # type: noise_params # mgv7_np_mountain = -0.6, 1, (250, 350, 250), 5333, 5, 0.63, 2.0 +# 3D noise defining structure of river canyon walls. # type: noise_params # mgv7_np_ridge = 0, 1, (100, 100, 100), 6467, 4, 0.75, 2.0 +# 3D noise defining giant caverns. # type: noise_params # mgv7_np_cavern = 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 +# First of 2 3D noises that together define tunnels. # type: noise_params # mgv7_np_cave1 = 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 +# Second of 2 3D noises that together define tunnels. # type: noise_params # mgv7_np_cave2 = 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 @@ -1359,8 +1410,8 @@ server_side_occlusion_culling = true # Occasional lakes and hills can be added to the flat world. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -# type: flags possible values: lakes, hills, , nolakes, nohills -# mgflat_spflags = +# type: flags possible values: lakes, hills, nolakes, nohills +# mgflat_spflags = nolakes,nohills # Y of flat ground. # type: int @@ -1374,7 +1425,7 @@ server_side_occlusion_culling = true # type: float # mgflat_cave_width = 0.09 -# Terrain noise threshold for lakes. +# Terrain noise threshold for optional lakes. # Controls proportion of world area covered by lakes. # Adjust towards 0.0 for a larger proportion. # type: float @@ -1384,7 +1435,7 @@ server_side_occlusion_culling = true # type: float # mgflat_lake_steepness = 48.0 -# Terrain noise threshold for hills. +# Terrain noise threshold for optional hills. # Controls proportion of world area covered by hills. # Adjust towards 0.0 for a larger proportion. # type: float @@ -1394,18 +1445,19 @@ server_side_occlusion_culling = true # type: float # mgflat_hill_steepness = 64.0 -# Determines terrain shape. -# The 3 numbers in brackets control the scale of the -# terrain, the 3 numbers should be identical. +# Defines location and terrain of optional hills and lakes. # type: noise_params # mgflat_np_terrain = 0, 1, (600, 600, 600), 7244, 5, 0.6, 2.0 +# Variation of biome filler depth. # type: noise_params # mgflat_np_filler_depth = 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 +# First of 2 3D noises that together define tunnels. # type: noise_params # mgflat_np_cave1 = 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 +# Second of 2 3D noises that together define tunnels. # type: noise_params # mgflat_np_cave2 = 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 @@ -1481,15 +1533,19 @@ server_side_occlusion_culling = true # type: float # mgfractal_julia_w = 0.33 +# Y-level of seabed. # type: noise_params # mgfractal_np_seabed = -14, 9, (600, 600, 600), 41900, 5, 0.6, 2.0 +# Variation of biome filler depth. # type: noise_params # mgfractal_np_filler_depth = 0, 1.2, (150, 150, 150), 261, 3, 0.7, 2.0 +# First of 2 3D noises that together define tunnels. # type: noise_params # mgfractal_np_cave1 = 0, 12, (61, 61, 61), 52534, 3, 0.5, 2.0 +# Second of 2 3D noises that together define tunnels. # type: noise_params # mgfractal_np_cave2 = 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 -- cgit v1.2.3 From bce0d458d8cda70c10d78ea9ec476474f0a6f01a Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 2 Apr 2017 23:00:34 +0100 Subject: Add Joystick type detection and Xbox controller support * Add joystick type detection (with joystick_type setting to override it) * Fix multiple joysticks from interfering with each other by only reading from one (add joystick_id setting) * Add support for Xbox controllers --- builtin/settingtypes.txt | 6 +++ minetest.conf.example | 9 +++- src/client/clientlauncher.cpp | 51 ++++++++++-------- src/client/clientlauncher.h | 1 + src/client/joystick_controller.cpp | 104 ++++++++++++++++++++++++++++++++----- src/client/joystick_controller.h | 9 +++- src/defaultsettings.cpp | 2 + src/game.h | 1 - 8 files changed, 146 insertions(+), 37 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index dc3164e44..d95f8cf41 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -107,6 +107,12 @@ continuous_forward (Continuous forward) bool false # Enable Joysticks enable_joysticks (Enable Joysticks) bool false +# The identifier of the joystick to use +joystick_id (Joystick ID) int 0 + +# The type of joystick +joystick_type (Joystick Type) enum auto auto,generic,xbox + # The time in seconds it takes between repeated events # when holding down a joystick button combination. repeat_joystick_button_time (Joystick button repetition interval) float 0.17 diff --git a/minetest.conf.example b/minetest.conf.example index 292a645e3..cfc66f168 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -87,6 +87,14 @@ # type: bool # enable_joysticks = false +# The identifier of the joystick to use +# type: int +# joystick_id = 0 + +# The type of joystick +# type: enum values: auto,generic,xbox +# joystick_type = auto + # The time in seconds it takes between repeated events # when holding down a joystick button combination. # type: float @@ -1786,4 +1794,3 @@ server_side_occlusion_culling = true # Print the engine's profiling data in regular intervals (in seconds). 0 = disable. Useful for developers. # type: int # profiler_print_interval = 0 - diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 3ec7be7d9..249f6727a 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -127,10 +127,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) device->setResizable(true); - if (random_input) - input = new RandomInputHandler(); - else - input = new RealInputHandler(device, receiver); + init_input(); smgr = device->getSceneManager(); smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true); @@ -337,6 +334,33 @@ bool ClientLauncher::init_engine() return device != NULL; } +void ClientLauncher::init_input() +{ + if (random_input) + input = new RandomInputHandler(); + else + input = new RealInputHandler(device, receiver); + + if (g_settings->getBool("enable_joysticks")) { + irr::core::array infos; + std::vector joystick_infos; + + // Make sure this is called maximum once per + // irrlicht device, otherwise it will give you + // multiple events for the same joystick. + if (device->activateJoysticks(infos)) { + infostream << "Joystick support enabled" << std::endl; + joystick_infos.reserve(infos.size()); + for (u32 i = 0; i < infos.size(); i++) { + joystick_infos.push_back(infos[i]); + } + input->joystick.onJoystickConnect(joystick_infos); + } else { + errorstream << "Could not activate joystick support." << std::endl; + } + } +} + bool ClientLauncher::launch_game(std::string &error_message, bool reconnect_requested, GameParams &game_params, const Settings &cmd_args) @@ -566,25 +590,8 @@ bool ClientLauncher::create_engine_device() device = createDeviceEx(params); - if (device) { - if (g_settings->getBool("enable_joysticks")) { - irr::core::array infos; - std::vector joystick_infos; - // Make sure this is called maximum once per - // irrlicht device, otherwise it will give you - // multiple events for the same joystick. - if (device->activateJoysticks(infos)) { - infostream << "Joystick support enabled" << std::endl; - joystick_infos.reserve(infos.size()); - for (u32 i = 0; i < infos.size(); i++) { - joystick_infos.push_back(infos[i]); - } - } else { - errorstream << "Could not activate joystick support." << std::endl; - } - } + if (device) porting::initIrrlicht(device); - } return device != NULL; } diff --git a/src/client/clientlauncher.h b/src/client/clientlauncher.h index b10bbebc9..ab22d7aaa 100644 --- a/src/client/clientlauncher.h +++ b/src/client/clientlauncher.h @@ -91,6 +91,7 @@ public: protected: void init_args(GameParams &game_params, const Settings &cmd_args); bool init_engine(); + void init_input(); bool launch_game(std::string &error_message, bool reconnect_requested, GameParams &game_params, const Settings &cmd_args); diff --git a/src/client/joystick_controller.cpp b/src/client/joystick_controller.cpp index ef8d18ab0..311cd22fb 100644 --- a/src/client/joystick_controller.cpp +++ b/src/client/joystick_controller.cpp @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "keys.h" #include "settings.h" #include "gettime.h" +#include "../util/string.h" bool JoystickButtonCmb::isTriggered(const irr::SEvent::SJoystickEvent &ev) const { @@ -42,7 +43,7 @@ bool JoystickAxisCmb::isTriggered(const irr::SEvent::SJoystickEvent &ev) const #define JLO_B_PB(A, B, C) jlo.button_keys.push_back(JoystickButtonCmb(A, B, C)) #define JLO_A_PB(A, B, C, D) jlo.axis_keys.push_back(JoystickAxisCmb(A, B, C, D)) -static JoystickLayout create_default_layout() +JoystickLayout create_default_layout() { JoystickLayout jlo; @@ -103,11 +104,59 @@ static JoystickLayout create_default_layout() return jlo; } -static const JoystickLayout default_layout = create_default_layout(); +JoystickLayout create_xbox_layout() +{ + JoystickLayout jlo; + + jlo.axes_dead_border = 7000; + + const JoystickAxisLayout axes[JA_COUNT] = { + {0, 1}, // JA_SIDEWARD_MOVE + {1, 1}, // JA_FORWARD_MOVE + {2, 1}, // JA_FRUSTUM_HORIZONTAL + {3, 1}, // JA_FRUSTUM_VERTICAL + }; + memcpy(jlo.axes, axes, sizeof(jlo.axes)); + + // The back button means "ESC". + JLO_B_PB(KeyType::ESC, 1 << 8, 1 << 8); // back + JLO_B_PB(KeyType::ESC, 1 << 9, 1 << 9); // start + + // 4 Buttons + JLO_B_PB(KeyType::JUMP, 1 << 0, 1 << 0); // A/green + JLO_B_PB(KeyType::ESC, 1 << 1, 1 << 1); // B/red + JLO_B_PB(KeyType::SPECIAL1, 1 << 2, 1 << 2); // X/blue + JLO_B_PB(KeyType::INVENTORY, 1 << 3, 1 << 3); // Y/yellow + + // Analog Sticks + JLO_B_PB(KeyType::SPECIAL1, 1 << 11, 1 << 11); // left + JLO_B_PB(KeyType::SNEAK, 1 << 12, 1 << 12); // right + + // Triggers + JLO_B_PB(KeyType::MOUSE_L, 1 << 6, 1 << 6); // lt + JLO_B_PB(KeyType::MOUSE_R, 1 << 7, 1 << 7); // rt + JLO_B_PB(KeyType::SCROLL_UP, 1 << 4, 1 << 4); // lb + JLO_B_PB(KeyType::SCROLL_DOWN, 1 << 5, 1 << 5); // rb + + // D-PAD + JLO_B_PB(KeyType::ZOOM, 1 << 15, 1 << 15); // up + JLO_B_PB(KeyType::DROP, 1 << 13, 1 << 13); // left + JLO_B_PB(KeyType::SCREENSHOT, 1 << 14, 1 << 14); // right + JLO_B_PB(KeyType::FREEMOVE, 1 << 16, 1 << 16); // down + + // Movement buttons, important for vessels + JLO_A_PB(KeyType::FORWARD, 1, 1, 1024); + JLO_A_PB(KeyType::BACKWARD, 1, -1, 1024); + JLO_A_PB(KeyType::LEFT, 0, 1, 1024); + JLO_A_PB(KeyType::RIGHT, 0, -1, 1024); + + return jlo; +} JoystickController::JoystickController() { - m_layout = &default_layout; + m_joystick_id = 0; + doubling_dtime = g_settings->getFloat("repeat_joystick_button_time"); for (size_t i = 0; i < KeyType::INTERNAL_ENUM_COUNT; i++) { @@ -116,23 +165,54 @@ JoystickController::JoystickController() clear(); } +void JoystickController::onJoystickConnect(const std::vector &joystick_infos) +{ + s32 id = g_settings->getS32("joystick_id"); + std::string layout = g_settings->get("joystick_type"); + + if (id < 0 || id >= joystick_infos.size()) { + // TODO: auto detection + id = 0; + } + + if (id >= 0 && id < joystick_infos.size()) { + if (layout.empty() || layout == "auto") + setLayoutFromControllerName(joystick_infos[id].Name.c_str()); + else + setLayoutFromControllerName(layout); + } + + m_joystick_id = id; +} + +void JoystickController::setLayoutFromControllerName(std::string name) { + if (lowercase(name).find("xbox") >= 0) { + m_layout = create_xbox_layout(); + } else { + m_layout = create_default_layout(); + } +} + bool JoystickController::handleEvent(const irr::SEvent::SJoystickEvent &ev) { + if (ev.Joystick != m_joystick_id) + return false; + m_internal_time = getTimeMs() / 1000.f; std::bitset keys_pressed; // First generate a list of keys pressed - for (size_t i = 0; i < m_layout->button_keys.size(); i++) { - if (m_layout->button_keys[i].isTriggered(ev)) { - keys_pressed.set(m_layout->button_keys[i].key); + for (size_t i = 0; i < m_layout.button_keys.size(); i++) { + if (m_layout.button_keys[i].isTriggered(ev)) { + keys_pressed.set(m_layout.button_keys[i].key); } } - for (size_t i = 0; i < m_layout->axis_keys.size(); i++) { - if (m_layout->axis_keys[i].isTriggered(ev)) { - keys_pressed.set(m_layout->axis_keys[i].key); + for (size_t i = 0; i < m_layout.axis_keys.size(); i++) { + if (m_layout.axis_keys[i].isTriggered(ev)) { + keys_pressed.set(m_layout.axis_keys[i].key); } } @@ -153,7 +233,7 @@ bool JoystickController::handleEvent(const irr::SEvent::SJoystickEvent &ev) } for (size_t i = 0; i < JA_COUNT; i++) { - const JoystickAxisLayout &ax_la = m_layout->axes[i]; + const JoystickAxisLayout &ax_la = m_layout.axes[i]; m_axes_vals[i] = ax_la.invert * ev.Axis[ax_la.axis_id]; } @@ -172,8 +252,8 @@ void JoystickController::clear() s16 JoystickController::getAxisWithoutDead(JoystickAxis axis) { s16 v = m_axes_vals[axis]; - if (((v > 0) && (v < m_layout->axes_dead_border)) || - ((v < 0) && (v > -m_layout->axes_dead_border))) + if (((v > 0) && (v < m_layout.axes_dead_border)) || + ((v < 0) && (v > -m_layout.axes_dead_border))) return 0; return v; } diff --git a/src/client/joystick_controller.h b/src/client/joystick_controller.h index ed0ee4068..867a0c3f2 100644 --- a/src/client/joystick_controller.h +++ b/src/client/joystick_controller.h @@ -98,6 +98,9 @@ class JoystickController { public: JoystickController(); + + void onJoystickConnect(const std::vector &joystick_infos); + bool handleEvent(const irr::SEvent::SJoystickEvent &ev); void clear(); @@ -146,10 +149,14 @@ public: f32 doubling_dtime; private: - const JoystickLayout *m_layout; + void setLayoutFromControllerName(std::string name); + + JoystickLayout m_layout; s16 m_axes_vals[JA_COUNT]; + u8 m_joystick_id; + std::bitset m_pressed_keys; f32 m_internal_time; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 4b50b991b..3f4ce6337 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -203,6 +203,8 @@ void set_default_settings(Settings *settings) settings->setDefault("always_fly_fast", "true"); settings->setDefault("continuous_forward", "false"); settings->setDefault("enable_joysticks", "false"); + settings->setDefault("joystick_id", "0"); + settings->setDefault("joystick_type", ""); settings->setDefault("repeat_joystick_button_time", "0.17"); settings->setDefault("joystick_frustum_sensitivity", "170"); diff --git a/src/game.h b/src/game.h index 19992ce3d..eaedca165 100644 --- a/src/game.h +++ b/src/game.h @@ -171,4 +171,3 @@ void the_game(bool *kill, bool simple_singleplayer_mode); #endif - -- cgit v1.2.3 From 71ffe699d0d8e5cd2594eb74d0d767eeb8a09cea Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Fri, 7 Apr 2017 17:10:26 +0200 Subject: Settings: Update documentation (#5534) Now documented (sorted a-z): enable_console enable_particles creative_mode hud_scaling inventory_image_hack keymap_console keymap_zoom shader_path view_bobbing --- builtin/settingtypes.txt | 49 ++++++++++++++++++++++++++++++++------ minetest.conf.example | 61 +++++++++++++++++++++++++++++++++++++++++------- src/defaultsettings.cpp | 1 - 3 files changed, 95 insertions(+), 16 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index d95f8cf41..a3b91fe74 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -206,6 +206,10 @@ keymap_screenshot (Screenshot) key KEY_F12 # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_drop (Drop item key) key KEY_KEY_Q +# Key to use view zoom when possible. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_zoom (View zoom key) key KEY_KEY_Z + # Key for toggling the display of the HUD. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_toggle_hud (HUD toggle key) key KEY_F1 @@ -214,6 +218,10 @@ keymap_toggle_hud (HUD toggle key) key KEY_F1 # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_toggle_chat (Chat toggle key) key KEY_F2 +# Key for toggling the display of the large chat console. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_console (Large chat console key) key KEY_F10 + # Key for toggling the display of the fog. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_toggle_force_fog_off (Fog toggle key) key KEY_F3 @@ -275,6 +283,7 @@ show_entity_selectionbox (Show entity selection boxes) bool true enable_remote_media_server (Connect to external media server) bool true # Enable Lua modding support on client. +# This support is experimental and API can change. enable_client_modding (Client modding) bool false # URL to the server list displayed in the Multiplayer Tab. @@ -317,6 +326,9 @@ enable_3d_clouds (3D clouds) bool true # Method used to highlight selected object. node_highlighting (Node highlighting) enum box box,halo +# Adds particles when digging a node. +enable_particles (Digging particles) bool true + [***Filtering] # Use mip mapping to scale textures. May slightly increase performance. @@ -353,9 +365,12 @@ fsaa (FSAA) enum 0 0,1,2,4,8,16 [***Shaders] # Shaders allow advanced visual effects and may increase performance on some video cards. -# Thy only work with the OpenGL video backend. +# This only works with the OpenGL video backend. enable_shaders (Shaders) bool true +# Path to shader directory. If no path is defined, default location will be used. +shader_path (Shader path) path + [****Tone Mapping] # Enables filmic tone mapping @@ -390,7 +405,7 @@ enable_parallax_occlusion (Parallax occlusion) bool false parallax_occlusion_mode (Parallax occlusion mode) int 1 0 1 # Strength of parallax. -3d_parallax_strength (Parallax occlusion strength) float 0.025 +3d_paralax_strength (Parallax occlusion strength) float 0.025 # Number of parallax occlusion iterations. parallax_occlusion_iterations (Parallax occlusion iterations) int 4 @@ -472,13 +487,16 @@ cloud_height (Cloud height) int 120 # Values larger than 26 will start to produce sharp cutoffs at cloud area corners. cloud_radius (Cloud radius) int 12 +# Enables view bobbing when walking. +view_bobbing (Enable view bobbing) bool true + # Multiplier for view bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. -view_bobbing_amount (View bobbing) float 1.0 +view_bobbing_amount (View bobbing factor) float 1.0 # Multiplier for fall bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. -fall_bobbing_amount (Fall bobbing) float 0.0 +fall_bobbing_amount (Fall bobbing factor) float 0.0 # 3D support. # Currently supported: @@ -518,6 +536,9 @@ desynchronize_mapblock_texture_animation (Desynchronize block animation) bool tr # Useful if there's something to be displayed right or left of hotbar. hud_hotbar_max_width (Maximum hotbar width) float 1.0 +# Modifies the size of the hudbar elements. +hud_scaling (HUD scale factor) float 1.0 + # Enables caching of facedir rotated meshes. enable_mesh_cache (Mesh cache) bool false @@ -548,9 +569,16 @@ ambient_occlusion_gamma (Ambient occlusion gamma) float 2.2 0.25 4.0 # Enables animation of inventory items. inventory_items_animations (Inventory items animations) bool false +# Android systems only: Tries to create inventory textures from meshes +# when no supported render was found. +inventory_image_hack (Inventory image hack) bool false + # Fraction of the visible distance at which fog starts to be rendered fog_start (Fog Start) float 0.4 0.0 0.99 +# Makes all liquids opaque +opaque_water (Opaque liquids) bool false + [**Menus] # Use a cloud animation for the main menu background. @@ -617,6 +645,10 @@ screenshot_quality (Screenshot quality) int 0 0 100 # Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens. screen_dpi (DPI) int 72 +# Windows systems only: Start Minetest with the command line window in the background. +# Contains the same information as the file debug.txt (default name). +enable_console (Enable console window) bool false + [*Sound] enable_sound (Sound) bool true @@ -729,6 +761,9 @@ show_statusline_on_connect (Status message on connection) bool true # Enable players getting damage and dying. enable_damage (Damage) bool false +# Enable creative mode for new created maps. +creative_mode (Creative) bool false + # A chosen map seed for a new map, leave empty for random. # Will be overridden when creating a new world in the main menu. fixed_map_seed (Fixed map seed) string @@ -972,6 +1007,7 @@ mgv5_cavern_threshold (Cavern threshold) float 0.7 mgv5_np_filler_depth (Filler depth noise) noise_params 0, 1, (150, 150, 150), 261, 4, 0.7, 2.0 # Variation of terrain vertical scale. +# When noise is < -0.55 terrain is near-flat. mgv5_np_factor (Factor noise) noise_params 0, 1, (250, 250, 250), 920381, 3, 0.45, 2.0 # Y-level of average terrain surface. @@ -1059,7 +1095,7 @@ mgv6_np_apple_trees (Apple trees noise) noise_params 0, 1, (100, 100, 100), 3429 # Floatlands are currently experimental and subject to change. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgv7_spflags (Mapgen v7 specific flags) flags mountains,ridges,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns +mgv7_spflags (Mapgen v7 specific flags) flags mountains,ridges,nofloatlands,caverns mountains,ridges,floatlands,caverns,nomountains,noridges,nofloatlands,nocaverns # Controls width of tunnels, a smaller value creates wider tunnels. mgv7_cave_width (Cave width) float 0.09 @@ -1137,7 +1173,7 @@ mgv7_np_cave2 (Cave2 noise) noise_params 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 # Occasional lakes and hills can be added to the flat world. # Flags that are not specified in the flag string are not modified from the default. # Flags starting with 'no' are used to explicitly disable them. -mgflat_spflags (Mapgen flat specific flags) flags lakes,hills,,nolakes,nohills +mgflat_spflags (Mapgen flat specific flags) flags nolakes,nohills lakes,hills,nolakes,nohills # Y of flat ground. mgflat_ground_level (Ground level) int 8 @@ -1349,7 +1385,6 @@ profiler.load (Load the game profiler) bool false profiler.default_report_format (Default report format) enum txt txt,csv,lua,json,json_pretty # The file path relative to your worldpath in which profiles will be saved to. -# profiler.report_path (Report path) string "" [***Instrumentation] diff --git a/minetest.conf.example b/minetest.conf.example index cfc66f168..9e9039bf2 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -211,6 +211,11 @@ # type: key # keymap_drop = KEY_KEY_Q +# Key to use view zoom when possible. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_zoom = KEY_KEY_Z + # Key for toggling the display of the HUD. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # type: key @@ -221,6 +226,11 @@ # type: key # keymap_toggle_chat = KEY_F2 +# Key for toggling the display of the large chat console. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_console = KEY_F10 + # Key for toggling the display of the fog. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # type: key @@ -298,7 +308,7 @@ # Enable Lua modding support on client. # This support is experimental and API can change. # type: bool -enable_client_modding (Client modding) bool false +# enable_client_modding = false # URL to the server list displayed in the Multiplayer Tab. # type: string @@ -350,6 +360,10 @@ enable_client_modding (Client modding) bool false # type: enum values: box, halo # node_highlighting = box +# Adds particles when digging a node. +# type: bool +# enable_particles = true + #### Filtering # Use mip mapping to scale textures. May slightly increase performance. @@ -393,10 +407,14 @@ enable_client_modding (Client modding) bool false #### Shaders # Shaders allow advanced visual effects and may increase performance on some video cards. -# Thy only work with the OpenGL video backend. +# This only works with the OpenGL video backend. # type: bool # enable_shaders = true +# Path to shader directory. If no path is defined, default location will be used. +# type: path +# shader_path = + ##### Tone Mapping # Enables filmic tone mapping @@ -439,7 +457,7 @@ enable_client_modding (Client modding) bool false # Strength of parallax. # type: float -# 3d_parallax_strength = 0.025 +# 3d_paralax_strength = 0.025 # Number of parallax occlusion iterations. # type: int @@ -545,6 +563,10 @@ enable_client_modding (Client modding) bool false # type: int # cloud_radius = 12 +# Enables view bobbing when walking. +# type: bool +# view_bobbing = true + # Multiplier for view bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. # type: float @@ -567,7 +589,7 @@ enable_client_modding (Client modding) bool false # 3d_mode = none # In-game chat console height, between 0.1 (10%) and 1.0 (100%). -# type: float +# type: float min: 0.1 max: 1 # console_height = 1.0 # In-game chat console background color (R,G,B). @@ -603,6 +625,10 @@ enable_client_modding (Client modding) bool false # type: float # hud_hotbar_max_width = 1.0 +# Modifies the size of the hudbar elements. +# type: float +# hud_scaling = 1.0 + # Enables caching of facedir rotated meshes. # type: bool # enable_mesh_cache = false @@ -641,10 +667,19 @@ enable_client_modding (Client modding) bool false # type: bool # inventory_items_animations = false +# Android systems only: Tries to create inventory textures from meshes +# when no supported render was found. +# type: bool +# inventory_image_hack = false + # Fraction of the visible distance at which fog starts to be rendered # type: float min: 0 max: 0.99 # fog_start = 0.4 +# Makes all liquids opaque +# type: bool +# opaque_water = false + ### Menus # Use a cloud animation for the main menu background. @@ -734,6 +769,11 @@ enable_client_modding (Client modding) bool false # type: int # screen_dpi = 72 +# Windows systems only: Start Minetest with the command line window in the background. +# Contains the same information as the file debug.txt (default name). +# type: bool +# enable_console = false + ## Sound # type: bool @@ -876,6 +916,10 @@ enable_client_modding (Client modding) bool false # type: bool # enable_damage = false +# Enable creative mode for new created maps. +# type: bool +# creative_mode = false + # A chosen map seed for a new map, leave empty for random. # Will be overridden when creating a new world in the main menu. # type: string @@ -1083,7 +1127,8 @@ enable_client_modding (Client modding) bool false # on the eye position of the player. This can reduce the number of blocks # sent to the client 50-80%. The client will not longer receive most invisible # so that the utility of noclip mode is reduced. -server_side_occlusion_culling = true +# type: bool +# server_side_occlusion_culling = true ## Mapgen @@ -1433,7 +1478,7 @@ server_side_occlusion_culling = true # type: float # mgflat_cave_width = 0.09 -# Terrain noise threshold for optional lakes. +# Terrain noise threshold for lakes. # Controls proportion of world area covered by lakes. # Adjust towards 0.0 for a larger proportion. # type: float @@ -1443,7 +1488,7 @@ server_side_occlusion_culling = true # type: float # mgflat_lake_steepness = 48.0 -# Terrain noise threshold for optional hills. +# Terrain noise threshold for hills. # Controls proportion of world area covered by hills. # Adjust towards 0.0 for a larger proportion. # type: float @@ -1678,7 +1723,6 @@ server_side_occlusion_culling = true # profiler.default_report_format = txt # The file path relative to your worldpath in which profiles will be saved to. -# # type: string # profiler.report_path = "" @@ -1794,3 +1838,4 @@ server_side_occlusion_culling = true # Print the engine's profiling data in regular intervals (in seconds). 0 = disable. Useful for developers. # type: int # profiler_print_interval = 0 + diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 52ff4c068..2a49a0eca 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -263,7 +263,6 @@ void set_default_settings(Settings *settings) settings->setDefault("creative_mode", "false"); settings->setDefault("show_statusline_on_connect", "true"); settings->setDefault("enable_damage", "true"); - settings->setDefault("give_initial_stuff", "false"); settings->setDefault("default_password", ""); settings->setDefault("default_privs", "interact, shout"); settings->setDefault("enable_pvp", "true"); -- cgit v1.2.3 From 0a8834608d21998bd05b899bd91ddc2196762926 Mon Sep 17 00:00:00 2001 From: number Zero Date: Thu, 12 Jan 2017 12:19:36 +0300 Subject: Hard-coded undersampling. Adds uniform undersampling for the 3D rendered scene. GUI elements are not undersampled, resulting in better playability for users with low-performance platforms with readable fonts and formspecs. The undersampling setting can be set to 0 (disabled), 2, 3, 4 pixels which translates into a resolution reduction of x4, x9 or x16, and is significant. --- builtin/settingtypes.txt | 5 +++++ minetest.conf.example | 6 +++++ src/defaultsettings.cpp | 1 + src/drawscene.cpp | 47 +++++++++++++++++++++++++++++++++------ src/settings_translation_file.cpp | 2 ++ 5 files changed, 54 insertions(+), 7 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index a3b91fe74..2c74d6c44 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -362,6 +362,11 @@ texture_min_size (Minimum texture size for filters) int 64 # when set to higher number than 0. fsaa (FSAA) enum 0 0,1,2,4,8,16 +# Undersampling is similar to using lower screen resolution, but it applies +# to the game world only, keeping the GUI intact. +# It should give significant performance boost at the cost of less detailed image. +undersampling (Undersampling) enum 0 0,2,3,4 + [***Shaders] # Shaders allow advanced visual effects and may increase performance on some video cards. diff --git a/minetest.conf.example b/minetest.conf.example index 9e9039bf2..d147ebfac 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -404,6 +404,12 @@ # type: enum values: 0, 1, 2, 4, 8, 16 # fsaa = 0 +# Undersampling is similar to using lower screen resolution, but it applies +# to the game world only, keeping the GUI intact. +# It should give significant performance boost at the cost of less detailed image. +# type: enum values: 0, 2, 3, 4 +# undersampling = 0 + #### Shaders # Shaders allow advanced visual effects and may increase performance on some video cards. diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 2a49a0eca..c6ced5931 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -108,6 +108,7 @@ void set_default_settings(Settings *settings) settings->setDefault("show_debug", "true"); #endif settings->setDefault("fsaa", "0"); + settings->setDefault("undersampling", "0"); settings->setDefault("enable_fog", "true"); settings->setDefault("fog_start", "0.4"); settings->setDefault("3d_mode", "none"); diff --git a/src/drawscene.cpp b/src/drawscene.cpp index 663c8828c..421b96f12 100644 --- a/src/drawscene.cpp +++ b/src/drawscene.cpp @@ -459,10 +459,37 @@ void draw_pageflip_3d_mode(Camera& camera, bool show_hud, #endif } -void draw_plain(Camera &camera, bool show_hud, Hud &hud, - video::IVideoDriver *driver, bool draw_wield_tool, - Client &client, gui::IGUIEnvironment *guienv) +// returns (size / coef), rounded upwards +inline int scaledown(int coef, int size) { + return (size + coef - 1) / coef; +} + +void draw_plain(Camera &camera, bool show_hud, + Hud &hud, video::IVideoDriver *driver, + scene::ISceneManager *smgr, const v2u32 &screensize, + bool draw_wield_tool, Client &client, gui::IGUIEnvironment *guienv, + video::SColor skycolor) +{ + // Undersampling-specific stuff + static video::ITexture *image = NULL; + static v2u32 last_pixelated_size = v2u32(0, 0); + int undersampling = g_settings->getU16("undersampling"); + v2u32 pixelated_size; + v2u32 dest_size; + if (undersampling > 0) { + pixelated_size = v2u32(scaledown(undersampling, screensize.X), + scaledown(undersampling, screensize.Y)); + dest_size = v2u32(undersampling * pixelated_size.X, undersampling * pixelated_size.Y); + if (pixelated_size != last_pixelated_size) { + init_texture(driver, pixelated_size, &image, "mt_drawimage_img1"); + last_pixelated_size = pixelated_size; + } + driver->setRenderTarget(image, true, true, skycolor); + } + + // Render + smgr->drawAll(); driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); if (show_hud) { hud.drawSelectionMesh(); @@ -470,10 +497,18 @@ void draw_plain(Camera &camera, bool show_hud, Hud &hud, camera.drawWieldedTool(); } } + + // Upscale lowres render + if (undersampling > 0) { + driver->setRenderTarget(0, true, true); + driver->draw2DImage(image, + irr::core::rect(0, 0, dest_size.X, dest_size.Y), + irr::core::rect(0, 0, pixelated_size.X, pixelated_size.Y)); + } } void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr, - Camera &camera, Client& client, LocalPlayer *player, Hud &hud, + Camera &camera, Client &client, LocalPlayer *player, Hud &hud, Minimap &mapper, gui::IGUIEnvironment *guienv, const v2u32 &screensize, const video::SColor &skycolor, bool show_hud, bool show_minimap) @@ -496,8 +531,6 @@ void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr, const std::string &draw_mode = g_settings->get("3d_mode"); - smgr->drawAll(); - if (draw_mode == "anaglyph") { draw_anaglyph_3d_mode(camera, show_hud, hud, driver, @@ -531,7 +564,7 @@ void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr, } else { draw_plain(camera, show_hud, hud, driver, - draw_wield_tool, client, guienv); + smgr, screensize, draw_wield_tool, client, guienv, skycolor); } /* diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp index 9ec21c415..93f2688d7 100644 --- a/src/settings_translation_file.cpp +++ b/src/settings_translation_file.cpp @@ -152,6 +152,8 @@ fake_function() { gettext("When using bilinear/trilinear/anisotropic filters, low-resolution textures\ncan be blurred, so automatically upscale them with nearest-neighbor\ninterpolation to preserve crisp pixels. This sets the minimum texture size\nfor the upscaled textures; higher values look sharper, but require more\nmemory. Powers of 2 are recommended. Setting this higher than 1 may not\nhave a visible effect unless bilinear/trilinear/anisotropic filtering is\nenabled."); gettext("FSAA"); gettext("Experimental option, might cause visible spaces between blocks\nwhen set to higher number than 0."); + gettext("Undersampling"); + gettext("Undersampling is similar to using lower screen resolution, but it applies\nto the game world only, keeping the GUI intact.\nIt should give significant performance boost at the cost of less detailed image."); gettext("Shaders"); gettext("Shaders"); gettext("Shaders allow advanced visual effects and may increase performance on some video cards.\nThy only work with the OpenGL video backend."); -- cgit v1.2.3 From 04cc9de8f2fbcb11f133c88f02fc11504b3ea6f3 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 15 Apr 2017 10:55:52 +0300 Subject: MeshUpdateQueue: Add a MapBlock cache that minimizes the amount of MapBlock copying done in the main thread Cache size is configurable by the meshgen_block_cache_size (default 20 MB). New profiler stats: - MeshUpdateQueue MapBlock cache hit % - MeshUpdateQueue MapBlock cache size kB Removes one type of stutter that was seen on the client when received MapBlocks were being handled. (the "MeshMakeData::fill" stutter) Kind of related to at least #5239 Originally preceded by these commits, now includes them: - Move the mesh generator thread into src/mesh_generator_thread.{cpp,h} - mesh_generator_thread.cpp: Update code style - MeshUpdateThread: Modify interface to house a different implementation: Actual functionality will be changed by next commits. - MeshMakeData: Add fillBlockData() interface (so that caller can fill in stuff from eg. a MapBlock cache) --- build/android/jni/Android.mk | 1 + builtin/settingtypes.txt | 5 + minetest.conf.example | 6 + src/CMakeLists.txt | 1 + src/client.cpp | 178 ++--------------------- src/client.h | 83 +---------- src/defaultsettings.cpp | 1 + src/mapblock.h | 5 + src/mapblock_mesh.cpp | 54 +++---- src/mapblock_mesh.h | 6 + src/mesh_generator_thread.cpp | 329 ++++++++++++++++++++++++++++++++++++++++++ src/mesh_generator_thread.h | 135 +++++++++++++++++ 12 files changed, 526 insertions(+), 278 deletions(-) create mode 100644 src/mesh_generator_thread.cpp create mode 100644 src/mesh_generator_thread.h (limited to 'minetest.conf.example') diff --git a/build/android/jni/Android.mk b/build/android/jni/Android.mk index fd104db06..2929eaba1 100644 --- a/build/android/jni/Android.mk +++ b/build/android/jni/Android.mk @@ -185,6 +185,7 @@ LOCAL_SRC_FILES := \ jni/src/mapnode.cpp \ jni/src/mapsector.cpp \ jni/src/mesh.cpp \ + jni/src/mesh_generator_thread.cpp \ jni/src/metadata.cpp \ jni/src/mg_biome.cpp \ jni/src/mg_decoration.cpp \ diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 2c74d6c44..5dc48c00e 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -551,6 +551,11 @@ enable_mesh_cache (Mesh cache) bool false # down the rate of mesh updates, thus reducing jitter on slower clients. mesh_generation_interval (Mapblock mesh generation delay) int 0 0 50 +# Size of the MapBlock cache of the mesh generator. Increasing this will +# increase the cache hit %, reducing the data being copied from the main +# thread, thus reducing jitter. +meshgen_block_cache_size (Mapblock mesh generator's MapBlock cache size MB) int 20 0 1000 + # Enables minimap. enable_minimap (Minimap) bool true diff --git a/minetest.conf.example b/minetest.conf.example index d147ebfac..9b50a775d 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -644,6 +644,12 @@ # type: int min: 0 max: 50 # mesh_generation_interval = 0 +# Size of the MapBlock cache of the mesh generator. Increasing this will +# increase the cache hit %, reducing the data being copied from the main +# thread, thus reducing jitter. +# type: int min: 0 max: 1000 +# meshgen_block_cache_size = 20 + # Enables minimap. # type: bool # enable_minimap = true diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index edb291545..37f72a44d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -522,6 +522,7 @@ set(client_SRCS main.cpp mapblock_mesh.cpp mesh.cpp + mesh_generator_thread.cpp minimap.cpp particles.cpp shader.cpp diff --git a/src/client.cpp b/src/client.cpp index 5ca51bd9c..7b962cd94 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -50,147 +50,6 @@ with this program; if not, write to the Free Software Foundation, Inc., extern gui::IGUIEnvironment* guienv; -/* - QueuedMeshUpdate -*/ - -QueuedMeshUpdate::QueuedMeshUpdate(): - p(-1337,-1337,-1337), - data(NULL), - ack_block_to_server(false) -{ -} - -QueuedMeshUpdate::~QueuedMeshUpdate() -{ - if(data) - delete data; -} - -/* - MeshUpdateQueue -*/ - -MeshUpdateQueue::MeshUpdateQueue() -{ -} - -MeshUpdateQueue::~MeshUpdateQueue() -{ - MutexAutoLock lock(m_mutex); - - for(std::vector::iterator - i = m_queue.begin(); - i != m_queue.end(); ++i) - { - QueuedMeshUpdate *q = *i; - delete q; - } -} - -/* - peer_id=0 adds with nobody to send to -*/ -void MeshUpdateQueue::addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_server, bool urgent) -{ - DSTACK(FUNCTION_NAME); - - assert(data); // pre-condition - - MutexAutoLock lock(m_mutex); - - if(urgent) - m_urgents.insert(p); - - /* - Find if block is already in queue. - If it is, update the data and quit. - */ - for(std::vector::iterator - i = m_queue.begin(); - i != m_queue.end(); ++i) - { - QueuedMeshUpdate *q = *i; - if(q->p == p) - { - if(q->data) - delete q->data; - q->data = data; - if(ack_block_to_server) - q->ack_block_to_server = true; - return; - } - } - - /* - Add the block - */ - QueuedMeshUpdate *q = new QueuedMeshUpdate; - q->p = p; - q->data = data; - q->ack_block_to_server = ack_block_to_server; - m_queue.push_back(q); -} - -// Returned pointer must be deleted -// Returns NULL if queue is empty -QueuedMeshUpdate *MeshUpdateQueue::pop() -{ - MutexAutoLock lock(m_mutex); - - bool must_be_urgent = !m_urgents.empty(); - for(std::vector::iterator - i = m_queue.begin(); - i != m_queue.end(); ++i) - { - QueuedMeshUpdate *q = *i; - if(must_be_urgent && m_urgents.count(q->p) == 0) - continue; - m_queue.erase(i); - m_urgents.erase(q->p); - return q; - } - return NULL; -} - -/* - MeshUpdateThread -*/ - -MeshUpdateThread::MeshUpdateThread() : UpdateThread("Mesh") -{ - m_generation_interval = g_settings->getU16("mesh_generation_interval"); - m_generation_interval = rangelim(m_generation_interval, 0, 50); -} - -void MeshUpdateThread::enqueueUpdate(v3s16 p, MeshMakeData *data, - bool ack_block_to_server, bool urgent) -{ - m_queue_in.addBlock(p, data, ack_block_to_server, urgent); - deferUpdate(); -} - -void MeshUpdateThread::doUpdate() -{ - QueuedMeshUpdate *q; - while ((q = m_queue_in.pop())) { - if (m_generation_interval) - sleep_ms(m_generation_interval); - ScopeProfiler sp(g_profiler, "Client: Mesh making"); - - MapBlockMesh *mesh_new = new MapBlockMesh(q->data, m_camera_offset); - - MeshUpdateResult r; - r.p = q->p; - r.mesh = mesh_new; - r.ack_block_to_server = q->ack_block_to_server; - - m_queue_out.push_back(r); - - delete q; - } -} - /* Client */ @@ -220,7 +79,7 @@ Client::Client( m_nodedef(nodedef), m_sound(sound), m_event(event), - m_mesh_update_thread(), + m_mesh_update_thread(this), m_env( new ClientMap(this, control, device->getSceneManager()->getRootSceneNode(), @@ -269,12 +128,6 @@ Client::Client( m_minimap = new Minimap(device, this); m_cache_save_interval = g_settings->getU16("server_map_save_interval"); - m_cache_smooth_lighting = g_settings->getBool("smooth_lighting"); - m_cache_enable_shaders = g_settings->getBool("enable_shaders"); - m_cache_use_tangent_vertices = m_cache_enable_shaders && ( - g_settings->getBool("enable_bumpmapping") || - g_settings->getBool("enable_parallax_occlusion")); - m_modding_enabled = g_settings->getBool("enable_client_modding"); m_script = new ClientScripting(this); m_env.setScript(m_script); @@ -1605,6 +1458,11 @@ int Client::getCrackLevel() return m_crack_level; } +v3s16 Client::getCrackPos() +{ + return m_crack_pos; +} + void Client::setCrack(int level, v3s16 pos) { int old_crack_level = m_crack_level; @@ -1670,28 +1528,14 @@ void Client::typeChatMessage(const std::wstring &message) void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent) { + // Check if the block exists to begin with. In the case when a non-existing + // neighbor is automatically added, it may not. In that case we don't want + // to tell the mesh update thread about it. MapBlock *b = m_env.getMap().getBlockNoCreateNoEx(p); - if(b == NULL) + if (b == NULL) return; - /* - Create a task to update the mesh of the block - */ - - MeshMakeData *data = new MeshMakeData(this, m_cache_enable_shaders, - m_cache_use_tangent_vertices); - - { - //TimeTaker timer("data fill"); - // Release: ~0ms - // Debug: 1-6ms, avg=2ms - data->fill(b); - data->setCrack(m_crack_level, m_crack_pos); - data->setSmoothLighting(m_cache_smooth_lighting); - } - - // Add task to queue - m_mesh_update_thread.enqueueUpdate(p, data, ack_to_server, urgent); + m_mesh_update_thread.updateBlock(&m_env.getMap(), p, ack_to_server, urgent); } void Client::addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server, bool urgent) diff --git a/src/client.h b/src/client.h index e565acd93..e7fcb597d 100644 --- a/src/client.h +++ b/src/client.h @@ -36,6 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "particles.h" #include "mapnode.h" #include "tileanimation.h" +#include "mesh_generator_thread.h" struct MeshMakeData; class MapBlockMesh; @@ -54,88 +55,12 @@ struct MinimapMapblock; class Camera; class NetworkPacket; -struct QueuedMeshUpdate -{ - v3s16 p; - MeshMakeData *data; - bool ack_block_to_server; - - QueuedMeshUpdate(); - ~QueuedMeshUpdate(); -}; - enum LocalClientState { LC_Created, LC_Init, LC_Ready }; -/* - A thread-safe queue of mesh update tasks -*/ -class MeshUpdateQueue -{ -public: - MeshUpdateQueue(); - - ~MeshUpdateQueue(); - - /* - peer_id=0 adds with nobody to send to - */ - void addBlock(v3s16 p, MeshMakeData *data, - bool ack_block_to_server, bool urgent); - - // Returned pointer must be deleted - // Returns NULL if queue is empty - QueuedMeshUpdate * pop(); - - u32 size() - { - MutexAutoLock lock(m_mutex); - return m_queue.size(); - } - -private: - std::vector m_queue; - std::set m_urgents; - Mutex m_mutex; -}; - -struct MeshUpdateResult -{ - v3s16 p; - MapBlockMesh *mesh; - bool ack_block_to_server; - - MeshUpdateResult(): - p(-1338,-1338,-1338), - mesh(NULL), - ack_block_to_server(false) - { - } -}; - -class MeshUpdateThread : public UpdateThread -{ -private: - MeshUpdateQueue m_queue_in; - int m_generation_interval; - -protected: - virtual void doUpdate(); - -public: - - MeshUpdateThread(); - - void enqueueUpdate(v3s16 p, MeshMakeData *data, - bool ack_block_to_server, bool urgent); - MutexedQueue m_queue_out; - - v3s16 m_camera_offset; -}; - enum ClientEventType { CE_NONE, @@ -471,6 +396,7 @@ public: float getAnimationTime(); int getCrackLevel(); + v3s16 getCrackPos(); void setCrack(int level, v3s16 pos); u16 getHP(); @@ -726,11 +652,6 @@ private: IntervalLimiter m_localdb_save_interval; u16 m_cache_save_interval; - // TODO: Add callback to update these when g_settings changes - bool m_cache_smooth_lighting; - bool m_cache_enable_shaders; - bool m_cache_use_tangent_vertices; - ClientScripting *m_script; bool m_modding_enabled; UNORDERED_MAP m_mod_storages; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index c6ced5931..573b5e2d8 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -39,6 +39,7 @@ void set_default_settings(Settings *settings) settings->setDefault("sound_volume", "0.8"); settings->setDefault("enable_mesh_cache", "false"); settings->setDefault("mesh_generation_interval", "0"); + settings->setDefault("meshgen_block_cache_size", "20"); settings->setDefault("enable_vbo", "true"); settings->setDefault("free_move", "false"); settings->setDefault("fast_move", "false"); diff --git a/src/mapblock.h b/src/mapblock.h index 7ff613fe8..8816dc817 100644 --- a/src/mapblock.h +++ b/src/mapblock.h @@ -154,6 +154,11 @@ public: raiseModified(MOD_STATE_WRITE_NEEDED, MOD_REASON_REALLOCATE); } + MapNode* getData() + { + return data; + } + //// //// Modification tracking methods //// diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index eddb061b4..933dfc32a 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -48,49 +48,43 @@ MeshMakeData::MeshMakeData(Client *client, bool use_shaders, m_use_tangent_vertices(use_tangent_vertices) {} -void MeshMakeData::fill(MapBlock *block) +void MeshMakeData::fillBlockDataBegin(const v3s16 &blockpos) { - m_blockpos = block->getPos(); + m_blockpos = blockpos; v3s16 blockpos_nodes = m_blockpos*MAP_BLOCKSIZE; - /* - Copy data - */ - - // Allocate this block + neighbors m_vmanip.clear(); VoxelArea voxel_area(blockpos_nodes - v3s16(1,1,1) * MAP_BLOCKSIZE, blockpos_nodes + v3s16(1,1,1) * MAP_BLOCKSIZE*2-v3s16(1,1,1)); m_vmanip.addArea(voxel_area); +} - { - //TimeTaker timer("copy central block data"); - // 0ms +void MeshMakeData::fillBlockData(const v3s16 &block_offset, MapNode *data) +{ + v3s16 data_size(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE); + VoxelArea data_area(v3s16(0,0,0), data_size - v3s16(1,1,1)); - // Copy our data - block->copyTo(m_vmanip); - } - { - //TimeTaker timer("copy neighbor block data"); - // 0ms + v3s16 bp = m_blockpos + block_offset; + v3s16 blockpos_nodes = bp * MAP_BLOCKSIZE; + m_vmanip.copyFrom(data, data_area, v3s16(0,0,0), blockpos_nodes, data_size); +} + +void MeshMakeData::fill(MapBlock *block) +{ + fillBlockDataBegin(block->getPos()); - /* - Copy neighbors. This is lightning fast. - Copying only the borders would be *very* slow. - */ + fillBlockData(v3s16(0,0,0), block->getData()); - // Get map - Map *map = block->getParent(); + // Get map for reading neigbhor blocks + Map *map = block->getParent(); - for(u16 i=0; i<26; i++) - { - const v3s16 &dir = g_26dirs[i]; - v3s16 bp = m_blockpos + dir; - MapBlock *b = map->getBlockNoCreateNoEx(bp); - if(b) - b->copyTo(m_vmanip); - } + for (u16 i=0; i<26; i++) { + const v3s16 &dir = g_26dirs[i]; + v3s16 bp = m_blockpos + dir; + MapBlock *b = map->getBlockNoCreateNoEx(bp); + if(b) + fillBlockData(dir, b->getData()); } } diff --git a/src/mapblock_mesh.h b/src/mapblock_mesh.h index 916703f3e..25c699e1c 100644 --- a/src/mapblock_mesh.h +++ b/src/mapblock_mesh.h @@ -52,6 +52,12 @@ struct MeshMakeData MeshMakeData(Client *client, bool use_shaders, bool use_tangent_vertices = false); + /* + Copy block data manually (to allow optimizations by the caller) + */ + void fillBlockDataBegin(const v3s16 &blockpos); + void fillBlockData(const v3s16 &block_offset, MapNode *data); + /* Copy central data directly from block, and other data from parent of block. diff --git a/src/mesh_generator_thread.cpp b/src/mesh_generator_thread.cpp new file mode 100644 index 000000000..126bf6327 --- /dev/null +++ b/src/mesh_generator_thread.cpp @@ -0,0 +1,329 @@ +/* +Minetest +Copyright (C) 2013, 2017 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "mesh_generator_thread.h" +#include "settings.h" +#include "profiler.h" +#include "client.h" +#include "mapblock.h" +#include "map.h" + +/* + CachedMapBlockData +*/ + +CachedMapBlockData::CachedMapBlockData(): + p(-1337,-1337,-1337), + data(NULL), + refcount_from_queue(0), + last_used_timestamp(time(0)) +{ +} + +CachedMapBlockData::~CachedMapBlockData() +{ + assert(refcount_from_queue == 0); + + if (data) + delete[] data; +} + +/* + QueuedMeshUpdate +*/ + +QueuedMeshUpdate::QueuedMeshUpdate(): + p(-1337,-1337,-1337), + ack_block_to_server(false), + urgent(false), + crack_level(-1), + crack_pos(0,0,0), + data(NULL) +{ +} + +QueuedMeshUpdate::~QueuedMeshUpdate() +{ + if (data) + delete data; +} + +/* + MeshUpdateQueue +*/ + +MeshUpdateQueue::MeshUpdateQueue(Client *client): + m_client(client) +{ + m_cache_enable_shaders = g_settings->getBool("enable_shaders"); + m_cache_use_tangent_vertices = m_cache_enable_shaders && ( + g_settings->getBool("enable_bumpmapping") || + g_settings->getBool("enable_parallax_occlusion")); + m_cache_smooth_lighting = g_settings->getBool("smooth_lighting"); + m_meshgen_block_cache_size = g_settings->getS32("meshgen_block_cache_size"); +} + +MeshUpdateQueue::~MeshUpdateQueue() +{ + MutexAutoLock lock(m_mutex); + + for (std::vector::iterator i = m_queue.begin(); + i != m_queue.end(); ++i) { + QueuedMeshUpdate *q = *i; + delete q; + } +} + +void MeshUpdateQueue::addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent) +{ + DSTACK(FUNCTION_NAME); + + MutexAutoLock lock(m_mutex); + + cleanupCache(); + + /* + Cache the block data (force-update the center block, don't update the + neighbors but get them if they aren't already cached) + */ + std::vector cached_blocks; + size_t cache_hit_counter = 0; + cached_blocks.reserve(3*3*3); + v3s16 dp; + for (dp.X = -1; dp.X <= 1; dp.X++) + for (dp.Y = -1; dp.Y <= 1; dp.Y++) + for (dp.Z = -1; dp.Z <= 1; dp.Z++) { + v3s16 p1 = p + dp; + CachedMapBlockData *cached_block; + if (dp == v3s16(0, 0, 0)) + cached_block = cacheBlock(map, p1, FORCE_UPDATE); + else + cached_block = cacheBlock(map, p1, SKIP_UPDATE_IF_ALREADY_CACHED, + &cache_hit_counter); + cached_blocks.push_back(cached_block); + } + g_profiler->avg("MeshUpdateQueue MapBlock cache hit %", + 100.0f * cache_hit_counter / cached_blocks.size()); + + /* + Mark the block as urgent if requested + */ + if (urgent) + m_urgents.insert(p); + + /* + Find if block is already in queue. + If it is, update the data and quit. + */ + for (std::vector::iterator i = m_queue.begin(); + i != m_queue.end(); ++i) { + QueuedMeshUpdate *q = *i; + if (q->p == p) { + // NOTE: We are not adding a new position to the queue, thus + // refcount_from_queue stays the same. + if(ack_block_to_server) + q->ack_block_to_server = true; + q->crack_level = m_client->getCrackLevel(); + q->crack_pos = m_client->getCrackPos(); + return; + } + } + + /* + Add the block + */ + QueuedMeshUpdate *q = new QueuedMeshUpdate; + q->p = p; + q->ack_block_to_server = ack_block_to_server; + q->crack_level = m_client->getCrackLevel(); + q->crack_pos = m_client->getCrackPos(); + m_queue.push_back(q); + + // This queue entry is a new reference to the cached blocks + for (size_t i=0; irefcount_from_queue++; + } +} + +// Returned pointer must be deleted +// Returns NULL if queue is empty +QueuedMeshUpdate *MeshUpdateQueue::pop() +{ + MutexAutoLock lock(m_mutex); + + bool must_be_urgent = !m_urgents.empty(); + for (std::vector::iterator i = m_queue.begin(); + i != m_queue.end(); ++i) { + QueuedMeshUpdate *q = *i; + if(must_be_urgent && m_urgents.count(q->p) == 0) + continue; + m_queue.erase(i); + m_urgents.erase(q->p); + fillDataFromMapBlockCache(q); + return q; + } + return NULL; +} + +CachedMapBlockData* MeshUpdateQueue::cacheBlock(Map *map, v3s16 p, UpdateMode mode, + size_t *cache_hit_counter) +{ + std::map::iterator it = + m_cache.find(p); + if (it != m_cache.end()) { + // Already in cache + CachedMapBlockData *cached_block = it->second; + if (mode == SKIP_UPDATE_IF_ALREADY_CACHED) { + if (cache_hit_counter) + (*cache_hit_counter)++; + return cached_block; + } + MapBlock *b = map->getBlockNoCreateNoEx(p); + if (b) { + if (cached_block->data == NULL) + cached_block->data = + new MapNode[MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE]; + memcpy(cached_block->data, b->getData(), + MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE * sizeof(MapNode)); + } else { + delete[] cached_block->data; + cached_block->data = NULL; + } + return cached_block; + } else { + // Not yet in cache + CachedMapBlockData *cached_block = new CachedMapBlockData(); + m_cache[p] = cached_block; + MapBlock *b = map->getBlockNoCreateNoEx(p); + if (b) { + cached_block->data = + new MapNode[MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE]; + memcpy(cached_block->data, b->getData(), + MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE * sizeof(MapNode)); + } + return cached_block; + } +} + +CachedMapBlockData* MeshUpdateQueue::getCachedBlock(const v3s16 &p) +{ + std::map::iterator it = m_cache.find(p); + if (it != m_cache.end()) { + return it->second; + } + return NULL; +} + +void MeshUpdateQueue::fillDataFromMapBlockCache(QueuedMeshUpdate *q) +{ + MeshMakeData *data = new MeshMakeData(m_client, m_cache_enable_shaders, + m_cache_use_tangent_vertices); + q->data = data; + + data->fillBlockDataBegin(q->p); + + int t_now = time(0); + + // Collect data for 3*3*3 blocks from cache + v3s16 dp; + for (dp.X = -1; dp.X <= 1; dp.X++) + for (dp.Y = -1; dp.Y <= 1; dp.Y++) + for (dp.Z = -1; dp.Z <= 1; dp.Z++) { + v3s16 p = q->p + dp; + CachedMapBlockData *cached_block = getCachedBlock(p); + if (cached_block) { + cached_block->refcount_from_queue--; + cached_block->last_used_timestamp = t_now; + if (cached_block->data) + data->fillBlockData(dp, cached_block->data); + } + } + + data->setCrack(q->crack_level, q->crack_pos); + data->setSmoothLighting(m_cache_smooth_lighting); +} + +void MeshUpdateQueue::cleanupCache() +{ + const int mapblock_kB = MAP_BLOCKSIZE * MAP_BLOCKSIZE * MAP_BLOCKSIZE * + sizeof(MapNode) / 1000; + g_profiler->avg("MeshUpdateQueue MapBlock cache size kB", + mapblock_kB * m_cache.size()); + + // The cache size is kept roughly below cache_soft_max_size, not letting + // anything get older than cache_seconds_max or deleted before 2 seconds. + const int cache_seconds_max = 10; + const int cache_soft_max_size = m_meshgen_block_cache_size * 1000 / mapblock_kB; + int cache_seconds = MYMAX(2, cache_seconds_max - + m_cache.size() / (cache_soft_max_size / cache_seconds_max)); + + int t_now = time(0); + + for (std::map::iterator it = m_cache.begin(); + it != m_cache.end(); ) { + CachedMapBlockData *cached_block = it->second; + if (cached_block->refcount_from_queue == 0 && + cached_block->last_used_timestamp < t_now - cache_seconds) { + m_cache.erase(it++); + } else { + ++it; + } + } +} + +/* + MeshUpdateThread +*/ + +MeshUpdateThread::MeshUpdateThread(Client *client): + UpdateThread("Mesh"), + m_queue_in(client) +{ + m_generation_interval = g_settings->getU16("mesh_generation_interval"); + m_generation_interval = rangelim(m_generation_interval, 0, 50); +} + +void MeshUpdateThread::updateBlock(Map *map, v3s16 p, bool ack_block_to_server, + bool urgent) +{ + // Allow the MeshUpdateQueue to do whatever it wants + m_queue_in.addBlock(map, p, ack_block_to_server, urgent); + deferUpdate(); +} + +void MeshUpdateThread::doUpdate() +{ + QueuedMeshUpdate *q; + while ((q = m_queue_in.pop())) { + if (m_generation_interval) + sleep_ms(m_generation_interval); + ScopeProfiler sp(g_profiler, "Client: Mesh making"); + + MapBlockMesh *mesh_new = new MapBlockMesh(q->data, m_camera_offset); + + MeshUpdateResult r; + r.p = q->p; + r.mesh = mesh_new; + r.ack_block_to_server = q->ack_block_to_server; + + m_queue_out.push_back(r); + + delete q; + } +} diff --git a/src/mesh_generator_thread.h b/src/mesh_generator_thread.h new file mode 100644 index 000000000..e74861862 --- /dev/null +++ b/src/mesh_generator_thread.h @@ -0,0 +1,135 @@ +/* +Minetest +Copyright (C) 2013, 2017 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program 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. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef MESH_GENERATOR_THREAD_HEADER +#define MESH_GENERATOR_THREAD_HEADER + +#include "mapblock_mesh.h" +#include "threading/mutex_auto_lock.h" +#include "util/thread.h" + +struct CachedMapBlockData +{ + v3s16 p; + MapNode *data; // A copy of the MapBlock's data member + int refcount_from_queue; + int last_used_timestamp; + + CachedMapBlockData(); + ~CachedMapBlockData(); +}; + +struct QueuedMeshUpdate +{ + v3s16 p; + bool ack_block_to_server; + bool urgent; + int crack_level; + v3s16 crack_pos; + MeshMakeData *data; // This is generated in MeshUpdateQueue::pop() + + QueuedMeshUpdate(); + ~QueuedMeshUpdate(); +}; + +/* + A thread-safe queue of mesh update tasks and a cache of MapBlock data +*/ +class MeshUpdateQueue +{ + enum UpdateMode { + FORCE_UPDATE, + SKIP_UPDATE_IF_ALREADY_CACHED, + }; +public: + MeshUpdateQueue(Client *client); + + ~MeshUpdateQueue(); + + // Caches the block at p and its neighbors (if needed) and queues a mesh + // update for the block at p + void addBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent); + + // Returned pointer must be deleted + // Returns NULL if queue is empty + QueuedMeshUpdate * pop(); + + u32 size() + { + MutexAutoLock lock(m_mutex); + return m_queue.size(); + } + +private: + Client *m_client; + std::vector m_queue; + std::set m_urgents; + std::map m_cache; + Mutex m_mutex; + + // TODO: Add callback to update these when g_settings changes + bool m_cache_enable_shaders; + bool m_cache_use_tangent_vertices; + bool m_cache_smooth_lighting; + int m_meshgen_block_cache_size; + + CachedMapBlockData* cacheBlock(Map *map, v3s16 p, UpdateMode mode, + size_t *cache_hit_counter=NULL); + CachedMapBlockData* getCachedBlock(const v3s16 &p); + void fillDataFromMapBlockCache(QueuedMeshUpdate *q); + void cleanupCache(); +}; + +struct MeshUpdateResult +{ + v3s16 p; + MapBlockMesh *mesh; + bool ack_block_to_server; + + MeshUpdateResult(): + p(-1338,-1338,-1338), + mesh(NULL), + ack_block_to_server(false) + { + } +}; + +class MeshUpdateThread : public UpdateThread +{ +public: + MeshUpdateThread(Client *client); + + // Caches the block at p and its neighbors (if needed) and queues a mesh + // update for the block at p + void updateBlock(Map *map, v3s16 p, bool ack_block_to_server, bool urgent); + + v3s16 m_camera_offset; + MutexedQueue m_queue_out; + +private: + MeshUpdateQueue m_queue_in; + + // TODO: Add callback to update these when g_settings changes + int m_generation_interval; + +protected: + virtual void doUpdate(); +}; + +#endif -- cgit v1.2.3 From cfe0291b131630a7400fdcf46b720bd70d8d0fa0 Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 17 Apr 2017 14:17:43 +0100 Subject: Conf.example: Move some lines to minetest.conf.example.extra Some information in conf.example cannot be generated from settingtypes.txt, moving it to a new file makes generating conf.example while preserving that information easier. Regenerate conf.example from settingtypes.txt. --- builtin/mainmenu/dlg_settings_advanced.lua | 6 --- minetest.conf.example | 37 +----------------- minetest.conf.example.extra | 63 ++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 42 deletions(-) create mode 100644 minetest.conf.example.extra (limited to 'minetest.conf.example') diff --git a/builtin/mainmenu/dlg_settings_advanced.lua b/builtin/mainmenu/dlg_settings_advanced.lua index 697babeb6..c63eb972e 100644 --- a/builtin/mainmenu/dlg_settings_advanced.lua +++ b/builtin/mainmenu/dlg_settings_advanced.lua @@ -769,10 +769,4 @@ end -- Generate minetest.conf.example and settings_translation_file.cpp --- *** Please note *** --- There is text in minetest.conf.example that will not be generated from --- settingtypes.txt but must be preserved: --- The documentation of mapgen noise parameter formats (title plus 16 lines) --- Noise parameter 'mgv5_np_ground' in group format (13 lines) - --assert(loadfile(core.get_builtin_path()..DIR_DELIM.."mainmenu"..DIR_DELIM.."generate_from_settingtypes.lua"))(parse_config_file(true, false)) diff --git a/minetest.conf.example b/minetest.conf.example index 9b50a775d..bdd6fd7f4 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -92,7 +92,7 @@ # joystick_id = 0 # The type of joystick -# type: enum values: auto,generic,xbox +# type: enum values: auto, generic, xbox # joystick_type = auto # The time in seconds it takes between repeated events @@ -1201,25 +1201,6 @@ # type: int # num_emerge_threads = 1 -#### Noise parameters and formats - -# Noise parameters can be specified as a set of positional values, for example: -# Offset, scale, (spread factors), seed offset, number of octaves, persistence, lacunarity -# mgv6_np_terrain_base = -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0 -# Or the group format can be used instead, for example: -# mgv6_np_terrain_base = { -# offset = -4, -# scale = 20, -# spread = (250, 250, 250), -# seed = 82341, -# octaves = 5, -# persistence = 0.6, -# lacunarity = 2.0, -# flags = "defaults" -# } -# Only the group format supports noise flags which are needed for eased noise. -# Mgv5 uses eased noise for np_ground so this is shown in group format below. - #### Biome API temperature and humidity noise parameters # Temperature variation for biomes. @@ -1287,22 +1268,6 @@ # type: noise_params # mgv5_np_cavern = 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 -# Noise parameter in group format, unsupported by advanced settings -# menu but settable in minetest.conf. -# See documentation of noise parameter formats above. -# 3D noise defining terrain. -# type: noise_params -# mgv5_np_ground = { -# offset = 0, -# scale = 40, -# spread = (80, 80, 80), -# seed = 983240, -# octaves = 4, -# persistence = 0.55, -# lacunarity = 2.0, -# flags = "eased" -# } - #### Mapgen v6 # Map generation attributes specific to Mapgen v6. diff --git a/minetest.conf.example.extra b/minetest.conf.example.extra new file mode 100644 index 000000000..7dd6c0939 --- /dev/null +++ b/minetest.conf.example.extra @@ -0,0 +1,63 @@ +# This file contains information (some of which was previously stored in +# minetest.conf.example) that cannot be automatically generated from +# builtin/settingtypes.txt. +# This file contains a list of settings and their default value for minetest.conf + +# By default, all the settings are commented and not functional. +# Uncomment settings by removing the preceding #. + +# minetest.conf is read by default from: +# ../minetest.conf +# ../../minetest.conf +# Any other path can be chosen by passing the path as a parameter +# to the program, eg. "minetest.exe --config ../minetest.conf.example". + +# Further documentation: +# http://wiki.minetest.net/ + + +# Mapgen + +# Noise parameters and formats + +# Noise parameters can be specified as a set of positional values, for example: +# +# Offset, scale, (x, y, z spread factors), seed offset, octaves, persistence, lacunarity +# mgv6_np_terrain_base = -4, 20, (250, 250, 250), 82341, 5, 0.6, 2.0 +# +# Or the group format can be used instead, for example: +# +# mgv6_np_terrain_base = { +# offset = -4, +# scale = 20, +# spread = (250, 250, 250), +# seed = 82341, +# octaves = 5, +# persistence = 0.6, +# lacunarity = 2.0, +# flags = "defaults" +# } +# +# The advanced settings menu does not yet support the group format. +# Only the group format supports noise flags which are needed for eased noise. +# Mgv5 uses eased noise for np_ground so this is shown in group format below +# and is not present in the advanced settings menu. + +# Mapgen v5 + +# Noise parameter in group format, unsupported by advanced settings menu but +# settable in minetest.conf. +# See documentation of noise parameter formats above. +# +# 3D noise defining terrain. +# type: noise_params +# mgv5_np_ground = { +# offset = 0, +# scale = 40, +# spread = (80, 80, 80), +# seed = 983240, +# octaves = 4, +# persistence = 0.55, +# lacunarity = 2.0, +# flags = "eased" +# } -- cgit v1.2.3 From db17225a976e20c6628afe70dd6b230673287b4d Mon Sep 17 00:00:00 2001 From: Louis Pearson Date: Tue, 25 Apr 2017 06:11:51 -0500 Subject: Footsteps without view bobbing (#5645) * Remove redundant view_bobbing setting Also fixes bug where disabling view_bobbing disables footstep sounds. * Removes redundant view_bobbing setting Setting view_bobbing amount to 0 is now the only way to turn view_bobbing on and off. Also fixed a bug where footstep sounds would not play when view_bobbing was disabled. --- builtin/settingtypes.txt | 5 +---- minetest.conf.example | 7 +------ po/be/minetest.po | 2 +- po/ca/minetest.po | 2 +- po/cs/minetest.po | 2 +- po/da/minetest.po | 2 +- po/de/minetest.po | 2 +- po/eo/minetest.po | 2 +- po/es/minetest.po | 2 +- po/et/minetest.po | 2 +- po/fr/minetest.po | 2 +- po/he/minetest.po | 2 +- po/hu/minetest.po | 2 +- po/id/minetest.po | 2 +- po/it/minetest.po | 2 +- po/ja/minetest.po | 2 +- po/jbo/minetest.po | 2 +- po/ko/minetest.po | 2 +- po/ky/minetest.po | 2 +- po/lt/minetest.po | 2 +- po/minetest.pot | 2 +- po/ms/minetest.po | 2 +- po/nb/minetest.po | 2 +- po/nl/minetest.po | 2 +- po/pl/minetest.po | 2 +- po/pt/minetest.po | 2 +- po/pt_BR/minetest.po | 2 +- po/ro/minetest.po | 2 +- po/ru/minetest.po | 2 +- po/sr_Cyrl/minetest.po | 2 +- po/sw/minetest.po | 2 +- po/tr/minetest.po | 2 +- po/uk/minetest.po | 2 +- po/zh_CN/minetest.po | 2 +- po/zh_TW/minetest.po | 2 +- src/camera.cpp | 9 +++------ src/camera.h | 1 - src/defaultsettings.cpp | 1 - src/settings_translation_file.cpp | 2 +- 39 files changed, 39 insertions(+), 52 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 5dc48c00e..29a96ab8e 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -492,10 +492,7 @@ cloud_height (Cloud height) int 120 # Values larger than 26 will start to produce sharp cutoffs at cloud area corners. cloud_radius (Cloud radius) int 12 -# Enables view bobbing when walking. -view_bobbing (Enable view bobbing) bool true - -# Multiplier for view bobbing. +# Enable view bobbing and amount of view bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. view_bobbing_amount (View bobbing factor) float 1.0 diff --git a/minetest.conf.example b/minetest.conf.example index bdd6fd7f4..ecbadb556 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -569,11 +569,7 @@ # type: int # cloud_radius = 12 -# Enables view bobbing when walking. -# type: bool -# view_bobbing = true - -# Multiplier for view bobbing. +# Enable view bobbing and amount of view bobbing. # For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double. # type: float # view_bobbing_amount = 1.0 @@ -1815,4 +1811,3 @@ # Print the engine's profiling data in regular intervals (in seconds). 0 = disable. Useful for developers. # type: int # profiler_print_interval = 0 - diff --git a/po/be/minetest.po b/po/be/minetest.po index 2466caea7..95a39697f 100644 --- a/po/be/minetest.po +++ b/po/be/minetest.po @@ -3670,7 +3670,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "Множнік калыхання пры праглядзе.\n" diff --git a/po/ca/minetest.po b/po/ca/minetest.po index eaf350f89..32b247ffc 100644 --- a/po/ca/minetest.po +++ b/po/ca/minetest.po @@ -3465,7 +3465,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/cs/minetest.po b/po/cs/minetest.po index c7d1720f0..917bc652b 100644 --- a/po/cs/minetest.po +++ b/po/cs/minetest.po @@ -3383,7 +3383,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/da/minetest.po b/po/da/minetest.po index b1aa649ba..c2bbd1477 100644 --- a/po/da/minetest.po +++ b/po/da/minetest.po @@ -3663,7 +3663,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/de/minetest.po b/po/de/minetest.po index a81fd0d56..ac51254cc 100644 --- a/po/de/minetest.po +++ b/po/de/minetest.po @@ -3746,7 +3746,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "Faktor für Auf- und Abbewegung (grafischer Effekt).\n" diff --git a/po/eo/minetest.po b/po/eo/minetest.po index adf29a0b6..71dd16892 100644 --- a/po/eo/minetest.po +++ b/po/eo/minetest.po @@ -3387,7 +3387,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/es/minetest.po b/po/es/minetest.po index 72438dc26..6cd0e184e 100644 --- a/po/es/minetest.po +++ b/po/es/minetest.po @@ -3526,7 +3526,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/et/minetest.po b/po/et/minetest.po index 94c9c7207..3cde4052b 100644 --- a/po/et/minetest.po +++ b/po/et/minetest.po @@ -3403,7 +3403,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/fr/minetest.po b/po/fr/minetest.po index f3aec72a6..9d1c0331a 100644 --- a/po/fr/minetest.po +++ b/po/fr/minetest.po @@ -3709,7 +3709,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "Facteur de mouvement de bras.\n" diff --git a/po/he/minetest.po b/po/he/minetest.po index 2e5367a9d..1b88f9111 100644 --- a/po/he/minetest.po +++ b/po/he/minetest.po @@ -3301,7 +3301,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/hu/minetest.po b/po/hu/minetest.po index a461b6a6b..b5824cc6b 100644 --- a/po/hu/minetest.po +++ b/po/hu/minetest.po @@ -3615,7 +3615,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/id/minetest.po b/po/id/minetest.po index 20464ab7a..4a3a24c48 100644 --- a/po/id/minetest.po +++ b/po/id/minetest.po @@ -3580,7 +3580,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/it/minetest.po b/po/it/minetest.po index b41f38cab..df5a7d0da 100644 --- a/po/it/minetest.po +++ b/po/it/minetest.po @@ -3720,7 +3720,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "Moltiplicatore per l'ondeggiamento visivo.\n" diff --git a/po/ja/minetest.po b/po/ja/minetest.po index f26036749..32e01a81b 100644 --- a/po/ja/minetest.po +++ b/po/ja/minetest.po @@ -3535,7 +3535,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/jbo/minetest.po b/po/jbo/minetest.po index 12ac80a39..749d53c35 100644 --- a/po/jbo/minetest.po +++ b/po/jbo/minetest.po @@ -3348,7 +3348,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/ko/minetest.po b/po/ko/minetest.po index 9bee4ee70..34bc7ddec 100644 --- a/po/ko/minetest.po +++ b/po/ko/minetest.po @@ -3507,7 +3507,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "화면 흔들림 멀티플라이어\n" diff --git a/po/ky/minetest.po b/po/ky/minetest.po index 72c729f8d..52704f78d 100644 --- a/po/ky/minetest.po +++ b/po/ky/minetest.po @@ -3403,7 +3403,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/lt/minetest.po b/po/lt/minetest.po index 7556e0309..c00c0df84 100644 --- a/po/lt/minetest.po +++ b/po/lt/minetest.po @@ -3383,7 +3383,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/minetest.pot b/po/minetest.pot index 46a74b448..1dddd0a71 100644 --- a/po/minetest.pot +++ b/po/minetest.pot @@ -2279,7 +2279,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/ms/minetest.po b/po/ms/minetest.po index 97f7a75f3..e53039522 100644 --- a/po/ms/minetest.po +++ b/po/ms/minetest.po @@ -2481,7 +2481,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/nb/minetest.po b/po/nb/minetest.po index 28bcb3f90..d3a8bdc67 100644 --- a/po/nb/minetest.po +++ b/po/nb/minetest.po @@ -3314,7 +3314,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/nl/minetest.po b/po/nl/minetest.po index 68e3e7b6d..be29ac829 100644 --- a/po/nl/minetest.po +++ b/po/nl/minetest.po @@ -3719,7 +3719,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "Vermenigvuldigingsfactor van loopbeweging.\n" diff --git a/po/pl/minetest.po b/po/pl/minetest.po index 8af82c0d6..0bf0ea84f 100644 --- a/po/pl/minetest.po +++ b/po/pl/minetest.po @@ -3674,7 +3674,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/pt/minetest.po b/po/pt/minetest.po index cef144845..992d0d608 100644 --- a/po/pt/minetest.po +++ b/po/pt/minetest.po @@ -3509,7 +3509,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/pt_BR/minetest.po b/po/pt_BR/minetest.po index 76d473a96..648b13a1c 100644 --- a/po/pt_BR/minetest.po +++ b/po/pt_BR/minetest.po @@ -3711,7 +3711,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "Multiplicador para sacudir a exibição.\n" diff --git a/po/ro/minetest.po b/po/ro/minetest.po index a9efb035f..4b0a724ea 100644 --- a/po/ro/minetest.po +++ b/po/ro/minetest.po @@ -3429,7 +3429,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/ru/minetest.po b/po/ru/minetest.po index 4406ec5a0..c3f2465a3 100644 --- a/po/ru/minetest.po +++ b/po/ru/minetest.po @@ -3628,7 +3628,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/sr_Cyrl/minetest.po b/po/sr_Cyrl/minetest.po index 0a0078f23..2d8739639 100644 --- a/po/sr_Cyrl/minetest.po +++ b/po/sr_Cyrl/minetest.po @@ -3359,7 +3359,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/sw/minetest.po b/po/sw/minetest.po index abf0da24d..b33e622aa 100644 --- a/po/sw/minetest.po +++ b/po/sw/minetest.po @@ -3644,7 +3644,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "Mengi kwa ajili ya Mwoneko kando.\n" diff --git a/po/tr/minetest.po b/po/tr/minetest.po index 707ce11d9..5db7287d4 100644 --- a/po/tr/minetest.po +++ b/po/tr/minetest.po @@ -3477,7 +3477,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/uk/minetest.po b/po/uk/minetest.po index 0035c792f..5271f4a5d 100644 --- a/po/uk/minetest.po +++ b/po/uk/minetest.po @@ -3350,7 +3350,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/zh_CN/minetest.po b/po/zh_CN/minetest.po index 410d98082..0503513e9 100644 --- a/po/zh_CN/minetest.po +++ b/po/zh_CN/minetest.po @@ -3421,7 +3421,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" diff --git a/po/zh_TW/minetest.po b/po/zh_TW/minetest.po index 7718ae462..55716950d 100644 --- a/po/zh_TW/minetest.po +++ b/po/zh_TW/minetest.po @@ -3608,7 +3608,7 @@ msgstr "" #: src/settings_translation_file.cpp msgid "" -"Multiplier for view bobbing.\n" +"Enable view bobbing and amount of view bobbing.\n" "For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double." msgstr "" "視野晃動的倍數。\n" diff --git a/src/camera.cpp b/src/camera.cpp index 7e83dadeb..b119bbfbb 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -102,7 +102,6 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control, m_cache_view_bobbing_amount = g_settings->getFloat("view_bobbing_amount"); m_cache_fov = g_settings->getFloat("fov"); m_cache_zoom_fov = g_settings->getFloat("zoom_fov"); - m_cache_view_bobbing = g_settings->getBool("view_bobbing"); m_nametags.clear(); } @@ -280,8 +279,8 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, v3f rel_cam_target = v3f(0,0,1); v3f rel_cam_up = v3f(0,1,0); - if (m_view_bobbing_anim != 0 && m_camera_mode < CAMERA_MODE_THIRD) - { + if (m_cache_view_bobbing_amount != 0.0f && m_view_bobbing_anim != 0.0f && + m_camera_mode < CAMERA_MODE_THIRD) { f32 bobfrac = my_modf(m_view_bobbing_anim * 2); f32 bobdir = (m_view_bobbing_anim < 0.5) ? 1.0 : -1.0; @@ -467,9 +466,7 @@ void Camera::update(LocalPlayer* player, f32 frametime, f32 busytime, const bool swimming = (movement_XZ || player->swimming_vertical) && player->in_liquid; const bool climbing = movement_Y && player->is_climbing; if ((walking || swimming || climbing) && - m_cache_view_bobbing && - (!g_settings->getBool("free_move") || !m_client->checkLocalPrivilege("fly"))) - { + (!g_settings->getBool("free_move") || !m_client->checkLocalPrivilege("fly"))) { // Start animation m_view_bobbing_state = 1; m_view_bobbing_speed = MYMIN(speed.getLength(), 70); diff --git a/src/camera.h b/src/camera.h index f57efdf10..e4c1d0b25 100644 --- a/src/camera.h +++ b/src/camera.h @@ -231,7 +231,6 @@ private: f32 m_cache_view_bobbing_amount; f32 m_cache_fov; f32 m_cache_zoom_fov; - bool m_cache_view_bobbing; std::list m_nametags; }; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 573b5e2d8..d45e386cf 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -171,7 +171,6 @@ void set_default_settings(Settings *settings) // Effects settings->setDefault("directional_colored_fog", "true"); - settings->setDefault("view_bobbing", "true"); settings->setDefault("inventory_items_animations", "false"); settings->setDefault("mip_map", "false"); settings->setDefault("anisotropic_filter", "false"); diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp index d34665181..47601135d 100644 --- a/src/settings_translation_file.cpp +++ b/src/settings_translation_file.cpp @@ -242,7 +242,7 @@ fake_function() { gettext("Enable view bobbing"); gettext("Enables view bobbing when walking."); gettext("View bobbing factor"); - gettext("Multiplier for view bobbing.\nFor example: 0 for no view bobbing; 1.0 for normal; 2.0 for double."); + gettext("Enable view bobbing and amount of view bobbing.\nFor example: 0 for no view bobbing; 1.0 for normal; 2.0 for double."); gettext("Fall bobbing factor"); gettext("Multiplier for fall bobbing.\nFor example: 0 for no view bobbing; 1.0 for normal; 2.0 for double."); gettext("3D mode"); -- cgit v1.2.3 From 21e0a049f81eb0d34adaf45646b11569eeadec52 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Fri, 5 May 2017 13:47:11 +0200 Subject: Save minetest screen width/height options when modified (#5683) * Save minetest screen width/height options when modified * Add autosave_screensize setting (default true) * Fix @SmallJoker comments --- builtin/mainmenu/tab_settings.lua | 9 ++++++++- builtin/settingtypes.txt | 3 +++ minetest.conf.example | 4 ++++ src/defaultsettings.cpp | 1 + src/game.cpp | 16 ++++++++++++++++ src/guiEngine.cpp | 20 ++++++++++++++++++-- 6 files changed, 50 insertions(+), 3 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index e59572a41..8a97d8334 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -190,7 +190,7 @@ local function formspec(tabview, name, tabdata) .. getSettingIndex.NodeHighlighting() .. "]" .. "dropdown[0.25,3.6;3.3;dd_leaves_style;" .. dd_options.leaves[1] .. ";" .. getSettingIndex.Leaves() .. "]" .. - "box[3.75,0;3.75,3.45;#999999]" .. + "box[3.75,0;3.75,4.45;#999999]" .. "label[3.85,0.1;" .. fgettext("Texturing:") .. "]" .. "dropdown[3.85,0.55;3.85;dd_filters;" .. dd_options.filters[1] .. ";" .. getSettingIndex.Filter() .. "]" .. @@ -199,6 +199,9 @@ local function formspec(tabview, name, tabdata) "label[3.85,2.15;" .. fgettext("Antialiasing:") .. "]" .. "dropdown[3.85,2.6;3.85;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";" .. getSettingIndex.Antialiasing() .. "]" .. + "label[3.85,3.45;" .. fgettext("Screen:") .. "]" .. + "checkbox[3.85,3.6;cb_autosave_screensize;" .. fgettext("Autosave screen size") .. ";" + .. dump(core.setting_getbool("autosave_screensize")) .. "]" .. "box[7.75,0;4,4.4;#999999]" .. "checkbox[8,0;cb_shaders;" .. fgettext("Shaders") .. ";" .. dump(core.setting_getbool("enable_shaders")) .. "]" @@ -290,6 +293,10 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) core.setting_set("connected_glass", fields["cb_connected_glass"]) return true end + if fields["cb_autosave_screensize"] then + core.setting_set("autosave_screensize", fields["cb_autosave_screensize"]) + return true + end if fields["cb_shaders"] then if (core.setting_get("video_driver") == "direct3d8" or core.setting_get("video_driver") == "direct3d9") then diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 29a96ab8e..4b82a1e0e 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -459,6 +459,9 @@ screenW (Screen width) int 800 # Height component of the initial window size. screenH (Screen height) int 600 +# Save window size automatically when modified. +autosave_screensize (Autosave Screen Size) bool true + # Fullscreen mode. fullscreen (Full screen) bool false diff --git a/minetest.conf.example b/minetest.conf.example index ecbadb556..b9efc432a 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -526,6 +526,10 @@ # type: int # screenH = 600 +# Save the window size automatically when modified. +# type: bool +# autosave_screensize = true + # Fullscreen mode. # type: bool # fullscreen = false diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index d45e386cf..434c887e8 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -121,6 +121,7 @@ void set_default_settings(Settings *settings) settings->setDefault("viewing_range", "100"); settings->setDefault("screenW", "800"); settings->setDefault("screenH", "600"); + settings->setDefault("autosave_screensize", "true"); settings->setDefault("fullscreen", "false"); settings->setDefault("fullscreen_bpp", "24"); settings->setDefault("vsync", "false"); diff --git a/src/game.cpp b/src/game.cpp index be0cc8fd5..ace647456 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1629,10 +1629,26 @@ void Game::run() && client->checkPrivilege("fast"); #endif + irr::core::dimension2d previous_screen_size(g_settings->getU16("screenW"), + g_settings->getU16("screenH")); + while (device->run() && !(*kill || g_gamecallback->shutdown_requested || (server && server->getShutdownRequested()))) { + const irr::core::dimension2d ¤t_screen_size = + device->getVideoDriver()->getScreenSize(); + // Verify if window size has changed and save it if it's the case + // Ensure evaluating settings->getBool after verifying screensize + // First condition is cheaper + if (previous_screen_size != current_screen_size && + current_screen_size != irr::core::dimension2d(0,0) && + g_settings->getBool("autosave_screensize")) { + g_settings->setU16("screenW", current_screen_size.Width); + g_settings->setU16("screenH", current_screen_size.Height); + previous_screen_size = current_screen_size; + } + /* Must be called immediately after a device->run() call because it * uses device->getTimer()->getTime() */ diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index ebc4aac44..2d1bd6d44 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -262,8 +262,24 @@ void GUIEngine::run() unsigned int text_height = g_fontengine->getTextHeight(); - while(m_device->run() && (!m_startgame) && (!m_kill)) - { + irr::core::dimension2d previous_screen_size(g_settings->getU16("screenW"), + g_settings->getU16("screenH")); + + while (m_device->run() && (!m_startgame) && (!m_kill)) { + + const irr::core::dimension2d ¤t_screen_size = + m_device->getVideoDriver()->getScreenSize(); + // Verify if window size has changed and save it if it's the case + // Ensure evaluating settings->getBool after verifying screensize + // First condition is cheaper + if (previous_screen_size != current_screen_size && + current_screen_size != irr::core::dimension2d(0,0) && + g_settings->getBool("autosave_screensize")) { + g_settings->setU16("screenW", current_screen_size.Width); + g_settings->setU16("screenH", current_screen_size.Height); + previous_screen_size = current_screen_size; + } + //check if we need to update the "upper left corner"-text if (text_height != g_fontengine->getTextHeight()) { updateTopLeftTextSize(); -- cgit v1.2.3 From 07c17db11450f235b67895ce39a5aef67458107d Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 3 Jul 2014 07:46:19 +0200 Subject: Add configurable key bindings for hotbar scrolling, and for changing volume. --- builtin/settingtypes.txt | 20 ++++++++++++++++++++ minetest.conf.example | 25 +++++++++++++++++++++++++ src/client/keys.h | 5 +++++ src/defaultsettings.cpp | 5 +++++ src/game.cpp | 35 +++++++++++++++++++++++++++++++++-- src/guiKeyChangeMenu.cpp | 24 ++++++++++++++++++------ src/settings_translation_file.cpp | 10 ++++++++++ 7 files changed, 116 insertions(+), 8 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 4b82a1e0e..61c04e616 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -186,6 +186,26 @@ keymap_fastmove (Fast key) key KEY_KEY_J # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_noclip (Noclip key) key KEY_KEY_H +# Key for selecting the next item in the hotbar. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_hotbar_next (Hotbar next key) key KEY_KEY_N + +# Key for selecting the previous item in the hotbar. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_hotbar_previous (Hotbar previous key) key KEY_KEY_B + +# Key for muting the game. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_mute (Mute key) key KEY_KEY_M + +# Key for increasing the volume. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_increase_volume (Inc. volume key) key + +# Key for decreasing the volume. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +keymap_decrease_volume (Dec. volume key) key + # Key for toggling autorun. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 keymap_autorun (Autorun key) key diff --git a/minetest.conf.example b/minetest.conf.example index b9efc432a..6c6ce91b8 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -186,6 +186,31 @@ # type: key # keymap_noclip = KEY_KEY_H +# Key for selecting the next item in the hotbar. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_hotbar_next = KEY_KEY_N + +# Key for selecting the previous item in the hotbar. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_hotbar_previous = KEY_KEY_B + +# Key for muting the game. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_mute = KEY_KEY_M + +# Key for increasing the volume. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_increase_volume = + +# Key for decreasing the volume. +# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 +# type: key +# keymap_decrease_volume = + # Key for toggling autorun. # See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3 # type: key diff --git a/src/client/keys.h b/src/client/keys.h index 76ae38ff0..9478737f6 100644 --- a/src/client/keys.h +++ b/src/client/keys.h @@ -50,6 +50,11 @@ public: FREEMOVE, FASTMOVE, NOCLIP, + HOTBAR_PREV, + HOTBAR_NEXT, + MUTE, + INC_VOLUME, + DEC_VOLUME, CINEMATIC, SCREENSHOT, TOGGLE_HUD, diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 434c887e8..c583220bd 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -80,6 +80,11 @@ void set_default_settings(Settings *settings) settings->setDefault("keymap_freemove", "KEY_KEY_K"); settings->setDefault("keymap_fastmove", "KEY_KEY_J"); settings->setDefault("keymap_noclip", "KEY_KEY_H"); + settings->setDefault("keymap_hotbar_next", "KEY_KEY_N"); + settings->setDefault("keymap_hotbar_previous", "KEY_KEY_B"); + settings->setDefault("keymap_mute", "KEY_KEY_M"); + settings->setDefault("keymap_increase_volume", ""); + settings->setDefault("keymap_decrease_volume", ""); settings->setDefault("keymap_cinematic", ""); settings->setDefault("keymap_toggle_hud", "KEY_F1"); settings->setDefault("keymap_toggle_chat", "KEY_F2"); diff --git a/src/game.cpp b/src/game.cpp index 61282b463..9de473231 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1049,6 +1049,11 @@ void KeyCache::populate() key[KeyType::FREEMOVE] = getKeySetting("keymap_freemove"); key[KeyType::FASTMOVE] = getKeySetting("keymap_fastmove"); key[KeyType::NOCLIP] = getKeySetting("keymap_noclip"); + key[KeyType::HOTBAR_PREV] = getKeySetting("keymap_hotbar_previous"); + key[KeyType::HOTBAR_NEXT] = getKeySetting("keymap_hotbar_next"); + key[KeyType::MUTE] = getKeySetting("keymap_mute"); + key[KeyType::INC_VOLUME] = getKeySetting("keymap_increase_volume"); + key[KeyType::DEC_VOLUME] = getKeySetting("keymap_decrease_volume"); key[KeyType::CINEMATIC] = getKeySetting("keymap_cinematic"); key[KeyType::SCREENSHOT] = getKeySetting("keymap_screenshot"); key[KeyType::TOGGLE_HUD] = getKeySetting("keymap_toggle_hud"); @@ -2493,6 +2498,30 @@ void Game::processKeyInput() toggleFast(); } else if (wasKeyDown(KeyType::NOCLIP)) { toggleNoClip(); + } else if (wasKeyDown(KeyType::MUTE)) { + float volume = g_settings->getFloat("sound_volume"); + if (volume < 0.001f) { + g_settings->setFloat("sound_volume", 1.0f); + m_statustext = narrow_to_wide(gettext("Volume changed to 100%")); + } else { + g_settings->setFloat("sound_volume", 0.0f); + m_statustext = narrow_to_wide(gettext("Volume changed to 0%")); + } + runData.statustext_time = 0; + } else if (wasKeyDown(KeyType::INC_VOLUME)) { + float new_volume = rangelim(g_settings->getFloat("sound_volume") + 0.1f, 0.0f, 1.0f); + char buf[100]; + g_settings->setFloat("sound_volume", new_volume); + snprintf(buf, sizeof(buf), gettext("Volume changed to %d%%"), myround(new_volume * 100)); + m_statustext = narrow_to_wide(buf); + runData.statustext_time = 0; + } else if (wasKeyDown(KeyType::DEC_VOLUME)) { + float new_volume = rangelim(g_settings->getFloat("sound_volume") - 0.1f, 0.0f, 1.0f); + char buf[100]; + g_settings->setFloat("sound_volume", new_volume); + snprintf(buf, sizeof(buf), gettext("Volume changed to %d%%"), myround(new_volume * 100)); + m_statustext = narrow_to_wide(buf); + runData.statustext_time = 0; } else if (wasKeyDown(KeyType::CINEMATIC)) { toggleCinematic(); } else if (wasKeyDown(KeyType::SCREENSHOT)) { @@ -2560,11 +2589,13 @@ void Game::processItemSelection(u16 *new_playeritem) s32 dir = wheel; - if (input->joystick.wasKeyDown(KeyType::SCROLL_DOWN)) { + if (input->joystick.wasKeyDown(KeyType::SCROLL_DOWN) || + wasKeyDown(KeyType::HOTBAR_NEXT)) { dir = -1; } - if (input->joystick.wasKeyDown(KeyType::SCROLL_UP)) { + if (input->joystick.wasKeyDown(KeyType::SCROLL_UP) || + wasKeyDown(KeyType::HOTBAR_PREV)) { dir = 1; } diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp index e85ee8271..ae53c56f9 100644 --- a/src/guiKeyChangeMenu.cpp +++ b/src/guiKeyChangeMenu.cpp @@ -58,6 +58,11 @@ enum GUI_ID_KEY_SNEAK_BUTTON, GUI_ID_KEY_DROP_BUTTON, GUI_ID_KEY_INVENTORY_BUTTON, + GUI_ID_KEY_HOTBAR_PREV_BUTTON, + GUI_ID_KEY_HOTBAR_NEXT_BUTTON, + GUI_ID_KEY_MUTE_BUTTON, + GUI_ID_KEY_DEC_VOLUME_BUTTON, + GUI_ID_KEY_INC_VOLUME_BUTTON, GUI_ID_KEY_DUMP_BUTTON, GUI_ID_KEY_RANGE_BUTTON, GUI_ID_KEY_ZOOM_BUTTON, @@ -109,7 +114,7 @@ void GUIKeyChangeMenu::removeChildren() void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) { removeChildren(); - v2s32 size(620, 430); + v2s32 size(745, 430); core::rect < s32 > rect(screensize.X / 2 - size.X / 2, screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, @@ -146,15 +151,17 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) { core::rect < s32 > rect(0, 0, 100, 30); - rect += topleft + v2s32(offset.X + 115, offset.Y - 5); + rect += topleft + v2s32(offset.X + 120, offset.Y - 5); const wchar_t *text = wgettext(k->key.name()); k->button = Environment->addButton(rect, this, k->id, text); delete[] text; } - if(i + 1 == KMaxButtonPerColumns) - offset = v2s32(260, 60); - else + if ((i + 1) % KMaxButtonPerColumns == 0) { + offset.X += 230; + offset.Y = 60; + } else { offset += v2s32(0, 25); + } } { @@ -215,7 +222,7 @@ void GUIKeyChangeMenu::drawMenu() video::SColor bgcolor(140, 0, 0, 0); { - core::rect < s32 > rect(0, 0, 620, 620); + core::rect < s32 > rect(0, 0, 745, 620); rect += AbsoluteRect.UpperLeftCorner; driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect); } @@ -407,6 +414,11 @@ void GUIKeyChangeMenu::init_keys() this->add_key(GUI_ID_KEY_SNEAK_BUTTON, wgettext("Sneak"), "keymap_sneak"); this->add_key(GUI_ID_KEY_DROP_BUTTON, wgettext("Drop"), "keymap_drop"); this->add_key(GUI_ID_KEY_INVENTORY_BUTTON, wgettext("Inventory"), "keymap_inventory"); + this->add_key(GUI_ID_KEY_HOTBAR_PREV_BUTTON,wgettext("Prev. item"), "keymap_hotbar_previous"); + this->add_key(GUI_ID_KEY_HOTBAR_NEXT_BUTTON,wgettext("Next item"), "keymap_hotbar_next"); + this->add_key(GUI_ID_KEY_MUTE_BUTTON, wgettext("Mute"), "keymap_mute"); + this->add_key(GUI_ID_KEY_DEC_VOLUME_BUTTON,wgettext("Dec. volume"), "keymap_decrease_volume"); + this->add_key(GUI_ID_KEY_INC_VOLUME_BUTTON,wgettext("Inc. volume"), "keymap_increase_volume"); this->add_key(GUI_ID_KEY_CHAT_BUTTON, wgettext("Chat"), "keymap_chat"); this->add_key(GUI_ID_KEY_CMD_BUTTON, wgettext("Command"), "keymap_cmd"); this->add_key(GUI_ID_KEY_CMD_LOCAL_BUTTON, wgettext("Local command"), "keymap_cmd_local"); diff --git a/src/settings_translation_file.cpp b/src/settings_translation_file.cpp index 47601135d..383da33a7 100644 --- a/src/settings_translation_file.cpp +++ b/src/settings_translation_file.cpp @@ -77,6 +77,16 @@ fake_function() { gettext("Key for toggling fast mode.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); gettext("Noclip key"); gettext("Key for toggling noclip mode.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); + gettext("Hotbar next key"); + gettext("Key for selecting the next item in the hotbar.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); + gettext("Hotbar previous key"); + gettext("Key for selecting the previous item in the hotbar.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); + gettext("Mute key"); + gettext("Key for muting the game.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); + gettext("Inc. volume key"); + gettext("Key for increasing the volume.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); + gettext("Dec. volume key"); + gettext("Key for decreasing the volume.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); gettext("Autorun key"); gettext("Key for toggling autorun.\nSee http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3"); gettext("Cinematic mode key"); -- cgit v1.2.3 From 018217f6b2058db44b59a86e170614e1c6925f9f Mon Sep 17 00:00:00 2001 From: ezhh Date: Thu, 11 May 2017 23:18:36 +0100 Subject: Add option to use neither node highlighting nor outlining --- builtin/mainmenu/tab_settings.lua | 5 +++-- builtin/settingtypes.txt | 2 +- minetest.conf.example | 2 +- src/hud.cpp | 25 ++++++++++++++++--------- src/hud.h | 6 +++++- 5 files changed, 26 insertions(+), 14 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index 69683eaa3..5a8cc19b8 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -25,7 +25,8 @@ local labels = { }, node_highlighting = { fgettext("Node Outlining"), - fgettext("Node Highlighting") + fgettext("Node Highlighting"), + fgettext("None") }, filters = { fgettext("No Filter"), @@ -52,7 +53,7 @@ local dd_options = { }, node_highlighting = { table.concat(labels.node_highlighting, ","), - {"box", "halo"} + {"box", "halo", "none"} }, filters = { table.concat(labels.filters, ","), diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 61c04e616..463ca0be9 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -344,7 +344,7 @@ enable_clouds (Clouds) bool true enable_3d_clouds (3D clouds) bool true # Method used to highlight selected object. -node_highlighting (Node highlighting) enum box box,halo +node_highlighting (Node highlighting) enum box box,halo,none # Adds particles when digging a node. enable_particles (Digging particles) bool true diff --git a/minetest.conf.example b/minetest.conf.example index 6c6ce91b8..e9add1597 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -382,7 +382,7 @@ # enable_3d_clouds = true # Method used to highlight selected object. -# type: enum values: box, halo +# type: enum values: box, halo, none # node_highlighting = box # Adds particles when digging a node. diff --git a/src/hud.cpp b/src/hud.cpp index 9729013ee..3e4162b64 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -87,24 +87,31 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr, m_halo_boxes.clear(); m_selection_pos = v3f(0.0, 0.0, 0.0); - std::string mode = g_settings->get("node_highlighting"); + std::string mode_setting = g_settings->get("node_highlighting"); + + if (mode_setting == "halo") { + m_mode = HIGHLIGHT_HALO; + } else if (mode_setting == "none") { + m_mode = HIGHLIGHT_NONE; + } else { + m_mode = HIGHLIGHT_BOX; + } + m_selection_material.Lighting = false; if (g_settings->getBool("enable_shaders")) { IShaderSource *shdrsrc = client->getShaderSource(); u16 shader_id = shdrsrc->getShader( - mode == "halo" ? "selection_shader" : "default_shader", 1, 1); + m_mode == HIGHLIGHT_HALO ? "selection_shader" : "default_shader", 1, 1); m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material; } else { m_selection_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; } - if (mode == "box") { - m_use_selection_mesh = false; + if (m_mode == HIGHLIGHT_BOX) { m_selection_material.Thickness = rangelim(g_settings->getS16("selectionbox_width"), 1, 5); - } else if (mode == "halo") { - m_use_selection_mesh = true; + } else if (m_mode == HIGHLIGHT_HALO) { m_selection_material.setTexture(0, tsrc->getTextureForMesh("halo.png")); m_selection_material.setFlag(video::EMF_BACK_FACE_CULLING, true); } else { @@ -518,7 +525,7 @@ void Hud::setSelectionPos(const v3f &pos, const v3s16 &camera_offset) void Hud::drawSelectionMesh() { - if (!m_use_selection_mesh) { + if (m_mode == HIGHLIGHT_BOX) { // Draw 3D selection boxes video::SMaterial oldmaterial = driver->getMaterial2D(); driver->setMaterial(m_selection_material); @@ -538,7 +545,7 @@ void Hud::drawSelectionMesh() driver->draw3DBox(box, video::SColor(255, r, g, b)); } driver->setMaterial(oldmaterial); - } else if (m_selection_mesh) { + } else if (m_mode == HIGHLIGHT_HALO && m_selection_mesh) { // Draw selection mesh video::SMaterial oldmaterial = driver->getMaterial2D(); driver->setMaterial(m_selection_material); @@ -564,7 +571,7 @@ void Hud::drawSelectionMesh() void Hud::updateSelectionMesh(const v3s16 &camera_offset) { m_camera_offset = camera_offset; - if (!m_use_selection_mesh) + if (m_mode != HIGHLIGHT_HALO) return; if (m_selection_mesh) { diff --git a/src/hud.h b/src/hud.h index efa0c3648..15c115d89 100644 --- a/src/hud.h +++ b/src/hud.h @@ -175,7 +175,11 @@ private: v3f m_selected_face_normal; video::SMaterial m_selection_material; - bool m_use_selection_mesh; + + enum { + HIGHLIGHT_BOX, + HIGHLIGHT_HALO, + HIGHLIGHT_NONE } m_mode; }; enum ItemRotationKind { -- cgit v1.2.3 From 39f4a2f607d44738d60db84eba4b30e3d7450204 Mon Sep 17 00:00:00 2001 From: Pierre-Adrien Langrognet Date: Sun, 21 May 2017 23:06:51 +0200 Subject: [CSM] Add send_chat_message and run_server_chatcommand API functions (#5747) * [CSM] Add send_chat_message and run_server_chatcommand API functions * Add client-side chat message rate limiting * Limit out chat queue size * [CSM] Add minetest.clear_out_chat_queue API function and .clear_chat_queue chatcommand * Last fixes/cleanups before merge --- builtin/client/chatcommands.lua | 12 +++++++++ builtin/settingtypes.txt | 3 +++ doc/client_lua_api.md | 10 ++++++-- minetest.conf.example | 4 +++ src/client.cpp | 54 ++++++++++++++++++++++++++++++++++++++--- src/client.h | 8 ++++++ src/defaultsettings.cpp | 1 + src/script/lua_api/l_client.cpp | 19 +++++++++++++++ src/script/lua_api/l_client.h | 6 +++++ 9 files changed, 111 insertions(+), 6 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua index f425216f5..2b8cc4acd 100644 --- a/builtin/client/chatcommands.lua +++ b/builtin/client/chatcommands.lua @@ -51,3 +51,15 @@ core.register_chatcommand("disconnect", { core.disconnect() end, }) + +core.register_chatcommand("clear_chat_queue", { + description = core.gettext("Clear the out chat queue"), + func = function(param) + core.clear_out_chat_queue() + return true, core.gettext("The out chat queue is now empty") + end, +}) + +function core.run_server_chatcommand(cmd, param) + core.send_chat_message("/" .. cmd .. " " .. param) +end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 463ca0be9..0ec33c628 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -312,6 +312,9 @@ serverlist_url (Serverlist URL) string servers.minetest.net # File in client/serverlist/ that contains your favorite servers displayed in the Multiplayer Tab. serverlist_file (Serverlist file) string favoriteservers.txt +# Maximum size of the out chat queue. 0 to disable queueing and -1 to make the queue size unlimited +max_out_chat_queue_size (Maximum size of the out chat queue) int 20 + [*Graphics] [**In-Game] diff --git a/doc/client_lua_api.md b/doc/client_lua_api.md index ce0746df4..b3e494cc1 100644 --- a/doc/client_lua_api.md +++ b/doc/client_lua_api.md @@ -721,6 +721,12 @@ Call these functions only at load time! ### Player * `minetest.get_wielded_item()` * Returns the itemstack the local player is holding +* `minetest.send_chat_message(message)` + * Act as if `message` was typed by the player into the terminal. +* `minetest.run_server_chatcommand(cmd, param)` + * Alias for `minetest.send_chat_message("/" .. cmd .. " " .. param)` +* `minetest.clear_out_chat_queue()` + * Clears the out chat queue * `minetest.localplayer` * Reference to the LocalPlayer object. See [`LocalPlayer`](#localplayer) class reference for methods. @@ -836,7 +842,7 @@ Please do not try to access the reference until the camera is initialized, other * Returns with same syntax as above * `get_fov()` * Returns: - + ```lua { x = number, @@ -845,7 +851,7 @@ Please do not try to access the reference until the camera is initialized, other actual = number } ``` - + * `get_pos()` * Returns position of camera with view bobbing * `get_offset()` diff --git a/minetest.conf.example b/minetest.conf.example index e9add1597..5e1609de6 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -343,6 +343,10 @@ # type: string # serverlist_file = favoriteservers.txt +# Maximum size of the out chat queue. 0 to disable queueing and -1 to make the queue size unlimited +# type: int min: -1 +max_out_chat_queue_size = 20 + ## Graphics ### In-Game diff --git a/src/client.cpp b/src/client.cpp index a36f5413f..a5228132d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -104,6 +104,8 @@ Client::Client( m_animation_time(0), m_crack_level(-1), m_crack_pos(0,0,0), + m_last_chat_message_sent(time(NULL)), + m_chat_message_allowance(5.0f), m_map_seed(0), m_password(password), m_chosen_auth_mech(AUTH_MECHANISM_NONE), @@ -400,6 +402,14 @@ void Client::step(float dtime) } } + /* + Send pending messages on out chat queue + */ + if (!m_out_chat_queue.empty() && canSendChatMessage()) { + sendChatMessage(m_out_chat_queue.front()); + m_out_chat_queue.pop(); + } + /* Handle environment */ @@ -1158,13 +1168,50 @@ void Client::sendInventoryAction(InventoryAction *a) Send(&pkt); } +bool Client::canSendChatMessage() const +{ + u32 now = time(NULL); + float time_passed = now - m_last_chat_message_sent; + + float virt_chat_message_allowance = m_chat_message_allowance + time_passed * + (CLIENT_CHAT_MESSAGE_LIMIT_PER_10S / 8.0f); + + if (virt_chat_message_allowance < 1.0f) + return false; + + return true; +} + void Client::sendChatMessage(const std::wstring &message) { - NetworkPacket pkt(TOSERVER_CHAT_MESSAGE, 2 + message.size() * sizeof(u16)); + const s16 max_queue_size = g_settings->getS16("max_out_chat_queue_size"); + if (canSendChatMessage()) { + u32 now = time(NULL); + float time_passed = now - m_last_chat_message_sent; + m_last_chat_message_sent = time(NULL); - pkt << message; + m_chat_message_allowance += time_passed * (CLIENT_CHAT_MESSAGE_LIMIT_PER_10S / 8.0f); + if (m_chat_message_allowance > CLIENT_CHAT_MESSAGE_LIMIT_PER_10S) + m_chat_message_allowance = CLIENT_CHAT_MESSAGE_LIMIT_PER_10S; - Send(&pkt); + m_chat_message_allowance -= 1.0f; + + NetworkPacket pkt(TOSERVER_CHAT_MESSAGE, 2 + message.size() * sizeof(u16)); + + pkt << message; + + Send(&pkt); + } else if (m_out_chat_queue.size() < (u16) max_queue_size || max_queue_size == -1) { + m_out_chat_queue.push(message); + } else { + infostream << "Could not queue chat message because maximum out chat queue size (" + << max_queue_size << ") is reached." << std::endl; + } +} + +void Client::clearOutChatQueue() +{ + m_out_chat_queue = std::queue(); } void Client::sendChangePassword(const std::string &oldpassword, @@ -1924,4 +1971,3 @@ std::string Client::getModStoragePath() const { return porting::path_user + DIR_DELIM + "client" + DIR_DELIM + "mod_storage"; } - diff --git a/src/client.h b/src/client.h index cc0d4699d..b4145c76f 100644 --- a/src/client.h +++ b/src/client.h @@ -38,6 +38,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "tileanimation.h" #include "mesh_generator_thread.h" +#define CLIENT_CHAT_MESSAGE_LIMIT_PER_10S 10.0f + struct MeshMakeData; class MapBlockMesh; class IWritableTextureSource; @@ -360,6 +362,7 @@ public: const StringMap &fields); void sendInventoryAction(InventoryAction *a); void sendChatMessage(const std::wstring &message); + void clearOutChatQueue(); void sendChangePassword(const std::string &oldpassword, const std::string &newpassword); void sendDamage(u8 damage); @@ -565,6 +568,8 @@ private: inline std::string getPlayerName() { return m_env.getLocalPlayer()->getName(); } + bool canSendChatMessage() const; + float m_packetcounter_timer; float m_connection_reinit_timer; float m_avg_rtt_timer; @@ -612,6 +617,9 @@ private: //s32 m_daynight_i; //u32 m_daynight_ratio; std::queue m_chat_queue; + std::queue m_out_chat_queue; + u32 m_last_chat_message_sent; + float m_chat_message_allowance; // The authentication methods we can use to enter sudo mode (=change password) u32 m_sudo_auth_methods; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index c583220bd..0a44069fd 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -57,6 +57,7 @@ void set_default_settings(Settings *settings) settings->setDefault("curl_verify_cert", "true"); settings->setDefault("enable_remote_media_server", "true"); settings->setDefault("enable_client_modding", "false"); + settings->setDefault("max_out_chat_queue_size", "20"); // Keymap settings->setDefault("remote_port", "30000"); diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp index 09b832ccf..0b7450af2 100644 --- a/src/script/lua_api/l_client.cpp +++ b/src/script/lua_api/l_client.cpp @@ -85,6 +85,23 @@ int ModApiClient::l_display_chat_message(lua_State *L) return 1; } +// send_chat_message(message) +int ModApiClient::l_send_chat_message(lua_State *L) +{ + if (!lua_isstring(L,1)) + return 0; + std::string message = luaL_checkstring(L, 1); + getClient(L)->sendChatMessage(utf8_to_wide(message)); + return 0; +} + +// clear_out_chat_queue() +int ModApiClient::l_clear_out_chat_queue(lua_State *L) +{ + getClient(L)->clearOutChatQueue(); + return 0; +} + // get_player_names() int ModApiClient::l_get_player_names(lua_State *L) { @@ -317,6 +334,8 @@ void ModApiClient::Initialize(lua_State *L, int top) API_FCT(get_current_modname); API_FCT(print); API_FCT(display_chat_message); + API_FCT(send_chat_message); + API_FCT(clear_out_chat_queue); API_FCT(get_player_names); API_FCT(set_last_run_mod); API_FCT(get_last_run_mod); diff --git a/src/script/lua_api/l_client.h b/src/script/lua_api/l_client.h index 09b74addd..fe5780fb1 100644 --- a/src/script/lua_api/l_client.h +++ b/src/script/lua_api/l_client.h @@ -37,6 +37,12 @@ private: // display_chat_message(message) static int l_display_chat_message(lua_State *L); + // send_chat_message(message) + static int l_send_chat_message(lua_State *L); + + // clear_out_chat_queue() + static int l_clear_out_chat_queue(lua_State *L); + // get_player_names() static int l_get_player_names(lua_State *L); -- cgit v1.2.3 From c09e16ff5bd65a82aa231a286308f3415fe9159e Mon Sep 17 00:00:00 2001 From: Nathan Salapat Date: Sun, 28 May 2017 02:23:06 -0500 Subject: Added missing levels to logging menu (#5836) * Added missing levels to logging menu Added none and error options to the debug_log_level in the advance settings. --- builtin/settingtypes.txt | 2 +- minetest.conf.example | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 0ec33c628..3758097bc 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -1468,7 +1468,7 @@ language (Language) enum ,be,ca,cs,da,de,en,eo,es,et,fr,he,hu,id,it,ja,jbo,ko, # - action # - info # - verbose -debug_log_level (Debug log level) enum action ,warning,action,info,verbose +debug_log_level (Debug log level) enum action ,none,error,warning,action,info,verbose # IPv6 support. enable_ipv6 (IPv6) bool true diff --git a/minetest.conf.example b/minetest.conf.example index 5e1609de6..1d37ab493 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1792,7 +1792,7 @@ max_out_chat_queue_size = 20 # - action # - info # - verbose -# type: enum values: , warning, action, info, verbose +# type: enum values: , none, error, warning, action, info, verbose # debug_log_level = action # IPv6 support. -- cgit v1.2.3 From 994802a77496202a1d71aae54e9606ee6f55def6 Mon Sep 17 00:00:00 2001 From: red-001 Date: Sat, 3 Jun 2017 13:44:04 +0100 Subject: Remove unimplemented setting `movement_speed_descend` (#5892) --- builtin/settingtypes.txt | 1 - minetest.conf.example | 3 --- 2 files changed, 4 deletions(-) (limited to 'minetest.conf.example') diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 3758097bc..ba3339d32 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -886,7 +886,6 @@ movement_speed_crouch (Crouch speed) float 1.35 movement_speed_fast (Fast mode speed) float 20 movement_speed_climb (Climbing speed) float 3 movement_speed_jump (Jumping speed) float 6.5 -movement_speed_descend (Descending speed) float 6 movement_liquid_fluidity (Liquid fluidity) float 1 movement_liquid_fluidity_smooth (Liquid fluidity smoothing) float 0.5 movement_liquid_sink (Liquid sink) float 10 diff --git a/minetest.conf.example b/minetest.conf.example index 1d37ab493..c933047dd 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -1078,9 +1078,6 @@ max_out_chat_queue_size = 20 # type: float # movement_speed_jump = 6.5 -# type: float -# movement_speed_descend = 6 - # type: float # movement_liquid_fluidity = 1 -- cgit v1.2.3