From adf738854ae214f2c41e3199ccbbbe810df22ccd Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 26 Jan 2022 17:37:55 +0100 Subject: [PATCH] Fix mob-in-boat crash in Minetest 5.5-dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Minetest 5.4.1, calling get_player_control() on a mob returned the empty string. Minetest commit 5eb45e1ea03c6104f007efec6dd9c351f310193d changed this, so now calling get_player_control() on a mob returns nil. As mcl_boats defines boats that can have a player or a mob as a driver, code like the following crashes with a changed get_player_control() API: local ctrl = driver:get_player_control() if ctrl.sneak then detach_object(driver, true) end Furthermore, once a world has crashed, joining it near a mob that is the driver of a boat with such control code immediately crashes again. When I reported this bug to Minetest, several Minetest core developers stated that they disliked the old API and proposed other return values for calling a mob's get_player_control() function – all different from the empty string. Since I have some doubts that this bug will be fixed in Minetest 5.5.0, boat code must take into account a nil return value. Minetest issue: https://github.com/minetest/minetest/issues/11989 --- mods/ENTITIES/mcl_boats/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index beff5fb52e..72664b1dfb 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -267,7 +267,7 @@ function boat.on_step(self, dtime, moveresult) return end local yaw = self.object:get_yaw() - if ctrl.up then + if ctrl and ctrl.up then -- Forwards self._v = self._v + 0.1 * v_factor @@ -276,7 +276,7 @@ function boat.on_step(self, dtime, moveresult) self.object:set_animation({x=0, y=40}, paddling_speed, 0, true) self._animation = 1 end - elseif ctrl.down then + elseif ctrl and ctrl.down then -- Backwards self._v = self._v - 0.1 * v_factor