X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Frollback_interface.cpp;h=d02d1cb3e8b861dabe5c66f2b29eff10487bf5d2;hb=f77f19a9412c9ae9f6b54a8794af219861a5e2e2;hp=c35ad57811b0687b914098104010b385ad493ee4;hpb=b1965ac20922e3722392114bd63a22b403dcbe98;p=dragonfireclient.git diff --git a/src/rollback_interface.cpp b/src/rollback_interface.cpp index c35ad5781..d02d1cb3e 100644 --- a/src/rollback_interface.cpp +++ b/src/rollback_interface.cpp @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/serialize.h" #include "util/string.h" #include "util/numeric.h" +#include "util/basic_macros.h" #include "map.h" #include "gamedef.h" #include "nodedef.h" @@ -32,8 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "inventory.h" #include "mapblock.h" -#define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" - RollbackNode::RollbackNode(Map *map, v3s16 p, IGameDef *gamedef) { @@ -45,7 +44,7 @@ RollbackNode::RollbackNode(Map *map, v3s16 p, IGameDef *gamedef) NodeMetadata *metap = map->getNodeMetadata(p); if (metap) { std::ostringstream os(std::ios::binary); - metap->serialize(os); + metap->serialize(os, 1); // FIXME: version bump?? meta = os.str(); } } @@ -155,7 +154,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam } else { NodeMetadata *meta = map->getNodeMetadata(p); if (!meta) { - meta = new NodeMetadata(gamedef); + meta = new NodeMetadata(gamedef->idef()); if (!map->setNodeMetadata(p, meta)) { delete meta; infostream << "RollbackAction::applyRevert(): " @@ -166,7 +165,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam } } std::istringstream is(n_old.meta, std::ios::binary); - meta->deSerialize(is); + meta->deSerialize(is, 1); // FIXME: version bump?? } // Inform other things that the meta data has changed v3s16 blockpos = getContainerPos(p, MAP_BLOCKSIZE); @@ -178,7 +177,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam MapBlock *block = map->getBlockNoCreateNoEx(blockpos); if (block) { block->raiseModified(MOD_STATE_WRITE_NEEDED, - "NodeMetaRef::reportMetadataChange"); + MOD_REASON_REPORT_META_CHANGE); } } catch (InvalidPositionException &e) { infostream << "RollbackAction::applyRevert(): " @@ -191,7 +190,6 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam case TYPE_MODIFY_INVENTORY_STACK: { InventoryLocation loc; loc.deSerialize(inventory_location); - std::string real_name = gamedef->idef()->getAlias(inventory_stack.name); Inventory *inv = imgr->getInventory(loc); if (!inv) { infostream << "RollbackAction::applyRevert(): Could not get " @@ -210,11 +208,14 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam << inventory_index << " too large in " << "inventory list \"" << inventory_list << "\" in " << 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 - if (list->getItem(inventory_index).name != real_name) + if (list->getItem(inventory_index).name != + gamedef->idef()->getAlias(inventory_stack.name)) return false; list->takeItem(inventory_index, inventory_stack.count); } else {