Wuzzy2 / MineClone2-Bugs

Bug tracker archive for MineClone 2 (no new posts allowed)
MIT License
7 stars 0 forks source link

Pistons breaking a block cause game to crash. #468

Closed Bu-Gee closed 6 years ago

Bu-Gee commented 6 years ago

Here is the stack trace. I placed a redstone torch to activate a circuit which pushes a piston to break a pumpkin. I got this stack trace:

2018-03-04 11:32:59: ACTION[Server]: singleplayer places node mesecons_torch:mesecon_torch_on_wall at (6,22,57) 2018-03-04 11:33:00: ERROR[Main]: ServerError: AsyncErr: environment_Step: Runtime error from mod 'mesecons' in callback environment_Step(): .../games/MineClone2/mods/ENTITIES/mcl_item_entity/init.lua:217: attempt to index local 'digger' (a nil value) 2018-03-04 11:33:00: ERROR[Main]: stack traceback: 2018-03-04 11:33:00: ERROR[Main]: .../games/MineClone2/mods/ENTITIES/mcl_item_entity/init.lua:217: in function 'handle_node_drops' 2018-03-04 11:33:00: ERROR[Main]: ...es/MineClone2/mods/ITEMS/REDSTONE/mesecons_mvps/init.lua:222: in function 'mvps_push' 2018-03-04 11:33:00: ERROR[Main]: ...MineClone2/mods/ITEMS/REDSTONE/mesecons_pistons/init.lua:95: in function 'action_on' 2018-03-04 11:33:00: ERROR[Main]: ...mes/MineClone2/mods/ITEMS/REDSTONE/mesecons/internal.lua:195: in function <...mes/MineClone2/mods/ITEMS/REDSTONE/mesecons/internal.lua:188> 2018-03-04 11:33:00: ERROR[Main]: .../MineClone2/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua:93: in function 'execute' 2018-03-04 11:33:00: ERROR[Main]: .../MineClone2/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua:84: in function <.../MineClone2/mods/ITEMS/REDSTONE/mesecons/actionqueue.lua:61> 2018-03-04 11:33:00: ERROR[Main]: /usr/share/minetest/builtin/game/register.lua:412: in function </usr/share/minetest/builtin/game/register.lua:392> 2018-03-04 11:33:00: ERROR[Main]: stack traceback: 2018-03-04 11:33:00: ACTION[Server]: [doc] Wrote player data into /home/bu/.minetest/worlds/MCL2/doc.mt. 2018-03-04 11:33:00: ACTION[Server]: singleplayer leaves game. List of players: 2018-03-04 11:33:00: ACTION[Main]: [doc] Server shuts down. Player data is about to be saved. 2018-03-04 11:33:00: ACTION[Main]: [doc] Wrote player data into /home/bu/.minetest/worlds/MCL2/doc.mt.

The game crashed. When I started it back up, the pumpkin is where it was and the redstone circuit was deactivated.

Best I can tell is that it looks like a missing digger index.

Update: I also tried this in creative mode and the pumpkin breaks but it doesn't leave anything to pick up. Does that mean it wasn't dug?

Bu-Gee commented 6 years ago

This patch appears to fix it, but to be perfectly honest, I don't know what else it breaks.

--- init.orig.lua       2018-03-04 16:47:53.249458663 -0500
+++ init.lua    2018-03-04 16:45:30.330049391 -0500
@@ -214,11 +214,14 @@

        -- Check if node will yield its useful drop by the digger's tool
        local dug_node = minetest.get_node(pos)
-       local tool = digger:get_wielded_item()
-       local toolcaps = tool:get_tool_capabilities()
+       local toolcaps = nil
+       if digger ~= nil then
+               local tool = digger:get_wielded_item()
+               toolcaps = tool:get_tool_capabilities()

-       if not check_can_drop(dug_node.name, toolcaps) then
-               return
+               if not check_can_drop(dug_node.name, toolcaps) then
+                       return
+               end
        end

        --[[ Special node drops when dug by shears by reading _mcl_shears_drop
@@ -228,7 +231,7 @@
        * table: Drop every itemstring in this table when dub by shears
        ]]
        local nodedef = minetest.registered_nodes[dug_node.name]
-       if toolcaps.groupcaps and toolcaps.groupcaps.shearsy_dig and nodedef._mcl_shears_drop then
+       if toolcaps ~= nil and toolcaps.groupcaps and toolcaps.groupcaps.shearsy_dig and nodedef._mcl_shears_drop then
                if nodedef._mcl_shears_drop == true then
                        drops = { dug_node.name }
                else
Wuzzy2 commented 6 years ago

The patch looks fine to me. The crash has been fixed. Thanks for reporting.