std::list<RollbackAction> getRevertActions(const std::string &actor_filter, int seconds) { infostream<<"RollbackManager::getRevertActions("<<actor_filter <<", "<<seconds<<")"<<std::endl; // Figure out time int cur_time = time(0); int first_time = cur_time - seconds; std::list<RollbackAction> action_buffer = getEntriesSince(first_time); std::list<RollbackAction> result; for(std::list<RollbackAction>::const_reverse_iterator i = action_buffer.rbegin(); i != action_buffer.rend(); i++) { if(i->unix_time < first_time) break; if(i->actor != actor_filter) continue; const RollbackAction &action = *i; /*infostream<<"RollbackManager::revertAction(): Should revert" <<" time="<<action.unix_time <<" actor=\""<<action.actor<<"\"" <<" action="<<action.toString() <<std::endl;*/ result.push_back(action); } return result; }
std::string getLastNodeActor(v3s16 p, int range, int seconds, v3s16 *act_p, int *act_seconds) { infostream<<"RollbackManager::getLastNodeActor("<<PP(p) <<", "<<seconds<<")"<<std::endl; // Figure out time int cur_time = time(0); int first_time = cur_time - seconds; std::list<RollbackAction> action_buffer = getEntriesSince(first_time); std::list<RollbackAction> result; for(std::list<RollbackAction>::const_reverse_iterator i = action_buffer.rbegin(); i != action_buffer.rend(); i++) { if(i->unix_time < first_time) break; // Find position of action or continue v3s16 action_p; if(i->type == RollbackAction::TYPE_SET_NODE) { action_p = i->p; } else if(i->type == RollbackAction::TYPE_MODIFY_INVENTORY_STACK) { InventoryLocation loc; loc.deSerialize(i->inventory_location); if(loc.type != InventoryLocation::NODEMETA) continue; action_p = loc.p; } else continue; if(range == 0){ if(action_p != p) continue; } else { if(abs(action_p.X - p.X) > range || abs(action_p.Y - p.Y) > range || abs(action_p.Z - p.Z) > range) continue; } if(act_p) *act_p = action_p; if(act_seconds) *act_seconds = cur_time - i->unix_time; return i->actor; } return ""; }
std::string getLastNodeActor(v3s16 p, int range, int seconds, v3s16 *act_p, int *act_seconds) { infostream<<"RollbackManager::getLastNodeActor("<<PP(p) <<", "<<seconds<<")"<<std::endl; // Figure out time int cur_time = time(0); int first_time = cur_time - seconds; std::list<RollbackAction> action_buffer = getEntriesSince(first_time); std::list<RollbackAction> result; for(std::list<RollbackAction>::const_reverse_iterator i = action_buffer.rbegin(); i != action_buffer.rend(); i++) { if(i->unix_time < first_time) break; // Find position of action or continue v3s16 action_p; if(!i->getPosition(&action_p)) continue; if(range == 0){ if(action_p != p) continue; } else { if(abs(action_p.X - p.X) > range || abs(action_p.Y - p.Y) > range || abs(action_p.Z - p.Z) > range) continue; } if(act_p) *act_p = action_p; if(act_seconds) *act_seconds = cur_time - i->unix_time; return i->actor; } return ""; }