From a87e59afee2d438c43379cda93dadb2075a1b6c6 Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Sun, 15 Sep 2024 00:06:17 +0200 Subject: [PATCH] wrap fixup code in do-block variable save_needed is not used for anything else --- init.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/init.lua b/init.lua index 38d2c0b..1b3022f 100644 --- a/init.lua +++ b/init.lua @@ -546,19 +546,21 @@ minetest.register_chatcommand("factions", { }) -- Fix factions -local save_needed = false -for _, fact in pairs(facts) do - if not fact.members then - fact.members = {} +do + local save_needed = false + for _, fact in pairs(facts) do + if not fact.members then + fact.members = {} + end + if fact.password then + fact.password256 = factions.hash_password(fact.password) + fact.password = nil + save_needed = true + end end - if fact.password then - fact.password256 = factions.hash_password(fact.password) - fact.password = nil - save_needed = true + if save_needed then + save_factions() end end -if save_needed then - save_factions() -end print("[playerfactions] loaded")