From cdafb81167f19e78b3e210c5948b0076411311ba Mon Sep 17 00:00:00 2001 From: upsilon Date: Thu, 5 Jan 2017 20:39:41 +0100 Subject: [PATCH] Fix a potential usebug Avoid a player to crash the server by disconnecting after throwing the arrow and before it hits. --- init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 9adc447..7ddac54 100644 --- a/init.lua +++ b/init.lua @@ -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