From 49117de47658cd6c885f88010c9328f8ce3e6e93 Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 20 Sep 2020 12:51:12 -0700 Subject: Record player existence in dymmy database. --- src/database/database-dummy.cpp | 23 +++++++++++++++++++++++ src/database/database-dummy.h | 9 +++++---- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src/database') diff --git a/src/database/database-dummy.cpp b/src/database/database-dummy.cpp index a3d8cd579..b56f341c5 100644 --- a/src/database/database-dummy.cpp +++ b/src/database/database-dummy.cpp @@ -22,6 +22,7 @@ Dummy database class */ #include "database-dummy.h" +#include "remoteplayer.h" bool Database_Dummy::saveBlock(const v3s16 &pos, const std::string &data) @@ -57,3 +58,25 @@ void Database_Dummy::listAllLoadableBlocks(std::vector &dst) } } +void Database_Dummy::savePlayer(RemotePlayer *player) +{ + m_player_database.insert(player->getName()); +} + +bool Database_Dummy::loadPlayer(RemotePlayer *player, PlayerSAO *sao) +{ + return m_player_database.find(player->getName()) != m_player_database.end(); +} + +bool Database_Dummy::removePlayer(const std::string &name) +{ + m_player_database.erase(name); + return true; +} + +void Database_Dummy::listPlayers(std::vector &res) +{ + for (const auto &player : m_player_database) { + res.emplace_back(player); + } +} diff --git a/src/database/database-dummy.h b/src/database/database-dummy.h index 2d87d58f6..b69919f84 100644 --- a/src/database/database-dummy.h +++ b/src/database/database-dummy.h @@ -32,14 +32,15 @@ public: bool deleteBlock(const v3s16 &pos); void listAllLoadableBlocks(std::vector &dst); - void savePlayer(RemotePlayer *player) {} - bool loadPlayer(RemotePlayer *player, PlayerSAO *sao) { return true; } - bool removePlayer(const std::string &name) { return true; } - void listPlayers(std::vector &res) {} + void savePlayer(RemotePlayer *player); + bool loadPlayer(RemotePlayer *player, PlayerSAO *sao); + bool removePlayer(const std::string &name); + void listPlayers(std::vector &res); void beginSave() {} void endSave() {} private: std::map m_database; + std::set m_player_database; }; -- cgit v1.2.3