X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fdatabase.h;h=5a2b844fde740fe49930d7e7f97e422f72ccfab8;hb=605599b6f150b89ba6539c4d088231b326adcb48;hp=f04c4aa502c4fc2e8a08cd99f4aa0cd57ffd693e;hpb=9736548720a96c9c7f739edb0435d9ba4ad80652;p=dragonfireclient.git diff --git a/src/database.h b/src/database.h index f04c4aa50..5a2b844fd 100644 --- a/src/database.h +++ b/src/database.h @@ -20,28 +20,46 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef DATABASE_HEADER #define DATABASE_HEADER -#include #include +#include #include "irr_v3d.h" #include "irrlichttypes.h" - -#ifndef PP - #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")" -#endif +#include "util/basic_macros.h" class Database { public: virtual void beginSave() = 0; virtual void endSave() = 0; + virtual bool initialized() const { return true; } +}; + +class MapDatabase : public Database +{ +public: + virtual ~MapDatabase() {} + + virtual bool saveBlock(const v3s16 &pos, const std::string &data) = 0; + virtual void loadBlock(const v3s16 &pos, std::string *block) = 0; + virtual bool deleteBlock(const v3s16 &pos) = 0; - virtual bool saveBlock(v3s16 blockpos, std::string &data) = 0; - virtual std::string loadBlock(v3s16 blockpos) = 0; - virtual bool deleteBlock(v3s16 blockpos) = 0; - s64 getBlockAsInteger(const v3s16 pos) const; - v3s16 getIntegerAsBlock(s64 i) const; - virtual void listAllLoadableBlocks(std::list &dst) = 0; - virtual int Initialized(void)=0; - virtual ~Database() {}; + static s64 getBlockAsInteger(const v3s16 &pos); + static v3s16 getIntegerAsBlock(s64 i); + + virtual void listAllLoadableBlocks(std::vector &dst) = 0; }; + +class PlayerSAO; +class RemotePlayer; + +class PlayerDatabase +{ +public: + virtual ~PlayerDatabase() {} + virtual void savePlayer(RemotePlayer *player) = 0; + virtual bool loadPlayer(RemotePlayer *player, PlayerSAO *sao) = 0; + virtual bool removePlayer(const std::string &name) = 0; + virtual void listPlayers(std::vector &res) = 0; +}; + #endif