mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Abort when trying to set a not registered node (#7011)
I removed the MapNode constructor which takes a nodename and gives the node's id or CONTENT_IGNORE The code which used this constructor (two places) now handles the situation of not registered nodes correctly: * minetest.set_node and similar functions make minetest crash when a not registered node is passed * reverting a node with rollback aborts if the node is not registered
This commit is contained in:
parent
3066d76e33
commit
431d8a9b83
4 changed files with 13 additions and 21 deletions
|
@ -1093,7 +1093,7 @@ MapNode readnode(lua_State *L, int index, const NodeDefManager *ndef)
|
|||
lua_getfield(L, index, "name");
|
||||
if (!lua_isstring(L, -1))
|
||||
throw LuaError("Node name is not set or is not a string!");
|
||||
const char *name = lua_tostring(L, -1);
|
||||
std::string name = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
u8 param1 = 0;
|
||||
|
@ -1108,7 +1108,11 @@ MapNode readnode(lua_State *L, int index, const NodeDefManager *ndef)
|
|||
param2 = lua_tonumber(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
return {ndef, name, param1, param2};
|
||||
content_t id = CONTENT_IGNORE;
|
||||
if (!ndef->getId(name, id))
|
||||
throw LuaError("\"" + name + "\" is not a registered node!");
|
||||
|
||||
return {id, param1, param2};
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue