mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 11:33:44 +01:00
Fix core.get_connected_players() returning unusable ObjectRefs
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).
This commit is contained in:
parent
7dffd08c1a
commit
1761d7d0f8
@ -651,7 +651,7 @@ int ModApiEnvMod::l_get_connected_players(lua_State *L)
|
|||||||
if (player->getPeerId() == PEER_ID_INEXISTENT)
|
if (player->getPeerId() == PEER_ID_INEXISTENT)
|
||||||
continue;
|
continue;
|
||||||
PlayerSAO *sao = player->getPlayerSAO();
|
PlayerSAO *sao = player->getPlayerSAO();
|
||||||
if (sao) {
|
if (sao && !sao->isGone()) {
|
||||||
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
|
getScriptApiBase(L)->objectrefGetOrCreate(L, sao);
|
||||||
lua_rawseti(L, -2, ++i);
|
lua_rawseti(L, -2, ++i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user