pandorabox-io / pandorabox_custom

pandorabox server customization mod
https://pandorabox.io
MIT License
4 stars 8 forks source link

Crash on EdenLost, Multi-craft v2.0.0 #65

Closed dennisjenkins75 closed 1 year ago

dennisjenkins75 commented 1 year ago

I updated all of the server mods recently and this started showing up. I have not attempted to rollback pandorabox_custom, but I can as an experiment.

2023-03-13 15:11:45: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'ethereal' in callback luaentity_Step(): Runtime error from mod 'ethereal' in callback node_on_dig(): .../1hit/worlds/world/worldmods/pandorabox_custom/hacks.lua:31: attempt to index loca
2023-03-13 15:11:45: ERROR[Main]: l 'dp' (a nil value)
2023-03-13 15:11:45: ERROR[Main]: stack traceback:
2023-03-13 15:11:45: ERROR[Main]:       .../1hit/worlds/world/worldmods/pandorabox_custom/hacks.lua:31: in function 'dig_up'
2023-03-13 15:11:45: ERROR[Main]:       /home/1hit/worlds/world/worldmods/ethereal/wood.lua:314: in function 'after_dig_node'
2023-03-13 15:11:45: ERROR[Main]:       /home/1hit/multicraft/bin/../builtin/game/item.lua:767: in function </home/1hit/multicraft/bin/../builtin/game/item.lua:680>
2023-03-13 15:11:45: ERROR[Main]:       [C]: in function 'dig_node'
2023-03-13 15:11:45: ERROR[Main]:       /home/1hit/worlds/world/worldmods/draconis/api/api.lua:1166: in function 'destroy_terrain'
2023-03-13 15:11:45: ERROR[Main]:       /home/1hit/worlds/world/worldmods/draconis/api/api.lua:1984: in function 'dragon_step'
2023-03-13 15:11:45: ERROR[Main]:       ...hit/worlds/world/worldmods/draconis/mobs/fire_dragon.lua:217: in function 'step_func'
2023-03-13 15:11:45: ERROR[Main]:       /home/1hit/worlds/world/worldmods/creatura/mob_meta.lua:940: in function </home/1hit/worlds/world/worldmods/creatura/mob_meta.lua:894>
OgelGames commented 1 year ago

Seems to be a weird bug with the way minetest.dig_node works, it passes a value that isn't nil, but also isn't usable:

// Dig it out with a NULL digger (appears in Lua as a
// non-functional ObjectRef)
bool success = scriptIfaceNode->node_on_dig(pos, n, NULL);

https://github.com/minetest/minetest/blob/d13b12b791d8a423a9acaeffc44c27edb7cdb95e/src/script/lua_api/l_env.cpp#L477-L478

The pandorabox_custom code checks for a nil digger, but that value isn't nil. https://github.com/pandorabox-io/pandorabox_custom/blob/38a43d81b6ff0565b719ef41756d41159f8c5ee4/hacks.lua#L26

Another weird thing, there is only a 1/6 chance of minetest.dig_node being called by the draconis code:

if random(6) < 2 then
    minetest.dig_node(n_pos)
else
    minetest.remove_node(n_pos)
end

https://github.com/ElCeejo/draconis/blob/091ec5fa9a0f9d2ef13e0b82e686f571c64d36fa/api/api.lua#L1165-L1169

S-S-X commented 1 year ago

Note: digger (or player in other callbacks) can be non functional and this is documented for Minetest API. It is intended, allows way less Lua side overhead (better performance). That's also a reason why one should be very careful if storing player objects Lua side (also documented).