Fix crash on rightclicking mobs

Fix crash due to invalid target evaluation
This commit is contained in:
sapier 2013-08-23 22:21:05 +02:00
parent 3a2f770994
commit b1614db76b
2 changed files with 10 additions and 9 deletions

View File

@ -428,12 +428,14 @@ function mobf_debug.rightclick_callback(entity,player)
print("MOBF: \t\t " .. k .. ": " .. v.value)
end
local attention_name = tostring(entity.dynamic_data.attention.most_relevant_target)
if (entity.dynamic_data.attention.most_relevant_target:is_player()) then
attention_name = entity.dynamic_data.attention.most_relevant_target:get_player_name()
if entity.dynamic_data.attention.most_relevant_target ~= nil then
local attention_name = tostring(entity.dynamic_data.attention.most_relevant_target)
if (entity.dynamic_data.attention.most_relevant_target:is_player()) then
attention_name = entity.dynamic_data.attention.most_relevant_target:get_player_name()
end
print("MOBF: \tTop attention object: " .. attention_name)
end
print("MOBF: \tTop attention object: " .. attention_name)
end
if entity.dynamic_data.graphics.last_fps ~= nil then

View File

@ -847,14 +847,13 @@ function fighting.melee_attack_handler(entity,now,distance)
return false
end
mobf_assert_backtrace( entity.dynamic_data.combat.target ~= nil)
local ownpos = entity.object:getpos()
local target_obj = entity.dynamic_data.combat.target.object
local target_obj = entity.dynamic_data.combat.target.object
mobf_assert_backtrace(target ~= nil)
if target:is_player() then
if target_obj == nil then
target_obj = entity.dynamic_data.combat.target
end
mobf_assert_backtrace(target_obj ~= nil)
if distance <= entity.data.combat.melee.range
and mobf_line_of_sight(ownpos,target_obj:getpos()) then