Skip to content

Commit

Permalink
Fix core.get_player_by_name() returning unusable ObjectRef
Browse files Browse the repository at this point in the history
Followup to the previous commit.
  • Loading branch information
sfan5 committed Mar 3, 2020
1 parent 1761d7d commit 6d8e2d2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/script/lua_api/l_env.cpp
Expand Up @@ -667,15 +667,11 @@ int ModApiEnvMod::l_get_player_by_name(lua_State *L)
// Do it
const char *name = luaL_checkstring(L, 1);
RemotePlayer *player = env->getPlayer(name);
if (player == NULL){
lua_pushnil(L);
return 1;
}
if (!player || player->getPeerId() == PEER_ID_INEXISTENT)
return 0;
PlayerSAO *sao = player->getPlayerSAO();
if(sao == NULL){
lua_pushnil(L);
return 1;
}
if (!sao || sao->isGone())
return 0;
// Put player on stack
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
return 1;
Expand Down

0 comments on commit 6d8e2d2

Please sign in to comment.