Bugfix for minetest.get_node_drops in builtin/item.lua

Orby
Member
 
Posts: 48
Joined: Sat Aug 18, 2012 03:59

Bugfix for minetest.get_node_drops in builtin/item.lua

by Orby » Thu Nov 01, 2012 00:13

Forgot to post this sooner. I don't have the exact error message recorded, but I was getting periodic crashes due to a bug in minetest.get_node_drops (or a bug somewhere else that was passing bad data to minetest.get_node_drops that it was failing to handle appropriately). The culprit was line 113 in builtin/item.lua, the problem was that a nil value was passed to ipairs:

111 if good_rarity and good_tool then
112 got_count = got_count + 1
113 for _, add_item in ipairs(item.items) do
114 got_items[#got_items+1] = add_item
115 end
116 if drop.max_items ~= nil and got_count == drop.max_items then
117 break
118 end
119 end

which was easily fixed by adding

111 if good_rarity and good_tool and item.items ~= nil then
112 got_count = got_count + 1
113 for _, add_item in ipairs(item.items) do
114 got_items[#got_items+1] = add_item
115 end
116 if drop.max_items ~= nil and got_count == drop.max_items then
117 break
118 end
119 end
{ LinuxGaming.us:30000 LinuxGaming.us 0.4.6 Server | www.LinuxGaming.us | irc.linuxgaming.us #linuxgaming #minetest }
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Thu Nov 01, 2012 11:26

Can you be more precise when its happening. If its realy a bug it should be fixed in upstream.
 

Orby
Member
 
Posts: 48
Joined: Sat Aug 18, 2012 03:59

by Orby » Thu Nov 01, 2012 17:16

PilzAdam wrote:Can you be more precise when its happening. If its realy a bug it should be fixed in upstream.


I'd like to give specific conditions, but it was happening pretty randomly (once every couple days or so). It is a bug that should be fixed upstream. That particular statement shouldn't execute if item.items is nil, it'll just cause the game to crash.
{ LinuxGaming.us:30000 LinuxGaming.us 0.4.6 Server | www.LinuxGaming.us | irc.linuxgaming.us #linuxgaming #minetest }
 


Return to Minetest Problems

Who is online

Users browsing this forum: No registered users and 11 guests

cron