diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-20 14:33:09 +1000 |
commit | 6352e8e3196f78388b6c771073f9e03eaa612673 (patch) | |
tree | e23772f79a7fbc41bc9108951e9e136857484bf4 /source/game/StarPlayerStorage.hpp | |
parent | 6741a057e5639280d85d0f88ba26f000baa58f61 (diff) |
everything everywhere
all at once
Diffstat (limited to 'source/game/StarPlayerStorage.hpp')
-rw-r--r-- | source/game/StarPlayerStorage.hpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/source/game/StarPlayerStorage.hpp b/source/game/StarPlayerStorage.hpp new file mode 100644 index 0000000..68dda4d --- /dev/null +++ b/source/game/StarPlayerStorage.hpp @@ -0,0 +1,51 @@ +#ifndef STAR_PLAYER_STORAGE_HPP +#define STAR_PLAYER_STORAGE_HPP + +#include "StarOrderedMap.hpp" +#include "StarUuid.hpp" +#include "StarPlayerFactory.hpp" +#include "StarThread.hpp" +#include "StarWorldStorage.hpp" +#include "StarStatistics.hpp" + +namespace Star { + +class PlayerStorage { +public: + PlayerStorage(String const& storageDir); + ~PlayerStorage(); + + size_t playerCount() const; + // Returns nothing if index is out of bounds. + Maybe<Uuid> playerUuidAt(size_t index); + + void savePlayer(PlayerPtr const& player); + PlayerPtr loadPlayer(Uuid const& uuid); + void deletePlayer(Uuid const& uuid); + + WorldChunks loadShipData(Uuid const& uuid); + void applyShipUpdates(Uuid const& uuid, WorldChunks const& updates); + + // Move the given player to the top of the player ordering. + void moveToFront(Uuid const& uuid); + + // Copy all the player relevant files for this uuid into .bak1 .bak2 etc + // files for however many backups are configured + void backupCycle(Uuid const& uuid); + + // Get / Set PlayerStorage global metadata + void setMetadata(String key, Json value); + Json getMetadata(String const& key); + +private: + void writeMetadata(); + + mutable RecursiveMutex m_mutex; + String m_storageDirectory; + OrderedHashMap<Uuid, Json> m_savedPlayersCache; + JsonObject m_metadata; +}; + +} + +#endif |