mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02: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:
@@ -139,7 +139,12 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
|
||||
return false;
|
||||
}
|
||||
// Create rollback node
|
||||
MapNode n(ndef, n_old.name, n_old.param1, n_old.param2);
|
||||
content_t id = CONTENT_IGNORE;
|
||||
if (!ndef->getId(n_old.name, id)) {
|
||||
// The old node is not registered
|
||||
return false;
|
||||
}
|
||||
MapNode n(id, n_old.param1, n_old.param2);
|
||||
// Set rollback node
|
||||
try {
|
||||
if (!map->addNodeWithEvent(p, n)) {
|
||||
@@ -203,7 +208,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
|
||||
<< inventory_location << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// If item was added, take away item, otherwise add removed item
|
||||
if (inventory_add) {
|
||||
// Silently ignore different current item
|
||||
|
Reference in New Issue
Block a user