@@ -50,6 +50,8 @@ ObjectRef* ObjectRef::checkobject(lua_State *L, int narg)
50
50
ServerActiveObject* ObjectRef::getobject (ObjectRef *ref)
51
51
{
52
52
ServerActiveObject *co = ref->m_object ;
53
+ if (co && co->isGone ())
54
+ return NULL ;
53
55
return co;
54
56
}
55
57
@@ -60,8 +62,6 @@ LuaEntitySAO* ObjectRef::getluaobject(ObjectRef *ref)
60
62
return NULL ;
61
63
if (obj->getType () != ACTIVEOBJECT_TYPE_LUAENTITY)
62
64
return NULL ;
63
- if (obj->isGone ())
64
- return NULL ;
65
65
return (LuaEntitySAO*)obj;
66
66
}
67
67
@@ -72,8 +72,6 @@ PlayerSAO* ObjectRef::getplayersao(ObjectRef *ref)
72
72
return NULL ;
73
73
if (obj->getType () != ACTIVEOBJECT_TYPE_PLAYER)
74
74
return NULL ;
75
- if (obj->isGone ())
76
- return NULL ;
77
75
return (PlayerSAO*)obj;
78
76
}
79
77
@@ -132,7 +130,6 @@ int ObjectRef::l_set_pos(lua_State *L)
132
130
{
133
131
NO_MAP_LOCK_REQUIRED;
134
132
ObjectRef *ref = checkobject (L, 1 );
135
- // LuaEntitySAO *co = getluaobject(ref);
136
133
ServerActiveObject *co = getobject (ref);
137
134
if (co == NULL ) return 0 ;
138
135
// pos
@@ -147,7 +144,6 @@ int ObjectRef::l_move_to(lua_State *L)
147
144
{
148
145
NO_MAP_LOCK_REQUIRED;
149
146
ObjectRef *ref = checkobject (L, 1 );
150
- // LuaEntitySAO *co = getluaobject(ref);
151
147
ServerActiveObject *co = getobject (ref);
152
148
if (co == NULL ) return 0 ;
153
149
// pos
@@ -1102,17 +1098,13 @@ int ObjectRef::l_add_player_velocity(lua_State *L)
1102
1098
ObjectRef *ref = checkobject (L, 1 );
1103
1099
v3f vel = checkFloatPos (L, 2 );
1104
1100
1105
- RemotePlayer *player = getplayer (ref);
1106
1101
PlayerSAO *co = getplayersao (ref);
1107
- if (!player || ! co)
1102
+ if (!co)
1108
1103
return 0 ;
1109
1104
1110
- session_t peer_id = player->getPeerId ();
1111
- if (peer_id == PEER_ID_INEXISTENT)
1112
- return 0 ;
1113
1105
// Do it
1114
1106
co->setMaxSpeedOverride (vel);
1115
- getServer (L)->SendPlayerSpeed (peer_id , vel);
1107
+ getServer (L)->SendPlayerSpeed (co-> getPeerID () , vel);
1116
1108
return 0 ;
1117
1109
}
1118
1110
0 commit comments