2005-01-08 00:48:11 +01:00
|
|
|
function gate_travel(b, units)
|
2005-01-03 22:28:57 +01:00
|
|
|
-- we've found which units we want to exchange, now swap them:
|
|
|
|
local u
|
2005-01-08 00:48:11 +01:00
|
|
|
for u in units do
|
|
|
|
u.region = b.region
|
|
|
|
u.building = b
|
2005-01-03 22:28:57 +01:00
|
|
|
end
|
2005-01-08 00:48:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function gate_units(b, maxsize)
|
|
|
|
local size = maxsize
|
|
|
|
local units = {}
|
|
|
|
local u
|
|
|
|
|
|
|
|
for u in b.units do
|
2005-01-13 13:42:36 +01:00
|
|
|
if u.number<=size and u.weight<=u.capacity then
|
|
|
|
units[u] = u
|
|
|
|
size = size - u.number
|
2005-01-08 00:48:11 +01:00
|
|
|
end
|
2005-01-03 22:28:57 +01:00
|
|
|
end
|
2005-01-08 00:48:11 +01:00
|
|
|
return units
|
2005-01-03 22:28:57 +01:00
|
|
|
end
|