From 70da8a940b054d0ad22168af47fed4b7c091914f Mon Sep 17 00:00:00 2001 From: paramat Date: Fri, 19 Jun 2015 00:17:03 +0100 Subject: Mapgen objects: Enable heatmap and humidmap for all biome api mapgens --- src/script/lua_api/l_mapgen.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 1a462adf7..2d67e2f29 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -510,21 +510,26 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L) return 1; } - case MGOBJ_HEATMAP: { // Mapgen V7 specific objects - case MGOBJ_HUMIDMAP: - if (strcmp(emerge->params.mg_name.c_str(), "v7")) + case MGOBJ_HEATMAP: { + if (!mg->heatmap) return 0; - MapgenV7 *mgv7 = (MapgenV7 *)mg; + lua_newtable(L); + for (size_t i = 0; i != maplen; i++) { + lua_pushnumber(L, mg->heatmap[i]); + lua_rawseti(L, -2, i + 1); + } + + return 1; + } - float *arr = (mgobj == MGOBJ_HEATMAP) ? - mgv7->noise_heat->result : mgv7->noise_humidity->result; - if (!arr) + case MGOBJ_HUMIDMAP: { + if (!mg->humidmap) return 0; lua_newtable(L); for (size_t i = 0; i != maplen; i++) { - lua_pushnumber(L, arr[i]); + lua_pushnumber(L, mg->humidmap[i]); lua_rawseti(L, -2, i + 1); } -- cgit v1.2.3