From d0520d22213e080ae2c023417d9e8c5fa2f15361 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Sun, 15 Sep 2024 05:14:11 +0200 Subject: [PATCH] join: cleanup - don't call get_player_factions() unless needed - use get_player_factions() instead of depricated get_player_faction() - truth check of password in valid_password() for easier understanding of code - remove explicit nil check where not needed --- init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 7395aed..4f7e772 100644 --- a/init.lua +++ b/init.lua @@ -149,7 +149,7 @@ function factions.hash_password(password) end function factions.valid_password(fname, password) - if not facts[fname] then + if not facts[fname] or not password then return false end return factions.hash_password(password) == facts[fname].password256 @@ -328,11 +328,11 @@ local function handle_command(name, param) elseif action == "join" then local faction_name = params[2] local password = params[3] - if factions.get_player_faction(name) ~= nil and factions.mode_unique_faction then + if factions.mode_unique_faction and factions.get_player_factions(name) then return false, S("You are already in a faction.") elseif not faction_name then return false, S("Missing faction name.") - elseif facts[faction_name] == nil then + elseif not facts[faction_name] then return false, S("Faction @1 doesn't exist.", faction_name) elseif not factions.valid_password(faction_name, password) then return false, S("Permission denied: Wrong password.")