mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-23 07:10:19 +01:00
Fix TNT mod crash when entities disappear during explosion (#2616)
This commit is contained in:
parent
3a863053c0
commit
07a8067348
@ -163,9 +163,8 @@ local function entity_physics(pos, radius, drops)
|
|||||||
|
|
||||||
local damage = (4 / dist) * radius
|
local damage = (4 / dist) * radius
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
-- currently the engine has no method to set
|
-- we knock the player back 1.0 node, and slightly upwards
|
||||||
-- player velocity. See #2960
|
-- TODO: switch to add_player_velocity() introduced in 5.1
|
||||||
-- instead, we knock the player back 1.0 node, and slightly upwards
|
|
||||||
local dir = vector.normalize(vector.subtract(obj_pos, pos))
|
local dir = vector.normalize(vector.subtract(obj_pos, pos))
|
||||||
local moveoff = vector.multiply(dir, dist + 1.0)
|
local moveoff = vector.multiply(dir, dist + 1.0)
|
||||||
local newpos = vector.add(pos, moveoff)
|
local newpos = vector.add(pos, moveoff)
|
||||||
@ -174,10 +173,13 @@ local function entity_physics(pos, radius, drops)
|
|||||||
|
|
||||||
obj:set_hp(obj:get_hp() - damage)
|
obj:set_hp(obj:get_hp() - damage)
|
||||||
else
|
else
|
||||||
|
local luaobj = obj:get_luaentity()
|
||||||
|
|
||||||
|
-- object might have disappeared somehow
|
||||||
|
if luaobj then
|
||||||
local do_damage = true
|
local do_damage = true
|
||||||
local do_knockback = true
|
local do_knockback = true
|
||||||
local entity_drops = {}
|
local entity_drops = {}
|
||||||
local luaobj = obj:get_luaentity()
|
|
||||||
local objdef = minetest.registered_entities[luaobj.name]
|
local objdef = minetest.registered_entities[luaobj.name]
|
||||||
|
|
||||||
if objdef and objdef.on_blast then
|
if objdef and objdef.on_blast then
|
||||||
@ -203,6 +205,7 @@ local function entity_physics(pos, radius, drops)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function add_effects(pos, radius, drops)
|
local function add_effects(pos, radius, drops)
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
|
Loading…
Reference in New Issue
Block a user