forked from github/server
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:
parent
455b3dc90e
commit
9ac90dd6a5
|
@ -1,9 +1,15 @@
|
||||||
function use_snowman(u, amount)
|
function use_snowman(u, amount)
|
||||||
if u.region.terrain == "glacier" then
|
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)
|
local man = unit.create(u.faction, u.region)
|
||||||
man.race = "snowman"
|
man.race = "snowman"
|
||||||
man.number = amount
|
man.number = amount
|
||||||
u:add_item("snowman", -amount)
|
if u:add_item("snowman", -amount)~= nil then
|
||||||
|
return -1
|
||||||
|
end
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return -4
|
return -4
|
||||||
|
|
Loading…
Reference in New Issue