save when a faction is disband, change the value of area.faction_open with the old playerfactions version to facilitate the switch into the new one
This commit is contained in:
parent
8c98db4da4
commit
7a4c992499
|
@ -304,7 +304,7 @@ if areas.factions_available then
|
|||
.." or is not owned by you.", id)
|
||||
end
|
||||
if factions.version == nil or factions.version < 2 or factions.mode_unique_faction then
|
||||
local open = not areas.areas[id].faction_open and factions.get_player_faction(name)
|
||||
local open = not areas.areas[id].faction_open and {factions.get_player_faction(name)}
|
||||
-- Save false as nil to avoid inflating the DB.
|
||||
areas.areas[id].faction_open = open or nil
|
||||
areas:save()
|
||||
|
@ -322,8 +322,8 @@ if areas.factions_available then
|
|||
local removed = false
|
||||
for i, fac_name in ipairs(fnames) do
|
||||
if faction_name == fac_name then
|
||||
removed = true
|
||||
table.remove(fnames,i)
|
||||
removed = true
|
||||
end
|
||||
end
|
||||
if not removed then
|
||||
|
@ -332,7 +332,7 @@ if areas.factions_available then
|
|||
if #fnames == 0 then
|
||||
fnames = nil
|
||||
end
|
||||
-- Save false as nil to avoid inflating the DB.
|
||||
-- Save {} as nil to avoid inflating the DB.
|
||||
areas.areas[id].faction_open = fnames
|
||||
areas:save()
|
||||
return true, fnames and S("Area is open for members of: @1",table.concat(fnames,", "))
|
||||
|
|
6
hud.lua
6
hud.lua
|
@ -25,17 +25,23 @@ minetest.register_globalstep(function(dtime)
|
|||
if factions.version == nil or factions.version < 2 then
|
||||
faction_info = factions.get_player_faction(area.owner)
|
||||
else
|
||||
-- Verify that every displayed faction still exists
|
||||
local faction_open_changed = false
|
||||
for i, fac_name in ipairs(area.faction_open) do
|
||||
if not factions.get_owner(fac_name) then
|
||||
table.remove(area.faction_open, i)
|
||||
faction_open_changed = true
|
||||
end
|
||||
end
|
||||
if #area.faction_open == 0 then
|
||||
area.faction_open = nil
|
||||
faction_info = nil
|
||||
faction_open_changed = true
|
||||
else
|
||||
faction_info = table.concat(area.faction_open, ", ")
|
||||
end
|
||||
-- Save areas if a faction was disband
|
||||
if faction_open_changed then areas:save() end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue