aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2016-04-28 03:43:09 -0400
committerkwolekr <kwolekr@minetest.net>2016-05-27 23:23:58 -0400
commit76f485647983ebd7eb4c3abbca0869d13f76920b (patch)
tree6e6f4745311f2ac834780b5bf142dfeeea3aceb0 /src/script/lua_api
parentfa6b21a15b415cd82dce6896b94a5341b7dd76f0 (diff)
downloadminetest-76f485647983ebd7eb4c3abbca0869d13f76920b.tar.gz
minetest-76f485647983ebd7eb4c3abbca0869d13f76920b.tar.bz2
minetest-76f485647983ebd7eb4c3abbca0869d13f76920b.zip
Move biome calculation to BiomeGen
BiomeGen defines an interface that, given a set of BiomeParams, computes biomes for a given area using the algorithm implemented by that specific BiomeGen. This abstracts away the old system where each mapgen supplied the noises required for biome generation.
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_mapgen.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index fb839176b..405b93b86 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -528,24 +528,26 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L)
return 1;
}
case MGOBJ_BIOMEMAP: {
- if (!mg->biomemap)
+ if (!mg->biomegen)
return 0;
lua_newtable(L);
for (size_t i = 0; i != maplen; i++) {
- lua_pushinteger(L, mg->biomemap[i]);
+ lua_pushinteger(L, mg->biomegen->biomemap[i]);
lua_rawseti(L, -2, i + 1);
}
return 1;
}
case MGOBJ_HEATMAP: {
- if (!mg->heatmap)
+ if (!mg->biomegen || mg->biomegen->getType() != BIOMEGEN_ORIGINAL)
return 0;
+ BiomeGenOriginal *bg = (BiomeGenOriginal *)mg->biomegen;
+
lua_newtable(L);
for (size_t i = 0; i != maplen; i++) {
- lua_pushnumber(L, mg->heatmap[i]);
+ lua_pushnumber(L, bg->heatmap[i]);
lua_rawseti(L, -2, i + 1);
}
@@ -553,12 +555,14 @@ int ModApiMapgen::l_get_mapgen_object(lua_State *L)
}
case MGOBJ_HUMIDMAP: {
- if (!mg->humidmap)
+ if (!mg->biomegen || mg->biomegen->getType() != BIOMEGEN_ORIGINAL)
return 0;
+ BiomeGenOriginal *bg = (BiomeGenOriginal *)mg->biomegen;
+
lua_newtable(L);
for (size_t i = 0; i != maplen; i++) {
- lua_pushnumber(L, mg->humidmap[i]);
+ lua_pushnumber(L, bg->humidmap[i]);
lua_rawseti(L, -2, i + 1);
}