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

#include <database-files.h>

+ Inheritance diagram for PlayerDatabaseFiles:
+ Collaboration diagram for PlayerDatabaseFiles:

Public Member Functions

 PlayerDatabaseFiles (const std::string &savedir)
 
virtual ~PlayerDatabaseFiles ()=default
 
void savePlayer (RemotePlayer *player)
 
bool loadPlayer (RemotePlayer *player, PlayerSAO *sao)
 
bool removePlayer (const std::string &name)
 
void listPlayers (std::vector< std::string > &res)
 
- Public Member Functions inherited from PlayerDatabase
virtual ~PlayerDatabase ()=default
 

Private Member Functions

void deSerialize (RemotePlayer *p, std::istream &is, const std::string &playername, PlayerSAO *sao)
 
void serialize (RemotePlayer *p, std::ostream &os)
 

Private Attributes

std::string m_savedir
 

Constructor & Destructor Documentation

◆ PlayerDatabaseFiles()

PlayerDatabaseFiles::PlayerDatabaseFiles ( const std::string & savedir)

References fs::CreateDir(), and m_savedir.

+ Here is the call graph for this function:

◆ ~PlayerDatabaseFiles()

virtual PlayerDatabaseFiles::~PlayerDatabaseFiles ( )
virtualdefault

Member Function Documentation

◆ deSerialize()

void PlayerDatabaseFiles::deSerialize ( RemotePlayer * p,
std::istream & is,
const std::string & playername,
PlayerSAO * sao )
private

References errorstream, Settings::exists(), Settings::get(), Settings::getBool(), Settings::getFloat(), PlayerSAO::getMeta(), Settings::getU16(), Settings::getV3F(), p(), Settings::parseConfigLines(), PLAYER_MAX_HP_DEFAULT, PlayerSAO::setBasePosition(), PlayerSAO::setBreath(), PlayerSAO::setHPRaw(), PlayerSAO::setLookPitch(), SimpleMetadata::setModified(), PlayerSAO::setPlayerYaw(), SimpleMetadata::setString(), and BaseException::what().

Referenced by listPlayers(), loadPlayer(), removePlayer(), and savePlayer().

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

◆ listPlayers()

void PlayerDatabaseFiles::listPlayers ( std::vector< std::string > & res)
virtual

Implements PlayerDatabase.

References deSerialize(), DIR_DELIM, fs::GetDirListing(), Player::getName(), m_savedir, and open_ifstream().

+ Here is the call graph for this function:

◆ loadPlayer()

bool PlayerDatabaseFiles::loadPlayer ( RemotePlayer * player,
PlayerSAO * sao )
virtual

Implements PlayerDatabase.

References deSerialize(), DIR_DELIM, Player::getName(), infostream, itos(), m_savedir, open_ifstream(), and PLAYER_FILE_ALTERNATE_TRIES.

+ Here is the call graph for this function:

◆ removePlayer()

bool PlayerDatabaseFiles::removePlayer ( const std::string & name)
virtual

Implements PlayerDatabase.

References fs::DeleteSingleFileOrEmptyDirectory(), deSerialize(), DIR_DELIM, Player::getName(), itos(), m_savedir, open_ifstream(), and PLAYER_FILE_ALTERNATE_TRIES.

+ Here is the call graph for this function:

◆ savePlayer()

void PlayerDatabaseFiles::savePlayer ( RemotePlayer * player)
virtual

Implements PlayerDatabase.

References fs::CreateDir(), deSerialize(), DIR_DELIM, errorstream, Player::getName(), infostream, itos(), m_savedir, RemotePlayer::onSuccessfulSave(), open_ifstream(), fs::PathExists(), PLAYER_FILE_ALTERNATE_TRIES, fs::safeWriteToFile(), and serialize().

+ Here is the call graph for this function:

◆ serialize()

void PlayerDatabaseFiles::serialize ( RemotePlayer * p,
std::ostream & os )
private

References fastWriteJson(), ServerActiveObject::getBasePosition(), PlayerSAO::getBreath(), UnitSAO::getHP(), PlayerSAO::getLookPitch(), PlayerSAO::getMeta(), UnitSAO::getRotation(), SimpleMetadata::getStrings(), p(), sanity_check, Settings::set(), Settings::setFloat(), Settings::setS32(), Settings::setU16(), Settings::setV3F(), and Settings::writeLines().

Referenced by savePlayer().

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

Member Data Documentation

◆ m_savedir

std::string PlayerDatabaseFiles::m_savedir
private

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