Preserved item orders at load and save time. (Fix for bug #16771.)

This commit is contained in:
Guillaume Melquiond 2010-12-24 10:00:20 +00:00
parent 28db7a19d0
commit bec8a218da
2 changed files with 8 additions and 2 deletions

View File

@ -35,7 +35,7 @@ local old_on_save = game_events.on_save
function game_events.on_save()
local custom_cfg = old_on_save()
for i,v in pairs(scenario_items) do
for j,w in pairs(v) do
for j,w in ipairs(v) do
table.insert(custom_cfg, { "item", w })
end
end
@ -44,12 +44,15 @@ end
local old_on_load = game_events.on_load
function game_events.on_load(cfg)
for i = #cfg,1,-1 do
local i = 1
while i <= #cfg do
local v = cfg[i]
if v[1] == "item" then
local v2 = v[2]
add_overlay(v2.x, v2.y, v2)
table.remove(cfg, i)
else
i = i + 1
end
end
old_on_load(cfg)

View File

@ -1856,6 +1856,9 @@ For game purposes, the races group into factions; for example, orcs often cooper
[/event]
[/event]
{PLACE_IMAGE "units/human-outlaws/poacher.png~TC(2,magenta)" 20 14}
{PLACE_IMAGE items/cage.png 20 14}
[item]
x,y=8,5
image="items/orcish-flag.png"