From 073fa5883923c60d24c75b2d6f6887709b68fd44 Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Thu, 7 Aug 2014 12:42:30 +1000 Subject: [PATCH] Fix l-system crash when treedef random_level not set by Lua --- src/script/lua_api/l_env.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 10aaddcc5..5a6603342 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -747,7 +747,8 @@ int ModApiEnvMod::l_spawn_tree(lua_State *L) } getintfield(L, 2, "angle", tree_def.angle); getintfield(L, 2, "iterations", tree_def.iterations); - getintfield(L, 2, "random_level", tree_def.iterations_random_level); + if (!getintfield(L, 2, "random_level", tree_def.iterations_random_level)) + tree_def.iterations_random_level = 0; getstringfield(L, 2, "trunk_type", tree_def.trunk_type); getboolfield(L, 2, "thin_branches", tree_def.thin_branches); tree_def.fruit_chance=0;