]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix core.get_connected_players() returning unusable ObjectRefs
authorsfan5 <sfan5@live.de>
Tue, 3 Mar 2020 19:44:03 +0000 (20:44 +0100)
committersfan5 <sfan5@live.de>
Tue, 3 Mar 2020 20:21:41 +0000 (21:21 +0100)
This bug is only exposed by 91eef646a59575bd9ae792e257bb6ad12fafc0b1
independent of the move of get_connected_players from Lua to C++.
Previously, there would be a small time window where the SAO had
its peer ID set to PEER_ID_INEXISTENT but the RemotePlayer was
still linked to the SAO, resulting in an ObjectRef that crashed
on certain function calls (#9387).

src/script/lua_api/l_env.cpp

index ac52941b3553df61ff7df392861573bb411ebf96..6e67e547bf9792720d30740a0a8d3b946acc36df 100644 (file)
@@ -651,7 +651,7 @@ int ModApiEnvMod::l_get_connected_players(lua_State *L)
                if (player->getPeerId() == PEER_ID_INEXISTENT)
                        continue;
                PlayerSAO *sao = player->getPlayerSAO();
-               if (sao) {
+               if (sao && !sao->isGone()) {
                        getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
                        lua_rawseti(L, -2, ++i);
                }