Merge pull request #11 from jleldridge/master
Rewrite location_set.of_pairs().
This commit is contained in:
commit
9c25c08b66
2 changed files with 26 additions and 7 deletions
|
@ -140,12 +140,7 @@ return {
|
|||
local enemy_attack_map = BC.get_attack_map(enemies)
|
||||
--AH.put_labels(enemy_attack_map.units)
|
||||
|
||||
local avoid_locs = ai.get_avoid()
|
||||
local avoid_map = LS.create()
|
||||
|
||||
for i,l in ipairs(avoid_locs) do
|
||||
avoid_map:insert(l.x, l.y)
|
||||
end
|
||||
local avoid_map = LS.of_pairs(ai.get_avoid())
|
||||
|
||||
-- Put units back out there
|
||||
for i,u in ipairs(units_MP) do wesnoth.put_unit(u.x, u.y, u) end
|
||||
|
|
|
@ -106,8 +106,32 @@ end
|
|||
|
||||
function methods:of_pairs(t)
|
||||
local values = self.values
|
||||
|
||||
for i,v in ipairs(t) do
|
||||
values[index(v[1], v[2])] = true
|
||||
local value_table = {}
|
||||
if (v.x) and (v.y) then
|
||||
for k,val in pairs(v) do
|
||||
if (k ~= "x") and (k ~= "y") then
|
||||
value_table[k] = val
|
||||
end
|
||||
end
|
||||
if (next(value_table) ~= nil) then
|
||||
values[index(v.x, v.y)] = value_table
|
||||
else
|
||||
values[index(v.x, v.y)] = true
|
||||
end
|
||||
else
|
||||
for k,val in pairs(v) do
|
||||
if (k ~= 1) and (k ~= 2) then
|
||||
value_table[k] = val
|
||||
end
|
||||
end
|
||||
if (next(value_table) ~= nil) then
|
||||
values[index(v[1], v[2])] = value_table
|
||||
else
|
||||
values[index(v[1], v[2])] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue