Better player save & load
This commit is contained in:
@@ -559,21 +559,6 @@ bool WorldFiles::readWorldInfo(World* world) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorldFiles::writePlayer(std::shared_ptr<Player> player) {
|
||||
files::write_json(getPlayerFile(), player->serialize().release());
|
||||
}
|
||||
|
||||
bool WorldFiles::readPlayer(std::shared_ptr<Player> player) {
|
||||
fs::path file = getPlayerFile();
|
||||
if (!fs::is_regular_file(file)) {
|
||||
std::cerr << "warning: player.json does not exists" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
player->deserialize(files::read_json(file).get());
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorldFiles::addPack(const World* world, const std::string& id) {
|
||||
fs::path file = getPacksFile();
|
||||
if (!fs::is_regular_file(file)) {
|
||||
|
||||
@@ -139,14 +139,9 @@ public:
|
||||
chunk_inventories_map fetchInventories(int x, int z);
|
||||
|
||||
bool readWorldInfo(World* world);
|
||||
bool readPlayer(std::shared_ptr<Player> player);
|
||||
|
||||
void writeRegion(int x, int y, WorldRegion* entry, fs::path file, int layer);
|
||||
|
||||
/// @brief Write player data to world files
|
||||
/// @param player target player
|
||||
void writePlayer(std::shared_ptr<Player> player);
|
||||
|
||||
/// @brief Write all unsaved data to world files
|
||||
/// @param world target world
|
||||
/// @param content world content
|
||||
@@ -169,4 +164,4 @@ public:
|
||||
static const char* WORLD_FILE;
|
||||
};
|
||||
|
||||
#endif /* FILES_WORLDFILES_H_ */
|
||||
#endif /* FILES_WORLDFILES_H_ */
|
||||
|
||||
Reference in New Issue
Block a user