Log guilty node name when allow_metadata_inventory_move/put/take fails

This commit is contained in:
Kahrl 2013-12-18 22:57:33 +01:00
parent 1ed90c90c3
commit ba8fa0bd42

@ -45,8 +45,8 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowMove(v3s16 p,
return 0; return 0;
// Push callback function on stack // Push callback function on stack
if(!getItemCallback(ndef->get(node).name.c_str(), std::string nodename = ndef->get(node).name;
"allow_metadata_inventory_move")) if(!getItemCallback(nodename.c_str(), "allow_metadata_inventory_move"))
return count; return count;
// function(pos, from_list, from_index, to_list, to_index, count, player) // function(pos, from_list, from_index, to_list, to_index, count, player)
@ -61,7 +61,8 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowMove(v3s16 p,
scriptError(); scriptError();
lua_remove(L, errorhandler); // Remove error handler lua_remove(L, errorhandler); // Remove error handler
if(!lua_isnumber(L, -1)) if(!lua_isnumber(L, -1))
throw LuaError(NULL, "allow_metadata_inventory_move should return a number"); throw LuaError(NULL, "allow_metadata_inventory_move should"
" return a number, guilty node: " + nodename);
int num = luaL_checkinteger(L, -1); int num = luaL_checkinteger(L, -1);
lua_pop(L, 1); // Pop integer lua_pop(L, 1); // Pop integer
return num; return num;
@ -85,8 +86,8 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowPut(v3s16 p,
return 0; return 0;
// Push callback function on stack // Push callback function on stack
if(!getItemCallback(ndef->get(node).name.c_str(), std::string nodename = ndef->get(node).name;
"allow_metadata_inventory_put")) if(!getItemCallback(nodename.c_str(), "allow_metadata_inventory_put"))
return stack.count; return stack.count;
// Call function(pos, listname, index, stack, player) // Call function(pos, listname, index, stack, player)
@ -99,7 +100,8 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowPut(v3s16 p,
scriptError(); scriptError();
lua_remove(L, errorhandler); // Remove error handler lua_remove(L, errorhandler); // Remove error handler
if(!lua_isnumber(L, -1)) if(!lua_isnumber(L, -1))
throw LuaError(NULL, "allow_metadata_inventory_put should return a number"); throw LuaError(NULL, "allow_metadata_inventory_put should"
" return a number, guilty node: " + nodename);
int num = luaL_checkinteger(L, -1); int num = luaL_checkinteger(L, -1);
lua_pop(L, 1); // Pop integer lua_pop(L, 1); // Pop integer
return num; return num;
@ -123,8 +125,8 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowTake(v3s16 p,
return 0; return 0;
// Push callback function on stack // Push callback function on stack
if(!getItemCallback(ndef->get(node).name.c_str(), std::string nodename = ndef->get(node).name;
"allow_metadata_inventory_take")) if(!getItemCallback(nodename.c_str(), "allow_metadata_inventory_take"))
return stack.count; return stack.count;
// Call function(pos, listname, index, count, player) // Call function(pos, listname, index, count, player)
@ -137,7 +139,8 @@ int ScriptApiNodemeta::nodemeta_inventory_AllowTake(v3s16 p,
scriptError(); scriptError();
lua_remove(L, errorhandler); // Remove error handler lua_remove(L, errorhandler); // Remove error handler
if(!lua_isnumber(L, -1)) if(!lua_isnumber(L, -1))
throw LuaError(NULL, "allow_metadata_inventory_take should return a number"); throw LuaError(NULL, "allow_metadata_inventory_take should"
" return a number, guilty node: " + nodename);
int num = luaL_checkinteger(L, -1); int num = luaL_checkinteger(L, -1);
lua_pop(L, 1); // Pop integer lua_pop(L, 1); // Pop integer
return num; return num;
@ -162,8 +165,8 @@ void ScriptApiNodemeta::nodemeta_inventory_OnMove(v3s16 p,
return; return;
// Push callback function on stack // Push callback function on stack
if(!getItemCallback(ndef->get(node).name.c_str(), std::string nodename = ndef->get(node).name;
"on_metadata_inventory_move")) if(!getItemCallback(nodename.c_str(), "on_metadata_inventory_move"))
return; return;
// function(pos, from_list, from_index, to_list, to_index, count, player) // function(pos, from_list, from_index, to_list, to_index, count, player)
@ -197,8 +200,8 @@ void ScriptApiNodemeta::nodemeta_inventory_OnPut(v3s16 p,
return; return;
// Push callback function on stack // Push callback function on stack
if(!getItemCallback(ndef->get(node).name.c_str(), std::string nodename = ndef->get(node).name;
"on_metadata_inventory_put")) if(!getItemCallback(nodename.c_str(), "on_metadata_inventory_put"))
return; return;
// Call function(pos, listname, index, stack, player) // Call function(pos, listname, index, stack, player)
@ -230,8 +233,8 @@ void ScriptApiNodemeta::nodemeta_inventory_OnTake(v3s16 p,
return; return;
// Push callback function on stack // Push callback function on stack
if(!getItemCallback(ndef->get(node).name.c_str(), std::string nodename = ndef->get(node).name;
"on_metadata_inventory_take")) if(!getItemCallback(nodename.c_str(), "on_metadata_inventory_take"))
return; return;
// Call function(pos, listname, index, stack, player) // Call function(pos, listname, index, stack, player)