Fix a potential usebug

Avoid a player to crash the server by disconnecting after throwing the arrow and before it hits.
This commit is contained in:
upsilon 2017-01-05 20:39:41 +01:00
parent 1e1424ab34
commit cdafb81167
1 changed files with 5 additions and 1 deletions

View File

@ -49,7 +49,11 @@ local function arrow_step(self, dtime)
return
end
self.on_hit(pos, self.last_pos, node, obj, minetest.get_player_by_name(self.player))
local player = minetest.get_player_by_name(self.player)
if not player then -- Possible if the player disconnected
return
end
self.on_hit(pos, self.last_pos, node, obj, player)
if self.on_hit_sound then
minetest.sound_play(self.on_hit_sound, {pos = pos, gain = 0.8})
end