bugfix: USE snowman did not check that the unit actually owned a snowman, causing a unit to have negative snowmen in turn 629 (exploit).

This commit is contained in:
Enno Rehling 2014-12-13 23:20:10 +01:00
parent 455b3dc90e
commit 9ac90dd6a5
1 changed files with 14 additions and 8 deletions

View File

@ -1,12 +1,18 @@
function use_snowman(u, amount)
if u.region.terrain == "glacier" then
local man = unit.create(u.faction, u.region)
man.race = "snowman"
man.number = amount
u:add_item("snowman", -amount)
return 0
end
return -4
local have = u:get_item("snowman")
if have<amount then
amount = have
end
if amount>0 and u.region.terrain == "glacier" then
local man = unit.create(u.faction, u.region)
man.race = "snowman"
man.number = amount
if u:add_item("snowman", -amount)~= nil then
return -1
end
return 0
end
return -4
end
local self = {}