Fix crash when accessing variables from a map generator

On some machines, the crash doesn't occur, but the variable is still not loaded correctly.

Addresses #5896
This commit is contained in:
Celtic Minstrel 2021-07-10 21:47:18 -04:00 committed by Celtic Minstrel
parent 2968aca834
commit 35911a3dcc

View file

@ -300,10 +300,12 @@ void mapgen_lua_kernel::user_config(const char * prog, const config & generator)
int mapgen_lua_kernel::intf_get_variable(lua_State *L)
{
char const *m = luaL_checkstring(L, 1);
variable_access_const v(m, vars_ ? *vars_ : config());
return luaW_pushvariable(L, v) ? 1 : 0;
if(vars_) {
variable_access_const v(m, *vars_);
return luaW_pushvariable(L, v) ? 1 : 0;
}
return 0;
}
int mapgen_lua_kernel::intf_get_all_vars(lua_State *L) {