Fix inventory corruption when using automatic weapons

This commit is contained in:
ANAND 2020-05-13 17:18:30 +05:30
parent 5238358ce5
commit ea8af36b47
No known key found for this signature in database
GPG key ID: 3AD8A3C4A51AAB97

View file

@ -421,7 +421,7 @@ local function fire_weapon(player, itemstack, spec, extended)
return return
end end
minetest.after(interval, function(...) minetest.after(interval, function(...)
if shooting[spec.user] then if shooting[spec.user] and player:get_wield_index() == spec.wield_idx then
local arg = {...} local arg = {...}
fire_weapon(arg[1], arg[2], arg[3], true) fire_weapon(arg[1], arg[2], arg[3], true)
end end
@ -443,6 +443,7 @@ shooter.fire_weapon = function(player, itemstack, spec)
end end
spec.user = name spec.user = name
spec.name = itemstack:get_name() spec.name = itemstack:get_name()
spec.wield_idx = player:get_wield_index()
fire_weapon(player, itemstack, spec) fire_weapon(player, itemstack, spec)
return true return true
end end