Infinite troops in pickup zone set to 0 after troop drop
Opened this issue · 1 comments
dsanchezseco commented
If in a pickup zone with infinite troops a group is dropped back the pickup zone counter is set to 0 (no troops available).
Problem, and solution, is that there is no check to see if the pickup has infinite troops before the sum(following line).
Line 4545 in 9fe7020
dsanchezseco commented
proposed solution
function ctld.updateZoneCounter(_index, _diff)
if ctld.pickupZones[_index] ~= nil then
-- only update counter if amount for pickupzone is not infinite(-1)
if ctld.pickupZones[_index][3] >= 0 then
ctld.pickupZones[_index][3] = ctld.pickupZones[_index][3] + _diff
if ctld.pickupZones[_index][3] < 0 then
ctld.pickupZones[_index][3] = 0
end
if ctld.pickupZones[_index][6] ~= nil then
trigger.action.setUserFlag(ctld.pickupZones[_index][6], ctld.pickupZones[_index][3])
end
end
-- env.info(ctld.pickupZones[_index][1].." = " ..ctld.pickupZones[_index][3])
end
end