mirror of
https://gitlab.com/gaelysam/mapgen_rivers.git
synced 2024-12-29 12:20:41 +01:00
Express map size in Minetest nodes, not in river grid nodes
This introduces new parameters 'map_x_size' and 'map_z_size' that default to 15K Deprecates 'grid_x_size' and 'grid_z_size'; if they are present, corresponding values of 'map_x_size' and 'map_z_size' are automatically written in config files. Also rework compatibility system to better compare versions, and bump version to 1.0.2-dev1.
This commit is contained in:
parent
b374e8ee95
commit
12c3394114
@ -1,3 +1,21 @@
|
|||||||
|
local function version_is_lower(v1, v2)
|
||||||
|
local d1, c1, d2, c2
|
||||||
|
while #v1 > 0 and #v2 > 0 do
|
||||||
|
d1, c1, v1 = v1:match("^(%d*)(%D*)(.*)$")
|
||||||
|
d2, c2, v2 = v2:match("^(%d*)(%D*)(.*)$")
|
||||||
|
|
||||||
|
d1 = tonumber(d1) or -1
|
||||||
|
d2 = tonumber(d2) or -1
|
||||||
|
if d1 ~= d2 then
|
||||||
|
return d1 < d2
|
||||||
|
end
|
||||||
|
if c1 ~= c2 then
|
||||||
|
return c1 < c2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local function fix_min_catchment(settings, is_global)
|
local function fix_min_catchment(settings, is_global)
|
||||||
local prefix = is_global and "mapgen_rivers_" or ""
|
local prefix = is_global and "mapgen_rivers_" or ""
|
||||||
|
|
||||||
@ -21,6 +39,18 @@ local function fix_compatibility_minetest(settings)
|
|||||||
if previous_version == "0.0" then
|
if previous_version == "0.0" then
|
||||||
fix_min_catchment(settings, true)
|
fix_min_catchment(settings, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if version_is_lower(previous_version, "1.0.2-dev1") then
|
||||||
|
local blocksize = tonumber(settings:get("mapgen_rivers_blocksize") or 15)
|
||||||
|
local grid_x_size = tonumber(settings:get("mapgen_rivers_grid_x_size"))
|
||||||
|
if grid_x_size then
|
||||||
|
settings:set("mapgen_rivers_map_x_size", tostring(grid_x_size * blocksize))
|
||||||
|
end
|
||||||
|
local grid_z_size = tonumber(settings:get("mapgen_rivers_grid_z_size"))
|
||||||
|
if grid_z_size then
|
||||||
|
settings:set("mapgen_rivers_map_z_size", tostring(grid_z_size * blocksize))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fix_compatibility_mapgen_rivers(settings)
|
local function fix_compatibility_mapgen_rivers(settings)
|
||||||
@ -29,6 +59,18 @@ local function fix_compatibility_mapgen_rivers(settings)
|
|||||||
if previous_version == "0.0" then
|
if previous_version == "0.0" then
|
||||||
fix_min_catchment(settings, false)
|
fix_min_catchment(settings, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if version_is_lower(previous_version, "1.0.2-dev1") then
|
||||||
|
local blocksize = tonumber(settings:get("blocksize") or 15)
|
||||||
|
local grid_x_size = tonumber(settings:get("grid_x_size"))
|
||||||
|
if grid_x_size then
|
||||||
|
settings:set("map_x_size", tostring(grid_x_size * blocksize))
|
||||||
|
end
|
||||||
|
local grid_z_size = tonumber(settings:get("grid_z_size"))
|
||||||
|
if grid_z_size then
|
||||||
|
settings:set("map_z_size", tostring(grid_z_size * blocksize))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return fix_compatibility_minetest, fix_compatibility_mapgen_rivers
|
return fix_compatibility_minetest, fix_compatibility_mapgen_rivers
|
||||||
|
@ -11,8 +11,9 @@ dofile(modpath .. 'load.lua')
|
|||||||
|
|
||||||
mapgen_rivers.grid = {}
|
mapgen_rivers.grid = {}
|
||||||
|
|
||||||
local X = mapgen_rivers.settings.grid_x_size
|
local blocksize = mapgen_rivers.settings.blocksize
|
||||||
local Z = mapgen_rivers.settings.grid_z_size
|
local X = math.floor(mapgen_rivers.settings.map_x_size / blocksize)
|
||||||
|
local Z = math.floor(mapgen_rivers.settings.map_z_size / blocksize)
|
||||||
|
|
||||||
local function offset_converter(o)
|
local function offset_converter(o)
|
||||||
return (o + 0.5) * (1/256)
|
return (o + 0.5) * (1/256)
|
||||||
@ -80,7 +81,6 @@ local function index(x, z)
|
|||||||
return z*X+x+1
|
return z*X+x+1
|
||||||
end
|
end
|
||||||
|
|
||||||
local blocksize = mapgen_rivers.settings.blocksize
|
|
||||||
local min_catchment = mapgen_rivers.settings.min_catchment
|
local min_catchment = mapgen_rivers.settings.min_catchment
|
||||||
local max_catchment = mapgen_rivers.settings.max_catchment
|
local max_catchment = mapgen_rivers.settings.max_catchment
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ local function pregenerate(keep_loaded)
|
|||||||
local grid = mapgen_rivers.grid
|
local grid = mapgen_rivers.grid
|
||||||
local size = grid.size
|
local size = grid.size
|
||||||
|
|
||||||
|
if size.x * size.y > 4e6 then
|
||||||
|
minetest.log("warning", "[mapgen_rivers] You are going to generate a very large grid (>4M nodes). If you experience problems, you should increase blocksize or reduce map size.")
|
||||||
|
end
|
||||||
|
|
||||||
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
local seed = tonumber(minetest.get_mapgen_setting("seed"))
|
||||||
np_base.seed = (np_base.seed or 0) + seed
|
np_base.seed = (np_base.seed or 0) + seed
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local mtsettings = minetest.settings
|
local mtsettings = minetest.settings
|
||||||
local mgrsettings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
local mgrsettings = Settings(minetest.get_worldpath() .. '/mapgen_rivers.conf')
|
||||||
|
|
||||||
mapgen_rivers.version = "1.0.2"
|
mapgen_rivers.version = "1.0.2-dev1"
|
||||||
|
|
||||||
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
local previous_version_mt = mtsettings:get("mapgen_rivers_version") or "0.0"
|
||||||
local previous_version_mgr = mgrsettings:get("version") or "0.0"
|
local previous_version_mgr = mgrsettings:get("version") or "0.0"
|
||||||
@ -93,8 +93,8 @@ mapgen_rivers.settings = {
|
|||||||
glacier_factor = def_setting('glacier_factor', 'number'),
|
glacier_factor = def_setting('glacier_factor', 'number'),
|
||||||
elevation_chill = def_setting('elevation_chill', 'number'),
|
elevation_chill = def_setting('elevation_chill', 'number'),
|
||||||
|
|
||||||
grid_x_size = def_setting('grid_x_size', 'number'),
|
map_x_size = def_setting('map_x_size', 'number'),
|
||||||
grid_z_size = def_setting('grid_z_size', 'number'),
|
map_z_size = def_setting('map_z_size', 'number'),
|
||||||
evol_params = {
|
evol_params = {
|
||||||
K = def_setting('river_erosion_coef', 'number'),
|
K = def_setting('river_erosion_coef', 'number'),
|
||||||
m = def_setting('river_erosion_power', 'number'),
|
m = def_setting('river_erosion_power', 'number'),
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
"glacier_factor": 8,
|
"glacier_factor": 8,
|
||||||
"elevation_chill": 0.25,
|
"elevation_chill": 0.25,
|
||||||
|
|
||||||
"grid_x_size": 1000,
|
"map_x_size": 15000,
|
||||||
"grid_z_size": 1000,
|
"map_z_size": 15000,
|
||||||
"river_erosion_coef": 0.5,
|
"river_erosion_coef": 0.5,
|
||||||
"river_erosion_power": 0.4,
|
"river_erosion_power": 0.4,
|
||||||
"diffusive_erosion": 0.5,
|
"diffusive_erosion": 0.5,
|
||||||
|
@ -3,19 +3,25 @@
|
|||||||
# Whether the map should be centered at x=0, z=0.
|
# Whether the map should be centered at x=0, z=0.
|
||||||
mapgen_rivers_center (Center map) bool true
|
mapgen_rivers_center (Center map) bool true
|
||||||
|
|
||||||
# Represents horizontal map scale. Every cell of the grid will be upscaled to
|
# Every cell of the river grid will represent a square of this size.
|
||||||
# a square of this size.
|
# A lower value will result in more detailed terrain and finer computation
|
||||||
# For example if the grid size is 1000x1000 and block size is 12,
|
# of rivers, but will be slower to generate and use more resources.
|
||||||
# the actual size of the map will be 12000.
|
#
|
||||||
|
# WARNING: Excessively low values may cause crashes at pre-generation, due to
|
||||||
|
# memory issues
|
||||||
mapgen_rivers_blocksize (Block size) float 15.0 2.0 100.0
|
mapgen_rivers_blocksize (Block size) float 15.0 2.0 100.0
|
||||||
|
|
||||||
# X size of the grid being generated
|
# X size of the map being generated
|
||||||
# Actual size of the map is grid_x_size * blocksize
|
#
|
||||||
mapgen_rivers_grid_x_size (Grid X size) int 1000 50 5000
|
# X size of the river grid will be this/blocksize
|
||||||
|
# When increasing, it is recommended to increase blocksize too
|
||||||
|
mapgen_rivers_map_x_size (Map X size) int 15000 500 66000
|
||||||
|
|
||||||
# Z size of the grid being generated
|
# Z size of the map being generated
|
||||||
# Actual size of the map is grid_z_size * blocksize
|
#
|
||||||
mapgen_rivers_grid_z_size (Grid Z size) int 1000 50 5000
|
# Z size of the river grid will be this/blocksize
|
||||||
|
# When increasing, it is recommended to increase blocksize too
|
||||||
|
mapgen_rivers_map_z_size (Map Z size) int 15000 500 66000
|
||||||
|
|
||||||
# Minimal catchment area for a river to be drawn, in square nodes
|
# Minimal catchment area for a river to be drawn, in square nodes
|
||||||
# Lower value means bigger river density
|
# Lower value means bigger river density
|
||||||
|
Loading…
Reference in New Issue
Block a user