1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Move core.get_connected_players() implementation to C++

Keeping the ObjectRefs around in a table isn't ideal and this allows
removing the somewhat nonsensical is_player_connected() added in 86ef7147.
This commit is contained in:
sfan5 2020-02-12 19:49:48 +01:00
parent c657fb343f
commit 0b8d3f99a5
6 changed files with 27 additions and 17 deletions

View file

@ -40,9 +40,6 @@ function core.check_player_privs(name, ...)
end
local player_list = {}
function core.send_join_message(player_name)
if not core.is_singleplayer() then
core.chat_send_all("*** " .. player_name .. " joined the game.")
@ -61,7 +58,6 @@ end
core.register_on_joinplayer(function(player)
local player_name = player:get_player_name()
player_list[player_name] = player
if not core.is_singleplayer() then
local status = core.get_server_status(player_name, true)
if status and status ~= "" then
@ -74,22 +70,10 @@ end)
core.register_on_leaveplayer(function(player, timed_out)
local player_name = player:get_player_name()
player_list[player_name] = nil
core.send_leave_message(player_name, timed_out)
end)
function core.get_connected_players()
local temp_table = {}
for index, value in pairs(player_list) do
if value:is_player_connected() then
temp_table[#temp_table + 1] = value
end
end
return temp_table
end
function core.is_player(player)
-- a table being a player is also supported because it quacks sufficiently
-- like a player if it has the is_player function