X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Frollback_interface.cpp;h=808b07fed9545a7b5032d54e6898a6ca29e2a6df;hb=58e6d25e033c76dc91aaac18fdeda92ac23fe0e1;hp=e15fe3da3155aba623589201fa98e9b2ce9edced;hpb=0190f9b077dcb2b8cb41c622dd91ffc1e04dacac;p=oweals%2Fminetest.git diff --git a/src/rollback_interface.cpp b/src/rollback_interface.cpp index e15fe3da3..808b07fed 100644 --- a/src/rollback_interface.cpp +++ b/src/rollback_interface.cpp @@ -1,6 +1,6 @@ /* -Minetest-c55 -Copyright (C) 2012 celeron55, Perttu Ahola +Minetest +Copyright (C) 2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -289,6 +289,24 @@ bool RollbackAction::isImportant(IGameDef *gamedef) const } } +bool RollbackAction::getPosition(v3s16 *dst) const +{ + switch(type){ + case RollbackAction::TYPE_SET_NODE: + if(dst) *dst = p; + return true; + case RollbackAction::TYPE_MODIFY_INVENTORY_STACK: { + InventoryLocation loc; + loc.deSerialize(inventory_location); + if(loc.type != InventoryLocation::NODEMETA) + return false; + if(dst) *dst = loc.p; + return true; } + default: + return false; + } +} + bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gamedef) const { try{ @@ -322,7 +340,13 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam if(n_old.meta != ""){ if(!meta){ meta = new NodeMetadata(gamedef); - map->setNodeMetadata(p, meta); + if(!map->setNodeMetadata(p, meta)){ + delete meta; + infostream<<"RollbackAction::applyRevert(): " + <<"setNodeMetadata failed at " + <deSerialize(is);