aboutsummaryrefslogtreecommitdiff
path: root/src/rollback_interface.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:19:54 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:19:54 +0100
commitad148587dcf5244c2d2011dba339786c765c54c4 (patch)
treebdd914121cd326da2ed26679838878e3edffc841 /src/rollback_interface.cpp
parent1145b05ea0bda87dc0827821385810eced08f774 (diff)
downloaddragonfireclient-ad148587dcf5244c2d2011dba339786c765c54c4.tar.xz
Make Lint Happy
Diffstat (limited to 'src/rollback_interface.cpp')
-rw-r--r--src/rollback_interface.cpp81
1 files changed, 45 insertions, 36 deletions
diff --git a/src/rollback_interface.cpp b/src/rollback_interface.cpp
index c00206e98..2ab011192 100644
--- a/src/rollback_interface.cpp
+++ b/src/rollback_interface.cpp
@@ -33,7 +33,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "inventory.h"
#include "mapblock.h"
-
RollbackNode::RollbackNode(Map *map, v3s16 p, IGameDef *gamedef)
{
const NodeDefManager *ndef = gamedef->ndef();
@@ -49,7 +48,6 @@ RollbackNode::RollbackNode(Map *map, v3s16 p, IGameDef *gamedef)
}
}
-
std::string RollbackAction::toString() const
{
std::ostringstream os(std::ios::binary);
@@ -79,16 +77,15 @@ std::string RollbackAction::toString() const
return os.str();
}
-
bool RollbackAction::isImportant(IGameDef *gamedef) const
{
if (type != TYPE_SET_NODE)
return true;
// If names differ, action is always important
- if(n_old.name != n_new.name)
+ if (n_old.name != n_new.name)
return true;
// If metadata differs, action is always important
- if(n_old.meta != n_new.meta)
+ if (n_old.meta != n_new.meta)
return true;
const NodeDefManager *ndef = gamedef->ndef();
// Both are of the same name, so a single definition is needed
@@ -100,12 +97,12 @@ bool RollbackAction::isImportant(IGameDef *gamedef) const
return true;
}
-
bool RollbackAction::getPosition(v3s16 *dst) const
{
switch (type) {
case TYPE_SET_NODE:
- if (dst) *dst = p;
+ if (dst)
+ *dst = p;
return true;
case TYPE_MODIFY_INVENTORY_STACK: {
InventoryLocation loc;
@@ -113,15 +110,17 @@ bool RollbackAction::getPosition(v3s16 *dst) const
if (loc.type != InventoryLocation::NODEMETA) {
return false;
}
- if (dst) *dst = loc.p;
- return true; }
+ if (dst)
+ *dst = loc.p;
+ return true;
+ }
default:
return false;
}
}
-
-bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gamedef) const
+bool RollbackAction::applyRevert(
+ Map *map, InventoryManager *imgr, IGameDef *gamedef) const
{
try {
switch (type) {
@@ -149,9 +148,9 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
try {
if (!map->addNodeWithEvent(p, n)) {
infostream << "RollbackAction::applyRevert(): "
- << "AddNodeWithEvent failed at "
- << PP(p) << " for " << n_old.name
- << std::endl;
+ << "AddNodeWithEvent failed at "
+ << PP(p) << " for " << n_old.name
+ << std::endl;
return false;
}
if (n_old.meta.empty()) {
@@ -162,14 +161,18 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
meta = new NodeMetadata(gamedef->idef());
if (!map->setNodeMetadata(p, meta)) {
delete meta;
- infostream << "RollbackAction::applyRevert(): "
- << "setNodeMetadata failed at "
- << PP(p) << " for " << n_old.name
- << std::endl;
+ infostream << "RollbackAction::"
+ "applyRevert(): "
+ << "setNodeMetadata "
+ "failed at "
+ << PP(p) << " for "
+ << n_old.name
+ << std::endl;
return false;
}
}
- std::istringstream is(n_old.meta, std::ios::binary);
+ std::istringstream is(
+ n_old.meta, std::ios::binary);
meta->deSerialize(is, 1); // FIXME: version bump??
}
// Inform other things that the meta data has changed
@@ -179,33 +182,38 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
map->dispatchEvent(event);
} catch (InvalidPositionException &e) {
infostream << "RollbackAction::applyRevert(): "
- << "InvalidPositionException: " << e.what()
- << std::endl;
+ << "InvalidPositionException: " << e.what()
+ << std::endl;
return false;
}
// Success
- return true; }
+ return true;
+ }
case TYPE_MODIFY_INVENTORY_STACK: {
InventoryLocation loc;
loc.deSerialize(inventory_location);
Inventory *inv = imgr->getInventory(loc);
if (!inv) {
- infostream << "RollbackAction::applyRevert(): Could not get "
- "inventory at " << inventory_location << std::endl;
+ infostream << "RollbackAction::applyRevert(): Could not "
+ "get "
+ "inventory at "
+ << inventory_location << std::endl;
return false;
}
InventoryList *list = inv->getList(inventory_list);
if (!list) {
- infostream << "RollbackAction::applyRevert(): Could not get "
- "inventory list \"" << inventory_list << "\" in "
- << inventory_location << std::endl;
+ infostream << "RollbackAction::applyRevert(): Could not "
+ "get "
+ "inventory list \""
+ << inventory_list << "\" in "
+ << inventory_location << std::endl;
return false;
}
if (list->getSize() <= inventory_index) {
infostream << "RollbackAction::applyRevert(): List index "
- << inventory_index << " too large in "
- << "inventory list \"" << inventory_list << "\" in "
- << inventory_location << std::endl;
+ << inventory_index << " too large in "
+ << "inventory list \"" << inventory_list
+ << "\" in " << inventory_location << std::endl;
return false;
}
@@ -213,7 +221,8 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
if (inventory_add) {
// Silently ignore different current item
if (list->getItem(inventory_index).name !=
- gamedef->idef()->getAlias(inventory_stack.name))
+ gamedef->idef()->getAlias(
+ inventory_stack.name))
return false;
list->takeItem(inventory_index, inventory_stack.count);
} else {
@@ -221,16 +230,16 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
}
// Inventory was modified; send to clients
imgr->setInventoryModified(loc);
- return true; }
+ return true;
+ }
default:
errorstream << "RollbackAction::applyRevert(): type not handled"
- << std::endl;
+ << std::endl;
return false;
}
- } catch(SerializationError &e) {
+ } catch (SerializationError &e) {
errorstream << "RollbackAction::applyRevert(): n_old.name=" << n_old.name
- << ", SerializationError: " << e.what() << std::endl;
+ << ", SerializationError: " << e.what() << std::endl;
}
return false;
}
-