Commit Graph

124 Commits

Author SHA1 Message Date
Paramat 0cde6fc552
Re-order mapgens in mainmenu and 'all settings' mapgen selection (#8705)
v6 always last to discourage selection.
Special mapgens flat, fractal, singlenode, next to last. Of these, singlenode
last to discourage selection.
Of the remaining, v5 last due to age, v7 first due to being the default.
2019-07-25 20:46:28 +01:00
Paramat 245a31d6b7
Mgfractal: Make non-fractal terrain optional (#8702)
Enabled by default.
Only allow spawn on fractal, not on seabed terrain.
Various codestyle and comment improvements.
2019-07-25 19:58:35 +01:00
Paramat 76824bac9f
Document the deprecation of hardcoded cave liquids (#8692) 2019-07-20 01:03:52 +01:00
Paramat 458f617575
Dungeons: Make multiple large rooms possible (#8678)
Re-add the random size range for large rooms.
Remove 'first_room_large' bool.
Add 'large_room_chance' parameter that can disable large rooms,
specify 1 large room, or specify a chance for large rooms.
If 1 or a chance is specified, the first generated room is large,
to take advantage of the intersection checks that are done for the
1st room only.
2019-07-16 20:39:58 +01:00
Paramat 0c31946943
Move more dungeon parameter selection to mapgens (#8653)
Move 'num_dungeons' to 'DungeonParams'.
Add new parameter 'num_rooms' to replace 'rooms_min' and 'rooms_max',
so that the mapgen has complete control over the number of rooms.
Add new bool 'first_room_large' so that the mapgen chooses this
instead of a hardcoded 1 in 4 chance.
Add new parameter 'room_size_large' to replace 'room_size_large_min'
and 'room_size_large_max', so that the mapgen has complete control
over this.
2019-07-09 20:38:51 +01:00
Paramat bb14b7e956
Dungeongen: Remove most hardcoded dungeon nodes (#8594)
Biome-defined dungeon nodes was added as a feature to MT 5.0.0.
So now remove most of the hardcoded dungeon node code that assumes a
game has stone, sandstone, desert stone, and no other stone types.
If biome-defined dungeon nodes are not found, dungeon nodes fall back
to the 'cobble' mapgen alias if present, if not present they fall back
to biome-defined 'stone'.
Remove now-unnecessary mapgen aliases from MapgenBasic. Non-mgv6 games
now only need to define 3 to 5 mapgen aliases.

Document dungeon parameters.

Make c_lava_source fallback to c_water_source as both are used as cave
liquids.
2019-06-30 22:55:20 +01:00
Paramat 5d4850a7ce
Mapgen Carpathian: Add optional rivers (#7977)
Rivers are disabled by default and will not be added to existing worlds.
Rewrite getSpawnLevelAtPoint() to be simpler and more consistent with
generateTerrain().
2019-06-19 01:06:08 +01:00
Paramat 7379aa74cf
Dungeons: Settable density noise, move number calculation to mapgens (#8473)
Add user-settable noise parameters for dungeon density to each mapgen,
except V6 which hardcodes this noise parameter.

Move the calculation of number of dungeons generated in a mapchunk out
of dungeongen.cpp and into mapgen code, to allow mapgens to generate
any desired number of dungeons in a mapchunk, instead of being forced
to have number of dungeons determined by a density noise.

This is more flexible and allows mapgens to use dungeon generation to
create custom structures, such as occasional mega-dungeons.
2019-06-01 20:50:43 +01:00
Paramat b1b40fef16
Allow multiple cave liquids in a biome definition (#8481)
This allows games to specify biome cave liquids and avoid the old
hardcoded behaviour, but preserves the ability to have multiple
cave liquids in one biome, such as lava and water.

When multiple cave liquids are defined by the biome definition,
make each entire cave use a randomly chosen liquid, instead of
every small cave segment using a randomly chosen liquid.

Plus an optimisation:
Don't place nodes if cave liquid is defined as 'air'
2019-05-18 21:13:14 +01:00
Jozef Behran 0c90ab4f6c Optimize random turns in dungeongen (#8129)
It turns out there is no need to return the new value and
preserve the old one in random_turn, the procedure can be
made to modify the value in-place. This saves quite a bunch
of parameter and return value copying.
2019-04-07 19:08:27 +02:00
Loic Blot a4677496f3 Fix comments 2019-03-31 20:49:39 +02:00
Loïc Blot b55fc3d773 mapgen: drop mapgen id from child mapgens.
This id must be owned by the child mapgen and never be set to a misc value by a developer

Also use nullptr in some places
2019-03-31 20:49:39 +02:00
Paramat 5e7662ca16
Dungeons: Do not remove nodes that have 'is_ground_content = false' (#8423)
Like randomwalk caves, preserve nodes that have 'is_ground_content = false',
to avoid dungeons that generate out beyond the edge of a mapchunk destroying
nodes added by mods in 'register_on_generated()'.

Issue discovered by, and original PR by, argyle77.
2019-03-26 03:56:57 +00:00
Paramat aafbdd442f
Valleys mapgen code rewrite (#8101)
Shorter, simpler, clearer and more consistent with other mapgens,
while preserving functionality.
Base terrain shape is unchanged.
With the 'vary river depth' option disabled, river surface level
is unchanged.
Behaviour of the 4 heat/humidity/river depth options is very
slightly changed due to bugfixes and code cleanup (the mapgen is
'unstable').
Apply heat and humidity gradients above water_level instead of
above y = 0.
2019-03-14 00:27:16 +00:00
Paramat 922e6ff57e
blitToVManip: Check out-of-bounds using node position not index (#8127)
Previously, when using 'place on vmanip' to add a schematic to a
lua voxelmanip, if part of the schematic was outside the voxelmanip
volume, the outside part would often appear in a strange place
elsewhere inside the voxelmanip instead of being trimmed off.
This was due to the out-of-bounds check checking the index.

A position outside the voxelmanip can have an index that satisfies
'0 <= index <= voxelmanip volume', causing the node to be placed
at a strange position inside the voxelmanip.

Use 'vm->m_area.contains(pos)' instead.
Move index calculation to later in the code to optimise.
2019-01-25 19:01:00 +00:00
Paramat bc1e54764b Fix warnings about dungeongen.cpp memcpy() and unused variable in MapBlock::deSerializeNetworkSpecific() (#8122)
* Fix warning about dungeongen.cpp memcpy()

* Fix unused variable in MapBlock::deSerializeNetworkSpecific()

* Fix unused variable a simpler way
2019-01-22 22:13:06 +01:00
Treer 84a5fa01ff Fix Mapgen Valleys getSpawnLevelAtPoint() (#7756) 2018-10-03 00:50:21 +01:00
Paramat 8543df7752
Fix various code issues found by cppcheck (#7741)
Mapgen Singlenode: Remove 'flags' that duplicates a 'class Mapgen' member.
Dungeongen: Initialise 'MMVManip *vm' to 'nullptr'.
Inventorymanager: Remove assignment error 'found = '.
2018-09-23 20:12:39 +01:00
Paramat 8516f28458
Change mapgen order to ores > dungeons > decorations (#7656)
Previously dungeons > decorations > ores.
Decorations depend on the node they are placed on, and ore types are
increasingly able to place large continuous volumes of nodes, such as
strata. Decorations are increasingly being used underground.

The new order avoids a node being changed by ore generation after a
decoration has been placed on it.
The new order also avoids ores appearing in the walls of a dungeon if
the wall nodes match the local stone node.
2018-08-20 18:24:53 +01:00
Paramat 4dff0021b8 Mgv5: Change tunnel parameters to those of other mapgens (#7641)
Make tunnels wider and use the noise parameters of most other mapgens.
All other underground features are already identical to all other
non-mgv6 mapgens, this final change modernises and improves the tunnels.
2018-08-16 20:10:56 +02:00
zeuner d7d451c647 Fix build on gcc 5.0 (#7586) 2018-07-26 21:49:38 +02:00
Paramat bc9bb63aed
Mgvalleys: Make river depth variation and humidity drop optional (#7532)
Add 2 new mapgen flags to make river depth variation and humidity drop
with altitude independently optional, instead of both being enabled by
the 'humid rivers' flag.

Simplify and clarify related code by removing a low priority
optimisation regarding 't_heat'.
Remove unnecessary optimisation bools and use spflags directly instead.
Improve and fix documentation in settingtypes.txt.
A few minor code cleanups.
2018-07-18 03:34:05 +01:00
Paramat 93661ca212
Cavegen: Fix errors when getting biome outside mapchunk (#7480)
Some cave segments are outside the mapchunk.

Previously, biome was being calculated by a function that uses the noise
maps. Points outside the mapchunk resulted in incorrect noise map indexes
that were sometimes outside the noise map size, causing a crash.

Use either noise maps or point noise calculations depending on point
location.
2018-06-26 19:35:23 +01:00
Paramat de621d5d4b
Decoration API: Add lightweight ability to have complete coverage (#7456)
When the noise value or fill_ratio >= 10.0 complete coverage is enabled.
This disables random placement to avoid redundant multiple placements
at one position. Instead, 1 decoration per surface node is placed by
looping across each division.

'10' was chosen as this is the fill_ratio that previously created
very near complete coverage. The complete coverage feature therefore
integrates smoothly when noise is used for variable decoration density.

'fill_ratio = 10' should be used by modders who want a decoration
placed on every surface node. Compared to before such a decoration
placement will be 10 times faster.
2018-06-24 17:14:18 +01:00
Paramat 8d3190e77a
Biome API: Fix absent water decorations and dust, in deep water (#7470)
Previously, the biomemap was 'BIOME_NONE' for a mapchunk column if a
stone surface was not found in it, causing water surface decorations
and water surface dust to fail.

Store the biome ID of the biome calculated at a water surface and add
it to the biomemap if the biomemap is 'BIOME_NONE' for the mapchunk
column. The biome calculated at a stone surface still has priority
for the biomemap entry, as it should.

Edit an incorrect comment.
2018-06-21 19:28:54 +01:00
Paramat 86389329eb
Biome dust: Revert fix that added dust to mod structures (#7464)
Revert commit 99143f4947 and commit
f4ca830abe.

These commits caused biome dust to be applied even when there was no core
mapgen terrain in a mapchunk column. So the dust, which overgenerates,
then appeared on structures added by mods in 'on_generated', such as
floatlands, asteroids or above-surface realms.
2018-06-19 22:09:42 +01:00
Paramat 0b23253447
Mapgen flags: Add 'biomes' global mapgen flag (#7355)
Previously the only way to disable biomes was to 'clear' the registered
biomes in a mod, but this method causes large amounts of unnecessary
processing:
1. Calculation of 4 2D noises.
2. Looping through all nodes of a mapchunk replacing nodes with identical
nodes.
The new flag disables those operations.
2018-06-08 23:24:36 +01:00
Paramat 86b19f2849
Biome dust placement: Improve comments, re-order some lines 2018-06-04 00:39:10 +01:00
Paramat f4ca830abe
Biomemap: Simplify code of recent commit (#7398) 2018-06-02 21:28:26 +01:00
Paramat 99143f4947
Biomemap: Avoid empty biomemap entry to fix failing biome dust (#7393)
'generateBiomes()' constructs the biomemap as it generates biomes.
The biome calculated at first stone surface encountered is added to
the biomemap.
Previously, if no stone surface was encountered in a mapchunk column
the biomemap was left empty for that (x, z) position, causing biome
dust and water surface decoration placement to fail.

If at the base of a mapchunk column the biomemap is empty, add the
currently active biome to the biomemap, or if biome is NULL calculate
it for this position and add it to the biomemap.
2018-06-02 03:20:09 +01:00
Paramat df991edaa8
Mgv7: Avoid rivergen removing mod-placed nodes when overgenerating (#7388)
Only allow river generation to replace c_stone.
This also acts as an optimisation by being placed before canyon shape
calculation.
2018-05-31 03:06:55 +01:00
Paramat 5c1edc58ab
Vein ore: Fix bug caused by changing perlinmap Y size (#7371)
Because vein ore uses 3D noise (all the other ores use 2D noise) the
perlinmap Y size can be different in different mapchunks when close
to the ore Y limits.
Previously this caused bugs in the vein structure because changes in
perlinmap Y size did not recreate the noise objects.

Delete and recreate the noise objects with the new Y size if Y size
has changed.
2018-05-24 22:20:06 +01:00
Paramat d6a6d3176e
Schematic decorations: Fix placement bug when centred and rotated (#7365)
Previously, the centering caused by the 'place center x/z' flags did
not take rotation into account. So schematics with unequal X and Z
dimensions were incorrectly placed. The bug was hidden for schematics
equal in X and Z dimensions.
2018-05-24 02:52:35 +01:00
Paramat 53d5b3ea40
Dungeons: Fix duplication of y limit parameters (#7359) 2018-05-20 23:45:53 +01:00
Paramat a01a9ca24c
Vertical biome blend: Tune PRNG seed for finer detail (#7329) 2018-05-14 19:01:58 +01:00
Paramat 4ccd18d5ec
Mgv7: Code cleanup (#7299) 2018-05-07 03:31:55 +01:00
Paramat 21c720755b
Cavegen: Allow small RandomWalk caves to generate beyond mapchunk border 2018-05-04 18:22:56 +01:00
Paramat 54606e103d
Mapgen caves: Re-order generation to fix cavern bug
Previously, caverns confused tunnel generation causing biome top and filler
nodes to appear in caverns.
Split 'generateCaves()' into 2 functions to separate tunnel and large
randomwalk cave generation.
In each mapgen re-order cave generation to generate tunnels before caverns.
2018-04-29 07:20:46 +01:00
paramat bb3baef30f Biome-defined cave liquids: Use faster biome calculation 2018-04-26 17:28:37 +02:00
paramat 9d7335a99c Biome-defined dungeon nodes: Use faster biome calculation 2018-04-26 17:27:06 +02:00
Paramat 454f80a0f7
Dungeons: Mostly fix missing stair nodes 2018-04-25 00:44:49 +01:00
Paramat 534971ccd0
Mgvalleys: Code cleanup
Split some long lines.
Edit comments.
Remove unnecessary comments and unnecessary commented-out code.
Use std::fmax/fmin instead of MYMAX/MYMIN.
Remove scope-limiting braces.
Consistently define literals as floats, except in noise parameters.
Cleanup literals in noise parameters.
Remove unnecessary 'near_cavern' line.
Reduce max spawn y to be consistent with other mapgens.
2018-04-24 01:34:48 +01:00
Paramat 12a8f8826d
Mgvalleys: Use shared tunnel / cavern code instead of internal
Caverns first appeared in mgvalleys and were later added to other
mapgens as shared code. Now this shared code can replace mgvalley's
internal cavern code.
Also use shared tunnel code instead of internal code.

Changes to mapgen that will affect existing worlds (mgvalleys is not
stable):

Single lava and water sources not added in tunnels.
Previous caverns are unchanged but an equal number of new ones are
added at a distance from the previous.
From y = -256 to 192 nodes below, where the caverns taper at their
upper limit, they will have a slightly different shape as the taper
is now linear.
2018-04-21 22:50:36 +01:00
Paramat 5abd0efb90
Cave liquids: Use a more precise point for calculating biome
Use the centre point of the route being carved for a more precise match
between cave liquids and biome.
2018-04-21 20:35:29 +01:00
Paramat 0e554706ac
Node resolver: Make error on fallback optional, disable for mapgen aliases 2018-04-20 20:26:30 +01:00
Paramat cca925377b
Cavegen: Fix variable typo that broke mgvalleys large cave distribution (#7249)
Fix elusive 5 year old bug that caused mgvalleys large caves to be flat and
limited to mapchunk borders.
Error was fixed 2 years ago in 'CavesV6' but not in 'CavesRandomWalk'.
2018-04-17 22:25:59 +01:00
Paramat 746ca41f58
Biome API / dungeons: Add biome-defined dungeon nodes
Add new biome fields 'node_dungeon', 'node_dungeon_alt', 'node_dungeon_stair'.
If 'node_dungeon' is not defined dungeons fall back to classic behaviour.

Remove messy and imprecise dungeon material code from 'generateBiomes()'.
Code deciding dungeon materials is now in 'generateDungeons()' and uses the
biome at mapchunk centre for more precision.

Remove hardcoded 'MG_STONE' types as long intended.
2018-04-07 22:09:54 +01:00
Paramat 7e3f88f539
Mgcarpathian: Fix spawn level calculation (#7212) 2018-04-06 00:10:16 +01:00
Paramat 5701f9e389
Mgcarpathian: Remove insignificant 'base' noise variation (#7209)
Was only +-1 node over a scale of thousands of nodes.
Replace with 'base_level' parameter value.
2018-04-05 21:52:10 +01:00
Paramat 32d456bd2d
Biome API / cavegen: Add definable cave liquid for a biome (#7192)
Add 'node_cave_liquid' as a new field in biome registration.
If field is absent cave liquids fall back to classic behaviour.
2018-04-05 17:21:41 +01:00
Loïc Blot 67a4cb7d8a Fix various clang-tidy reported performance-type-promotion-in-math-fn 2018-04-03 18:16:17 +02:00
Loïc Blot 2481ea27ce
Fix many issues reported by clang-tidy (#7189)
* Fix many issues reported by clang-tidy

We have many issues in code related to some performance to float <-> double.
Clang-tidy reported it in performance-type-promotion-in-math-fn

I fixed many of them. It's not ready for a promote to blocking

Also fix some value which should be const-ref
2018-04-02 23:51:08 +02:00
Paramat 2c490dddc0
Mgcarpathian: Mapgen loop optimisations. fabs() -> std::fabs()
* Mgcarpathian: ZYX -> ZXY mapgen loop optimisation.

* 'pow(n, 3)' to 'n * n * n' type optimisations.

* fabs() -> std::fabs().
2018-03-29 21:08:42 +01:00
Paramat 2f280cc672
Mapgen: Remove unused mgv7 code and some unused biometypes 2018-03-26 04:59:49 +01:00
paramat 19c993bc39 Biomes: Fix vertical biome blend 2018-03-16 02:59:38 +00:00
paramat 7ad6cdd09b Biome API: Add 'get_biome_name(biome_id)' API
Change name of default biome to a more suitable lowercase 'default'.
2018-03-11 23:06:17 +00:00
Loic Blot 12d1e4ff04 VoxelArea: add_{x,y,z,p} must be static
Fix some documentations issues
Use getNodeNoCheck(v3s16, ...) in some cases instead of getNodeNoCheck(x, y, z, ...)
2018-03-09 23:27:26 +01:00
paramat cbb9301bea Biomes: Add 'min_pos'/'max_pos' xyz biome limits
'y_min' and 'y_max' are still accepted for compatibility.
2018-03-09 03:16:25 +00:00
paramat 07622bf9b4 Generate Notifier: Clear events once after all 'on generated' functions 2018-03-03 22:59:49 +00:00
Gael-de-Sailly b952d42000 MapgenValleys: Fixed submarine valleys shape 2018-03-03 22:59:26 +00:00
paramat c610643c4c Place schematic (on vmanip): Enable use of 'place center' flags
For 'place schematic' and 'place schematic on vmanip' APIs.
Fix 'place center' code to properly centre schematics.
Fix some comments.
2018-02-27 19:39:05 +00:00
paramat 359a940dde SAO limits: Allow SAOs to exist outside the set 'mapgen limit' 2018-02-26 17:21:45 +00:00
paramat f9ad061910 Vertical biome blend: Tune blend patterns 2018-02-20 15:28:52 +00:00
paramat 2bc7c5ff93 Dungeons: Add Y limits in all mapgens
Preserve the upper limit used in mgvalleys.
2018-02-20 15:25:37 +00:00
paramat 861cfd8484 Dungeons: Avoid generation in multiple liquid nodes and 'airlike'
Previously only 'mapgen water source' and 'mapgen river water source'
were checked for. Games can use multiple liquid nodes defined for biomes,
many of which will not be aliased to those 2 mapgen aliases, causing
floating dungeons to generate in some liquids.

Now we check for liquid drawtype instead, so can remove liquid nodes
from dungeonparams.

Also check for 'airlike' drawtype instead of 'CONTENT_AIR' to avoid
generation in 'airlike' nodes in some rare situations. This will also be
needed for when we add definable biome air nodes.
2018-02-13 03:48:39 +00:00
Dániel Juhász 3face01a20 Node definition manager refactor (#7016)
* Rename IWritableNodeDefManager to NodeDefManager
* Make INodeDefManager functions const
* Use "const *NodeDefManager" instead of "*INodeDefManager"
* Remove unused INodeDefManager class
* Merge NodeDefManager and CNodeDefManager
* Document NodeDefManager
2018-02-10 21:04:16 +01:00
paramat d45e5da8ca Biomes: Add 'get heat', 'get humidity', 'get biome data' APIs
'get biome data' returns biome id, heat and humidity.
Clean up nearby lines in lua_api.txt.
2018-01-16 08:47:07 +00:00
paramat 142474196a Mapgen folder: Update and improve copyright information of files 2018-01-15 04:42:08 +00:00
Paramat 549cfd9db8 Biomes: Add vertical biome blend (#6853)
Add 'vertical blend' parameter to biome registration that defines how
many nodes above the biome's 'y max' limit the blend will extend.
2018-01-05 00:10:55 +01:00
paramat 2aad3be2cb Mgv7 floatlands: Add exponent parameter
Allows more control over shape of floatland mountain terrain.
Terrain shape is unchanged.
2018-01-03 04:05:55 +00:00
adrido d677f292cc Use std::vector instead of dynamic C-Array (#6744) 2017-12-10 09:07:24 +01:00
paramat 4b553ece09 Stratum ore: Add option for a constant thickness stratum
Add a 'stratum thickness' integer parameter, as an alternative
to providing a 2nd noise parameter for thickness variation.
2017-11-19 00:25:39 +00:00
paramat ec93893c7f Biome dust node: Only place on 'walkable' cubic non-liquid drawtypes
No longer decide placement on 'buildable_to' parameter.
Dust nodes only look acceptable placed on cubic nodes.
Modders may not want to make their plantlike decorations 'buildable_to'.
2017-11-17 19:27:06 +00:00
Vitaliy 20a85d76d9 Move files to subdirectories (#6599)
* Move files around
2017-11-08 23:56:20 +01:00