aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-04-17 01:03:13 -0400
committerkwolekr <kwolekr@minetest.net>2015-04-17 01:03:13 -0400
commit3576f4fab7267ff6d110fe94b6f397d6471a6980 (patch)
treed9ef53e2d65140874d95a5ec579846cbfeb1c550 /src/script/lua_api
parent406d9ba87b9f6e57b86c6282bf157e3341aa195c (diff)
downloadminetest-3576f4fab7267ff6d110fe94b6f397d6471a6980.tar.gz
minetest-3576f4fab7267ff6d110fe94b6f397d6471a6980.tar.bz2
minetest-3576f4fab7267ff6d110fe94b6f397d6471a6980.zip
Switch to check_v3s16 in l_mapgen.cpp and l_vmanip.cpp for type safety
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_mapgen.cpp18
-rw-r--r--src/script/lua_api/l_vmanip.cpp18
2 files changed, 18 insertions, 18 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index c2b461b43..c063919ba 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -244,7 +244,7 @@ bool read_schematic_def(lua_State *L, int index,
//// Get schematic size
lua_getfield(L, index, "size");
- v3s16 size = read_v3s16(L, -1);
+ v3s16 size = check_v3s16(L, -1);
lua_pop(L, 1);
schem->size = size;
@@ -995,9 +995,9 @@ int ModApiMapgen::l_generate_ores(lua_State *L)
mg.vm = LuaVoxelManip::checkobject(L, 1)->vm;
mg.ndef = getServer(L)->getNodeDefManager();
- v3s16 pmin = lua_istable(L, 2) ? read_v3s16(L, 2) :
+ v3s16 pmin = lua_istable(L, 2) ? check_v3s16(L, 2) :
mg.vm->m_area.MinEdge + v3s16(1,1,1) * MAP_BLOCKSIZE;
- v3s16 pmax = lua_istable(L, 3) ? read_v3s16(L, 3) :
+ v3s16 pmax = lua_istable(L, 3) ? check_v3s16(L, 3) :
mg.vm->m_area.MaxEdge - v3s16(1,1,1) * MAP_BLOCKSIZE;
sortBoxVerticies(pmin, pmax);
@@ -1019,9 +1019,9 @@ int ModApiMapgen::l_generate_decorations(lua_State *L)
mg.vm = LuaVoxelManip::checkobject(L, 1)->vm;
mg.ndef = getServer(L)->getNodeDefManager();
- v3s16 pmin = lua_istable(L, 2) ? read_v3s16(L, 2) :
+ v3s16 pmin = lua_istable(L, 2) ? check_v3s16(L, 2) :
mg.vm->m_area.MinEdge + v3s16(1,1,1) * MAP_BLOCKSIZE;
- v3s16 pmax = lua_istable(L, 3) ? read_v3s16(L, 3) :
+ v3s16 pmax = lua_istable(L, 3) ? check_v3s16(L, 3) :
mg.vm->m_area.MaxEdge - v3s16(1,1,1) * MAP_BLOCKSIZE;
sortBoxVerticies(pmin, pmax);
@@ -1040,8 +1040,8 @@ int ModApiMapgen::l_create_schematic(lua_State *L)
Map *map = &(getEnv(L)->getMap());
- v3s16 p1 = read_v3s16(L, 1);
- v3s16 p2 = read_v3s16(L, 2);
+ v3s16 p1 = check_v3s16(L, 1);
+ v3s16 p2 = check_v3s16(L, 2);
sortBoxVerticies(p1, p2);
std::vector<std::pair<v3s16, u8> > prob_list;
@@ -1050,7 +1050,7 @@ int ModApiMapgen::l_create_schematic(lua_State *L)
while (lua_next(L, 3)) {
if (lua_istable(L, -1)) {
lua_getfield(L, -1, "pos");
- v3s16 pos = read_v3s16(L, -1);
+ v3s16 pos = check_v3s16(L, -1);
lua_pop(L, 1);
u8 prob = getintfield_default(L, -1, "prob", MTSCHEM_PROB_ALWAYS);
@@ -1101,7 +1101,7 @@ int ModApiMapgen::l_place_schematic(lua_State *L)
SchematicManager *schemmgr = getServer(L)->getEmergeManager()->schemmgr;
//// Read position
- v3s16 p = read_v3s16(L, 1);
+ v3s16 p = check_v3s16(L, 1);
//// Read rotation
int rot = ROTATE_0;
diff --git a/src/script/lua_api/l_vmanip.cpp b/src/script/lua_api/l_vmanip.cpp
index de7612115..061ee6036 100644
--- a/src/script/lua_api/l_vmanip.cpp
+++ b/src/script/lua_api/l_vmanip.cpp
@@ -46,8 +46,8 @@ int LuaVoxelManip::l_read_from_map(lua_State *L)
LuaVoxelManip *o = checkobject(L, 1);
MMVManip *vm = o->vm;
- v3s16 bp1 = getNodeBlockPos(read_v3s16(L, 2));
- v3s16 bp2 = getNodeBlockPos(read_v3s16(L, 3));
+ v3s16 bp1 = getNodeBlockPos(check_v3s16(L, 2));
+ v3s16 bp2 = getNodeBlockPos(check_v3s16(L, 3));
sortBoxVerticies(bp1, bp2);
vm->initialEmerge(bp1, bp2);
@@ -116,7 +116,7 @@ int LuaVoxelManip::l_get_node_at(lua_State *L)
GET_ENV_PTR;
LuaVoxelManip *o = checkobject(L, 1);
- v3s16 pos = read_v3s16(L, 2);
+ v3s16 pos = check_v3s16(L, 2);
pushnode(L, o->vm->getNodeNoExNoEmerge(pos), env->getGameDef()->ndef());
return 1;
@@ -128,7 +128,7 @@ int LuaVoxelManip::l_set_node_at(lua_State *L)
GET_ENV_PTR;
LuaVoxelManip *o = checkobject(L, 1);
- v3s16 pos = read_v3s16(L, 2);
+ v3s16 pos = check_v3s16(L, 2);
MapNode n = readnode(L, 3, env->getGameDef()->ndef());
o->vm->setNodeNoEmerge(pos, n);
@@ -171,8 +171,8 @@ int LuaVoxelManip::l_calc_lighting(lua_State *L)
v3s16 yblock = v3s16(0, 1, 0) * MAP_BLOCKSIZE;
v3s16 fpmin = vm->m_area.MinEdge;
v3s16 fpmax = vm->m_area.MaxEdge;
- v3s16 pmin = lua_istable(L, 2) ? read_v3s16(L, 2) : fpmin + yblock;
- v3s16 pmax = lua_istable(L, 3) ? read_v3s16(L, 3) : fpmax - yblock;
+ v3s16 pmin = lua_istable(L, 2) ? check_v3s16(L, 2) : fpmin + yblock;
+ v3s16 pmax = lua_istable(L, 3) ? check_v3s16(L, 3) : fpmax - yblock;
sortBoxVerticies(pmin, pmax);
if (!vm->m_area.contains(VoxelArea(pmin, pmax)))
@@ -206,8 +206,8 @@ int LuaVoxelManip::l_set_lighting(lua_State *L)
MMVManip *vm = o->vm;
v3s16 yblock = v3s16(0, 1, 0) * MAP_BLOCKSIZE;
- v3s16 pmin = lua_istable(L, 3) ? read_v3s16(L, 3) : vm->m_area.MinEdge + yblock;
- v3s16 pmax = lua_istable(L, 4) ? read_v3s16(L, 4) : vm->m_area.MaxEdge - yblock;
+ v3s16 pmin = lua_istable(L, 3) ? check_v3s16(L, 3) : vm->m_area.MinEdge + yblock;
+ v3s16 pmax = lua_istable(L, 4) ? check_v3s16(L, 4) : vm->m_area.MaxEdge - yblock;
sortBoxVerticies(pmin, pmax);
if (!vm->m_area.contains(VoxelArea(pmin, pmax)))
@@ -402,7 +402,7 @@ int LuaVoxelManip::create_object(lua_State *L)
Map *map = &(env->getMap());
LuaVoxelManip *o = (lua_istable(L, 1) && lua_istable(L, 2)) ?
- new LuaVoxelManip(map, read_v3s16(L, 1), read_v3s16(L, 2)) :
+ new LuaVoxelManip(map, check_v3s16(L, 1), check_v3s16(L, 2)) :
new LuaVoxelManip(map);
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;