Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
RollbackManager Class Reference

#include <rollback.h>

+ Inheritance diagram for RollbackManager:
+ Collaboration diagram for RollbackManager:

Public Member Functions

 RollbackManager (const std::string &world_path, IGameDef *gamedef)
 
 ~RollbackManager ()
 
void reportAction (const RollbackAction &action_)
 
std::string getActor ()
 
bool isActorGuess ()
 
void setActor (const std::string &actor, bool is_guess)
 
std::string getSuspect (v3s16 p, float nearness_shortcut, float min_nearness)
 
void flush ()
 
void addAction (const RollbackAction &action)
 
std::list< RollbackActiongetNodeActors (v3s16 pos, int range, time_t seconds, int limit)
 
std::list< RollbackActiongetRevertActions (const std::string &actor_filter, time_t seconds)
 
- Public Member Functions inherited from IRollbackManager
virtual ~IRollbackManager ()=default
 

Private Member Functions

void registerNewActor (const int id, const std::string &name)
 
void registerNewNode (const int id, const std::string &name)
 
int getActorId (const std::string &name)
 
int getNodeId (const std::string &name)
 
const char * getActorName (const int id)
 
const char * getNodeName (const int id)
 
bool createTables ()
 
bool initDatabase ()
 
bool registerRow (const ActionRow &row)
 
const std::list< ActionRowactionRowsFromSelect (sqlite3_stmt *stmt)
 
ActionRow actionRowFromRollbackAction (const RollbackAction &action)
 
const std::list< RollbackActionrollbackActionsFromActionRows (const std::list< ActionRow > &rows)
 
const std::list< ActionRowgetRowsSince (time_t firstTime, const std::string &actor)
 
const std::list< ActionRowgetRowsSince_range (time_t firstTime, v3s16 p, int range, int limit)
 
const std::list< RollbackActiongetActionsSince_range (time_t firstTime, v3s16 p, int range, int limit)
 
const std::list< RollbackActiongetActionsSince (time_t firstTime, const std::string &actor="")
 

Static Private Member Functions

static float getSuspectNearness (bool is_guess, v3s16 suspect_p, time_t suspect_t, v3s16 action_p, time_t action_t)
 

Private Attributes

IGameDefgamedef = nullptr
 
std::string current_actor
 
bool current_actor_is_guess = false
 
std::list< RollbackActionaction_todisk_buffer
 
std::list< RollbackActionaction_latest_buffer
 
std::string database_path
 
sqlite3 * db
 
sqlite3_stmt * stmt_insert
 
sqlite3_stmt * stmt_replace
 
sqlite3_stmt * stmt_select
 
sqlite3_stmt * stmt_select_range
 
sqlite3_stmt * stmt_select_withActor
 
sqlite3_stmt * stmt_knownActor_select
 
sqlite3_stmt * stmt_knownActor_insert
 
sqlite3_stmt * stmt_knownNode_select
 
sqlite3_stmt * stmt_knownNode_insert
 
std::vector< EntityknownActors
 
std::vector< EntityknownNodes
 

Constructor & Destructor Documentation

◆ RollbackManager()

RollbackManager::RollbackManager ( const std::string & world_path,
IGameDef * gamedef )

References database_path, DIR_DELIM, initDatabase(), and verbosestream.

+ Here is the call graph for this function:

◆ ~RollbackManager()

RollbackManager::~RollbackManager ( )

References db, FINALIZE_STATEMENT, flush(), SQLOK_ERRSTREAM, stmt_insert, stmt_knownActor_insert, stmt_knownActor_select, stmt_knownNode_insert, stmt_knownNode_select, stmt_replace, stmt_select, stmt_select_range, and stmt_select_withActor.

+ Here is the call graph for this function:

Member Function Documentation

◆ actionRowFromRollbackAction()

◆ actionRowsFromSelect()

const std::list< ActionRow > RollbackManager::actionRowsFromSelect ( sqlite3_stmt * stmt)
private

References ActionRow::actor, ActionRow::add, ItemStack::count, getActorName(), ActionRow::guessed, ItemStackRow::id, ActionRow::index, itos(), ActionRow::list, ActionRow::location, ActionRow::newMeta, ActionRow::newNode, ActionRow::newParam1, ActionRow::newParam2, ActionRow::nodeMeta, ActionRow::oldMeta, ActionRow::oldNode, ActionRow::oldParam1, ActionRow::oldParam2, SQLOK, ActionRow::stack, ActionRow::timestamp, ActionRow::type, RollbackAction::TYPE_MODIFY_INVENTORY_STACK, RollbackAction::TYPE_SET_NODE, ActionRow::x, ActionRow::y, and ActionRow::z.

Referenced by getRowsSince(), and getRowsSince_range().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addAction()

void RollbackManager::addAction ( const RollbackAction & action)

References action_latest_buffer, action_todisk_buffer, and flush().

Referenced by reportAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTables()

bool RollbackManager::createTables ( )
private

References db, SQLOK, and verbosestream.

Referenced by initDatabase().

+ Here is the caller graph for this function:

◆ flush()

void RollbackManager::flush ( )
virtual

Implements IRollbackManager.

References action_todisk_buffer, actionRowFromRollbackAction(), db, and registerRow().

Referenced by ~RollbackManager(), addAction(), getNodeActors(), and getRevertActions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActionsSince()

const std::list< RollbackAction > RollbackManager::getActionsSince ( time_t firstTime,
const std::string & actor = "" )
private

References getRowsSince(), and rollbackActionsFromActionRows().

Referenced by getRevertActions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActionsSince_range()

const std::list< RollbackAction > RollbackManager::getActionsSince_range ( time_t firstTime,
v3s16 p,
int range,
int limit )
private

References getRowsSince_range(), p(), and rollbackActionsFromActionRows().

Referenced by getNodeActors().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActor()

std::string RollbackManager::getActor ( )
virtual

Implements IRollbackManager.

References current_actor.

◆ getActorId()

int RollbackManager::getActorId ( const std::string & name)
private

References db, knownActors, registerNewActor(), SQLOK, SQLRES, and stmt_knownActor_insert.

Referenced by actionRowFromRollbackAction(), and getRowsSince().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActorName()

const char * RollbackManager::getActorName ( const int id)
private

References knownActors.

Referenced by actionRowsFromSelect(), and rollbackActionsFromActionRows().

+ Here is the caller graph for this function:

◆ getNodeActors()

std::list< RollbackAction > RollbackManager::getNodeActors ( v3s16 pos,
int range,
time_t seconds,
int limit )
virtual

Implements IRollbackManager.

References flush(), and getActionsSince_range().

+ Here is the call graph for this function:

◆ getNodeId()

int RollbackManager::getNodeId ( const std::string & name)
private

References db, knownNodes, registerNewNode(), SQLOK, SQLRES, and stmt_knownNode_insert.

Referenced by actionRowFromRollbackAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNodeName()

const char * RollbackManager::getNodeName ( const int id)
private

References knownNodes.

Referenced by rollbackActionsFromActionRows().

+ Here is the caller graph for this function:

◆ getRevertActions()

std::list< RollbackAction > RollbackManager::getRevertActions ( const std::string & actor_filter,
time_t seconds )
virtual

Implements IRollbackManager.

References flush(), and getActionsSince().

+ Here is the call graph for this function:

◆ getRowsSince()

const std::list< ActionRow > RollbackManager::getRowsSince ( time_t firstTime,
const std::string & actor )
private

References actionRowsFromSelect(), getActorId(), stmt_select, and stmt_select_withActor.

Referenced by getActionsSince().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRowsSince_range()

const std::list< ActionRow > RollbackManager::getRowsSince_range ( time_t firstTime,
v3s16 p,
int range,
int limit )
private

References actionRowsFromSelect(), p(), and stmt_select_range.

Referenced by getActionsSince_range().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSuspect()

std::string RollbackManager::getSuspect ( v3s16 p,
float nearness_shortcut,
float min_nearness )
virtual

Implements IRollbackManager.

References action_latest_buffer, current_actor, getSuspectNearness(), and p().

Referenced by reportAction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSuspectNearness()

float RollbackManager::getSuspectNearness ( bool is_guess,
v3s16 suspect_p,
time_t suspect_t,
v3s16 action_p,
time_t action_t )
staticprivate

References intToFloat(), and POINTS_PER_NODE.

Referenced by getSuspect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDatabase()

bool RollbackManager::initDatabase ( )
private

References createTables(), database_path, db, fs::PathExists(), registerNewActor(), registerNewNode(), SQLOK, stmt_insert, stmt_knownActor_insert, stmt_knownActor_select, stmt_knownNode_insert, stmt_knownNode_select, stmt_replace, stmt_select, stmt_select_range, stmt_select_withActor, and verbosestream.

Referenced by RollbackManager().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isActorGuess()

bool RollbackManager::isActorGuess ( )
virtual

Implements IRollbackManager.

References current_actor_is_guess.

◆ registerNewActor()

void RollbackManager::registerNewActor ( const int id,
const std::string & name )
private

References knownActors.

Referenced by getActorId(), and initDatabase().

+ Here is the caller graph for this function:

◆ registerNewNode()

void RollbackManager::registerNewNode ( const int id,
const std::string & name )
private

References knownNodes.

Referenced by getNodeId(), and initDatabase().

+ Here is the caller graph for this function:

◆ registerRow()

◆ reportAction()

void RollbackManager::reportAction ( const RollbackAction & action_)
virtual

Implements IRollbackManager.

References RollbackAction::actor, RollbackAction::actor_is_guess, addAction(), current_actor, current_actor_is_guess, gamedef, RollbackAction::getPosition(), getSuspect(), RollbackAction::isImportant(), p(), and RollbackAction::unix_time.

+ Here is the call graph for this function:

◆ rollbackActionsFromActionRows()

const std::list< RollbackAction > RollbackManager::rollbackActionsFromActionRows ( const std::list< ActionRow > & rows)
private

References RollbackAction::actor, getActorName(), getNodeName(), RollbackAction::inventory_add, RollbackAction::inventory_index, RollbackAction::inventory_list, RollbackAction::inventory_location, RollbackAction::inventory_stack, RollbackNode::meta, RollbackAction::n_new, RollbackAction::n_old, ItemStack::name, RollbackNode::name, RollbackAction::p, RollbackNode::param1, RollbackNode::param2, RollbackAction::type, RollbackAction::TYPE_MODIFY_INVENTORY_STACK, RollbackAction::TYPE_SET_NODE, and RollbackAction::unix_time.

Referenced by getActionsSince(), and getActionsSince_range().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActor()

void RollbackManager::setActor ( const std::string & actor,
bool is_guess )
virtual

Member Data Documentation

◆ action_latest_buffer

std::list<RollbackAction> RollbackManager::action_latest_buffer
private

Referenced by addAction(), and getSuspect().

◆ action_todisk_buffer

std::list<RollbackAction> RollbackManager::action_todisk_buffer
private

Referenced by addAction(), and flush().

◆ current_actor

std::string RollbackManager::current_actor
private

◆ current_actor_is_guess

bool RollbackManager::current_actor_is_guess = false
private

◆ database_path

std::string RollbackManager::database_path
private

Referenced by RollbackManager(), and initDatabase().

◆ db

sqlite3* RollbackManager::db
private

◆ gamedef

IGameDef* RollbackManager::gamedef = nullptr
private

Referenced by reportAction().

◆ knownActors

std::vector<Entity> RollbackManager::knownActors
private

◆ knownNodes

std::vector<Entity> RollbackManager::knownNodes
private

◆ stmt_insert

sqlite3_stmt* RollbackManager::stmt_insert
private

◆ stmt_knownActor_insert

sqlite3_stmt* RollbackManager::stmt_knownActor_insert
private

◆ stmt_knownActor_select

sqlite3_stmt* RollbackManager::stmt_knownActor_select
private

Referenced by ~RollbackManager(), and initDatabase().

◆ stmt_knownNode_insert

sqlite3_stmt* RollbackManager::stmt_knownNode_insert
private

◆ stmt_knownNode_select

sqlite3_stmt* RollbackManager::stmt_knownNode_select
private

Referenced by ~RollbackManager(), and initDatabase().

◆ stmt_replace

sqlite3_stmt* RollbackManager::stmt_replace
private

◆ stmt_select

sqlite3_stmt* RollbackManager::stmt_select
private

◆ stmt_select_range

sqlite3_stmt* RollbackManager::stmt_select_range
private

◆ stmt_select_withActor

sqlite3_stmt* RollbackManager::stmt_select_withActor
private

The documentation for this class was generated from the following files: