Fix potential problem with core.get_connected_players()
authorsfan5 <sfan5@live.de>
Tue, 25 Feb 2020 15:08:47 +0000 (16:08 +0100)
committersfan5 <sfan5@live.de>
Tue, 25 Feb 2020 15:08:47 +0000 (16:08 +0100)
src/script/lua_api/l_env.cpp

index 7d5de896d750250561a4b80c5829bb77bb85bf9e..ac52941b3553df61ff7df392861573bb411ebf96 100644 (file)
@@ -648,6 +648,8 @@ int ModApiEnvMod::l_get_connected_players(lua_State *L)
        lua_createtable(L, env->getPlayerCount(), 0);
        u32 i = 0;
        for (RemotePlayer *player : env->getPlayers()) {
+               if (player->getPeerId() == PEER_ID_INEXISTENT)
+                       continue;
                PlayerSAO *sao = player->getPlayerSAO();
                if (sao) {
                        getScriptApiBase(L)->objectrefGetOrCreate(L, sao);