mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fix seg fault if popping from empty stack (L-system trees)
See: https://github.com/minetest/minetest/issues/1525 Background Wuzzy2: If you attempt to spawn a L-system tree with minetest.spawn_tree, you can make Minetest crash if it is attempted to pop an empty stack. ShadowNinja: This shouldn't cause a segmentation fault, but it should throw a Lua error Commit Description This commit throws a Lua error instead of causing a segmentation fault. The server will still "crash" but will include a Lua backtrace. L-Systems fix randomness Unless a random seed is provided (via Lua treedef) seed the PRNG with a different seed for each tree Resolves: https://github.com/minetest/minetest/issues/1469 Fix l-system crash when treedef random_level not set by Lua
This commit is contained in:
parent
996ea60642
commit
f33d31693e
4 changed files with 45 additions and 10 deletions
|
@ -30,6 +30,11 @@ class ServerEnvironment;
|
|||
|
||||
namespace treegen {
|
||||
|
||||
enum error {
|
||||
SUCCESS,
|
||||
UNBALANCED_BRACKETS
|
||||
};
|
||||
|
||||
struct TreeDef {
|
||||
std::string initial_axiom;
|
||||
std::string rules_a;
|
||||
|
@ -50,6 +55,7 @@ namespace treegen {
|
|||
MapNode fruitnode;
|
||||
int fruit_chance;
|
||||
int seed;
|
||||
bool explicit_seed;
|
||||
};
|
||||
|
||||
// Add default tree
|
||||
|
@ -60,10 +66,10 @@ namespace treegen {
|
|||
INodeDefManager *ndef, int seed);
|
||||
|
||||
// Add L-Systems tree (used by engine)
|
||||
void make_ltree(ManualMapVoxelManipulator &vmanip, v3s16 p0, INodeDefManager *ndef,
|
||||
treegen::error make_ltree(ManualMapVoxelManipulator &vmanip, v3s16 p0, INodeDefManager *ndef,
|
||||
TreeDef tree_definition);
|
||||
// Spawn L-systems tree from LUA
|
||||
void spawn_ltree (ServerEnvironment *env, v3s16 p0, INodeDefManager *ndef,
|
||||
treegen::error spawn_ltree (ServerEnvironment *env, v3s16 p0, INodeDefManager *ndef,
|
||||
TreeDef tree_definition);
|
||||
|
||||
// L-System tree gen helper functions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue