This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

View file

@ -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