some more checks in some API methods

This commit is contained in:
Luke aka SwissalpS 2024-09-16 16:31:09 +02:00
parent b47198299b
commit e4851ade83

@ -170,8 +170,8 @@ function factions.get_password()
return nil return nil
end end
if not facts[fname] then
function factions.set_password(faction_name, password) function factions.set_password(faction_name, password)
if not (facts[faction_name] and 'string' == type(password)) then
return false return false
end end
facts[faction_name].password256 = factions.hash_password(password) facts[faction_name].password256 = factions.hash_password(password)
@ -179,8 +179,9 @@ function factions.set_password(faction_name, password)
return true return true
end end
if not (facts[fname] and minetest.player_exists(player)) then
function factions.join_faction(faction_name, player_name) function factions.join_faction(faction_name, player_name)
if not (facts[faction_name] and 'string' == type(player_name)
and minetest.player_exists(player_name)) then
return false return false
end end
facts[faction_name].members[player_name] = true facts[faction_name].members[player_name] = true
@ -188,8 +189,9 @@ function factions.join_faction(faction_name, player_name)
return true return true
end end
if not (facts[fname] and minetest.player_exists(player_name)) then
function factions.leave_faction(faction_name, player_name) function factions.leave_faction(faction_name, player_name)
if not (facts[faction_name] and 'string' == type(player_name)
and minetest.player_exists(player_name)) then
return false return false
end end
facts[faction_name].members[player_name] = nil facts[faction_name].members[player_name] = nil