aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen/mapgen.cpp
AgeCommit message (Collapse)Author
2022-12-03Add `minetest.get_mapgen_edges` (#12999)Jude Melton-Houghton
2022-11-09Fix typos and en_US/en_GB inconsistency in various files (#12902)Abdou-31
2022-10-09Optimize lighting calculation (#12797)Jude Melton-Houghton
2022-07-09Enforce limits of settings that could cause buggy behaviour (#12450)SmallJoker
Enforces the setting value bounds that are currently only limited by the GUI (settingtypes.txt).
2022-06-20Annotate light spread functions with commentssfan5
2022-06-03fix integer overflow in mapgen (#11641)JosiahWI
* fix integer overflow in mapgen Some calculations involving the magic seed had overflow because the result of an intermediate arithmetic step could not fit in an s32. By making the magic seed unsigned, the other operand in the equation will be cast to unsigned, and possibly other operands or intermediate operands. This will result in unexpected behavior if an operand is negative, which is technically possible, but logically should not happen. * comment noise2d bitshift While working through the code I was momentarily concerned that the right bitshift in noise2d could fill ones in some cases. It turns out that with signed integers, this is indeed true, but this one is shifting an unsigned integer, so the behavior is as expected. I put a comment here to clarify this, in case someone else wonders the same thing down the line. * noise2d and noise3d unittests I have added 3 tests each for noise2d and noise3d, testing all zero inputs, a very large seed (case which caused UB in the old implementation) and some fun primes I picked for no particular reason. This should be sufficient to demonstrate that the behavior of the new implementation has not changed. I used uniform initialization because it is a good feature of C++11. Please do not explode. * uncomment the noise2d bitshift This reverts commit 583b77ee9f1ad6bb77340ebb5ba51eb9a88ff51c. It's a well-defined language semantic; it doesn't need to be commented. * code cleanliness
2022-01-09Mainmenu game-related changes (#11887)sfan5
fixes: * Switching between games does not immediately hide creative mode / damage buttons if so specified * World creation menu has a game selection list even though the menu already provides a gamebar * Showing gameid in world list is unnecessary * Choice of mapgen parameters in menu persists between games (and was half-broken)
2021-03-23Fix broken `BiomeGen` abstraction (#11107)sfan5
2020-10-05Remove unused functions reported by cppcheck (#10463)SmallJoker
Run unused functions reported by cppcheck This change removes a few (but not all) unused functions. Some unused helper functions were not removed due to their complexity and potential of future use.
2020-09-03Add 'ores' global mapgen flag (#10276)Paramat
2020-05-05Give the Mapgen on each EmergeThread its own Biome/Ore/Deco/SchemManager copysfan5
2020-04-11Drop content_sao.{cpp,h}Loic Blot
Move LuaEntitySAO to a new dedicated file Drop TestSAO (useless object) Drop the old static startup initialized SAO factory, which was pretty useless. This factory was using a std::map for 2 elements, now just use a simple condition owned by ServerEnvironment, which will be lightweight, that will also drop a one time useful test on each LuaEntitySAO creation. This should reduce server load on massive SAO creation
2020-04-10Print error if invalid mapgen alias was detected (#9579)Wuzzy
2020-01-25Settings: Add get_flags API for mapgen flags (mg_flags, mgv6_spflags, ...) ↵SmallJoker
(#9284) Unified flags handling in C++ and Lua Settings API -> Reading only, for now. Writing can be implemented later, if needed. API function to read the currently active flags -> was impossible from Lua Co-authored-by: Wuzzy <wuzzy2@mail.ru>
2019-11-23Caves: Fix shadowing of 'large_cave_depth' to avoid confusionparamat
2019-11-23Dungeons: Move duplicated y limit checks to generation functionparamat
2019-11-18Randomwalk cave liquids: Remove deprecated 'lava depth' parameter (#9105)Paramat
Low-disruption first step towards removing the hardcoded cave liquid code. Since MT 5.0.0 cave liquids can be defined and located by biome definitions instead. In games that do not yet use biome definitions to define and locate cave liquids (MTGame does), lava will now appear below y = water_level - 256 instead of below 'lava depth' (usually y = -256). Therefore no change in most mapgens if using the default 'lava depth'.
2019-11-09Tunnels: Completely disable generation when 'cave width' >= 10.0 (#9093)Paramat
Previously, the only way to disable the 3D noise tunnels was to set 'cave width' > 1.0, however doing so did not disable the very intensive noise calculations or the generation loop. All the other types of cave generation (randomwalk caves, caverns) can already be independently and completely disabled. This feature is now needed more because the small randomwalk caves are now available for use as an alternative to the 3D noise tunnels.
2019-11-08Randomwalk caves: Add parameters for number, proportion flooded. Allow small ↵Paramat
caves (#8928) Add mapgen parameters to set the range of the random number of randomwalk caves per mapchunk, and to set the proportion that are flooded with liquids. Default values are, for now, unchanged from the previous hardcoded values. Add parameters to allow small randomwalk caves Disabled by default for now as they have never been present in the non-mgv6 mapgens.
2019-09-14Dungeons: Clean up parameters, improve structure variety (#8918)Paramat
While preserving the general character of dungeon structure. Slightly increase the range of standard room horizontal size, while preserving the average horizontal size. Return to classic maximum large room size of 16x16x16. Make 1 in 4 dungeons have a 1 in 8 chance for each room being 'large', making multiple large rooms possible for the first time. Make 1 in 8 dungeons allow diagonal corridors, to make these a little more common. Make corridor width vary from 1 to 2, but forced to 2 if diagonal corridors are allowed, to make them passable. Add some comments.
2019-08-23Make Mapgen::spreadLight use a queue (#8838)DS
2019-08-13Better F6 profiler (#8750)SmallJoker
Update the profiler names to make more sense of what they actually represent Move the profiler code from header to its source file Use monospace font to align lines Format the statistics line to align better with surrounding values Refresh the profiler each 3 seconds (roughly)
2019-07-25Re-order mapgens in mainmenu and 'all settings' mapgen selection (#8705)Paramat
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-16Dungeons: Make multiple large rooms possible (#8678)Paramat
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-09Move more dungeon parameter selection to mapgens (#8653)Paramat
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-06-30Dungeongen: Remove most hardcoded dungeon nodes (#8594)Paramat
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-01Dungeons: Settable density noise, move number calculation to mapgens (#8473)Paramat
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-03-31Fix commentsLoic Blot
2019-03-31mapgen: drop mapgen id from child mapgens.Loïc Blot
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
2018-06-21Biome API: Fix absent water decorations and dust, in deep water (#7470)Paramat
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-19Biome dust: Revert fix that added dust to mod structures (#7464)Paramat
Revert commit 99143f494711034068685b6ee845ce19fa09d7d9 and commit f4ca830abe1aa22875c99b31bf2ee56e26f83f05. 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-08Mapgen flags: Add 'biomes' global mapgen flag (#7355)Paramat
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-04Biome dust placement: Improve comments, re-order some linesParamat
2018-06-02Biomemap: Simplify code of recent commit (#7398)Paramat
2018-06-02Biomemap: Avoid empty biomemap entry to fix failing biome dust (#7393)Paramat
'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-05-20Dungeons: Fix duplication of y limit parameters (#7359)Paramat
2018-04-29Mapgen caves: Re-order generation to fix cavern bugParamat
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-26Biome-defined dungeon nodes: Use faster biome calculationparamat
2018-04-07Biome API / dungeons: Add biome-defined dungeon nodesParamat
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-05Biome API / cavegen: Add definable cave liquid for a biome (#7192)Paramat
Add 'node_cave_liquid' as a new field in biome registration. If field is absent cave liquids fall back to classic behaviour.
2018-03-09VoxelArea: add_{x,y,z,p} must be staticLoic Blot
Fix some documentations issues Use getNodeNoCheck(v3s16, ...) in some cases instead of getNodeNoCheck(x, y, z, ...)
2018-03-09Biomes: Add 'min_pos'/'max_pos' xyz biome limitsparamat
'y_min' and 'y_max' are still accepted for compatibility.
2018-03-03Generate Notifier: Clear events once after all 'on generated' functionsparamat
2018-02-26SAO limits: Allow SAOs to exist outside the set 'mapgen limit'paramat
2018-02-13Dungeons: Avoid generation in multiple liquid nodes and 'airlike'paramat
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-01-15Mapgen folder: Update and improve copyright information of filesparamat
2017-12-10Use std::vector instead of dynamic C-Array (#6744)adrido
2017-11-17Biome dust node: Only place on 'walkable' cubic non-liquid drawtypesparamat
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-08Move files to subdirectories (#6599)Vitaliy
* Move files around