mirror of
https://github.com/minetest/minetest.git
synced 2024-10-02 07:53:09 +02:00
Skip invalid objects in raycasts
This commit is contained in:
parent
d4e8da1041
commit
0ad415c18d
@ -155,6 +155,7 @@ void LuaLBM::trigger(ServerEnvironment *env, v3s16 p,
|
|||||||
int LuaRaycast::l_next(lua_State *L)
|
int LuaRaycast::l_next(lua_State *L)
|
||||||
{
|
{
|
||||||
GET_PLAIN_ENV_PTR;
|
GET_PLAIN_ENV_PTR;
|
||||||
|
ServerEnvironment *senv = dynamic_cast<ServerEnvironment*>(env);
|
||||||
|
|
||||||
bool csm = false;
|
bool csm = false;
|
||||||
#ifndef SERVER
|
#ifndef SERVER
|
||||||
@ -163,7 +164,17 @@ int LuaRaycast::l_next(lua_State *L)
|
|||||||
|
|
||||||
LuaRaycast *o = checkObject<LuaRaycast>(L, 1);
|
LuaRaycast *o = checkObject<LuaRaycast>(L, 1);
|
||||||
PointedThing pointed;
|
PointedThing pointed;
|
||||||
env->continueRaycast(&o->state, &pointed);
|
for (;;) {
|
||||||
|
env->continueRaycast(&o->state, &pointed);
|
||||||
|
if (pointed.type != POINTEDTHING_OBJECT)
|
||||||
|
break;
|
||||||
|
if (!senv)
|
||||||
|
break;
|
||||||
|
const auto *obj = senv->getActiveObject(pointed.object_id);
|
||||||
|
if (obj && !obj->isGone())
|
||||||
|
break;
|
||||||
|
// skip gone object
|
||||||
|
}
|
||||||
if (pointed.type == POINTEDTHING_NOTHING)
|
if (pointed.type == POINTEDTHING_NOTHING)
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user