summaryrefslogtreecommitdiff
path: root/src/rollback.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-19 14:25:35 +0200
committerGitHub <noreply@github.com>2017-08-19 14:25:35 +0200
commit7528986e4449febead9b18b6118f0b096f7cf800 (patch)
tree8e526c1403ba8d0689ab40a24165fc19d8a07e27 /src/rollback.cpp
parent1992db1395d9c068327a7c08bac7a24ef7112274 (diff)
downloadminetest-7528986e4449febead9b18b6118f0b096f7cf800.tar.gz
minetest-7528986e4449febead9b18b6118f0b096f7cf800.tar.bz2
minetest-7528986e4449febead9b18b6118f0b096f7cf800.zip
Code modernization: src/p*, src/q*, src/r*, src/s* (partial) (#6282)
* Code modernization: src/p*, src/q*, src/r*, src/s* (partial) * empty function * default constructor/destructor * for range-based loops * use emplace_back instead of push_back * C++ STL header style * Spelling: vertice -> vertex
Diffstat (limited to 'src/rollback.cpp')
-rw-r--r--src/rollback.cpp45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/rollback.cpp b/src/rollback.cpp
index a77a9ee15..3cd9c7ce7 100644
--- a/src/rollback.cpp
+++ b/src/rollback.cpp
@@ -577,35 +577,34 @@ const std::list<RollbackAction> RollbackManager::rollbackActionsFromActionRows(
{
std::list<RollbackAction> actions;
- for (std::list<ActionRow>::const_iterator it = rows.begin();
- it != rows.end(); ++it) {
+ for (const ActionRow &row : rows) {
RollbackAction action;
- action.actor = (it->actor) ? getActorName(it->actor) : "";
- action.unix_time = it->timestamp;
- action.type = static_cast<RollbackAction::Type>(it->type);
+ action.actor = (row.actor) ? getActorName(row.actor) : "";
+ action.unix_time = row.timestamp;
+ action.type = static_cast<RollbackAction::Type>(row.type);
switch (action.type) {
case RollbackAction::TYPE_MODIFY_INVENTORY_STACK:
- action.inventory_location = it->location.c_str();
- action.inventory_list = it->list;
- action.inventory_index = it->index;
- action.inventory_add = it->add;
- action.inventory_stack = it->stack;
+ action.inventory_location = row.location;
+ action.inventory_list = row.list;
+ action.inventory_index = row.index;
+ action.inventory_add = row.add;
+ action.inventory_stack = row.stack;
if (action.inventory_stack.name.empty()) {
- action.inventory_stack.name = getNodeName(it->stack.id);
+ action.inventory_stack.name = getNodeName(row.stack.id);
}
break;
case RollbackAction::TYPE_SET_NODE:
- action.p = v3s16(it->x, it->y, it->z);
- action.n_old.name = getNodeName(it->oldNode);
- action.n_old.param1 = it->oldParam1;
- action.n_old.param2 = it->oldParam2;
- action.n_old.meta = it->oldMeta;
- action.n_new.name = getNodeName(it->newNode);
- action.n_new.param1 = it->newParam1;
- action.n_new.param2 = it->newParam2;
- action.n_new.meta = it->newMeta;
+ action.p = v3s16(row.x, row.y, row.z);
+ action.n_old.name = getNodeName(row.oldNode);
+ action.n_old.param1 = row.oldParam1;
+ action.n_old.param2 = row.oldParam2;
+ action.n_old.meta = row.oldMeta;
+ action.n_new.name = getNodeName(row.newNode);
+ action.n_new.param1 = row.newParam1;
+ action.n_new.param2 = row.newParam2;
+ action.n_new.meta = row.newMeta;
break;
default:
@@ -870,7 +869,7 @@ void RollbackManager::setActor(const std::string & actor, bool is_guess)
std::string RollbackManager::getSuspect(v3s16 p, float nearness_shortcut,
float min_nearness)
{
- if (current_actor != "") {
+ if (!current_actor.empty()) {
return current_actor;
}
int cur_time = time(0);
@@ -883,7 +882,7 @@ std::string RollbackManager::getSuspect(v3s16 p, float nearness_shortcut,
if (i->unix_time < first_time) {
break;
}
- if (i->actor == "") {
+ if (i->actor.empty()) {
continue;
}
// Find position of suspect or continue
@@ -919,7 +918,7 @@ void RollbackManager::flush()
for (iter = action_todisk_buffer.begin();
iter != action_todisk_buffer.end();
++iter) {
- if (iter->actor == "") {
+ if (iter->actor.empty()) {
continue;
}