forked from Mirrorlandia_minetest/minetest
Fix core.get_player_by_name() returning unusable ObjectRef
Followup to the previous commit.
This commit is contained in:
parent
1761d7d0f8
commit
6d8e2d2483
@ -667,15 +667,11 @@ int ModApiEnvMod::l_get_player_by_name(lua_State *L)
|
|||||||
// Do it
|
// Do it
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
RemotePlayer *player = env->getPlayer(name);
|
RemotePlayer *player = env->getPlayer(name);
|
||||||
if (player == NULL){
|
if (!player || player->getPeerId() == PEER_ID_INEXISTENT)
|
||||||
lua_pushnil(L);
|
return 0;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
PlayerSAO *sao = player->getPlayerSAO();
|
PlayerSAO *sao = player->getPlayerSAO();
|
||||||
if(sao == NULL){
|
if (!sao || sao->isGone())
|
||||||
lua_pushnil(L);
|
return 0;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// Put player on stack
|
// Put player on stack
|
||||||
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
|
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user