X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Frollback_interface.cpp;h=c00206e984592a53f167ced313544b672dbbbcdc;hb=b3b075ea02034306256b486dd45410aa765f035a;hp=3ac15544c6763c3e22c2eb0595e1e040ec4d38ad;hpb=3d66622772e66154b7624957a27f9be54c4c7c28;p=dragonfireclient.git diff --git a/src/rollback_interface.cpp b/src/rollback_interface.cpp index 3ac15544c..c00206e98 100644 --- a/src/rollback_interface.cpp +++ b/src/rollback_interface.cpp @@ -37,7 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc., RollbackNode::RollbackNode(Map *map, v3s16 p, IGameDef *gamedef) { const NodeDefManager *ndef = gamedef->ndef(); - MapNode n = map->getNodeNoEx(p); + MapNode n = map->getNode(p); name = ndef->get(n).name; param1 = n.param1; param2 = n.param2; @@ -132,14 +132,19 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam // Make sure position is loaded from disk map->emergeBlock(getContainerPos(p, MAP_BLOCKSIZE), false); // Check current node - MapNode current_node = map->getNodeNoEx(p); + MapNode current_node = map->getNode(p); std::string current_name = ndef->get(current_node).name; // If current node not the new node, it's bad if (current_name != n_new.name) { 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)) { @@ -171,7 +176,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam MapEditEvent event; event.type = MEET_BLOCK_NODE_METADATA_CHANGED; event.p = p; - map->dispatchEvent(&event); + map->dispatchEvent(event); } catch (InvalidPositionException &e) { infostream << "RollbackAction::applyRevert(): " << "InvalidPositionException: " << e.what() @@ -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