feat: auto patch invalid inventory id pre 0.25
This commit is contained in:
parent
371fdaedce
commit
e70d30b9a2
@ -148,6 +148,11 @@ std::unique_ptr<Level> World::load(
|
||||
0
|
||||
);
|
||||
player->deserialize(playerMap);
|
||||
auto& inventory = player->getInventory();
|
||||
// invalid inventory id pre 0.25
|
||||
if (inventory->getId() == 0) {
|
||||
inventory->setId(level->getWorld()->getNextInventoryId());
|
||||
}
|
||||
level->inventories->store(player->getInventory());
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -27,7 +27,7 @@ struct WorldInfo : public Serializable {
|
||||
std::string name;
|
||||
std::string generator;
|
||||
uint64_t seed;
|
||||
int64_t nextInventoryId = 0;
|
||||
int64_t nextInventoryId = 1;
|
||||
|
||||
/// @brief Day/night loop timer in range 0..1 where
|
||||
/// 0.0 - is midnight and
|
||||
@ -58,8 +58,6 @@ class World {
|
||||
const Content* const content;
|
||||
std::vector<ContentPack> packs;
|
||||
|
||||
int64_t nextInventoryId = 1;
|
||||
|
||||
void writeResources(const Content* content);
|
||||
public:
|
||||
std::shared_ptr<WorldFiles> wfile;
|
||||
@ -155,7 +153,7 @@ public:
|
||||
/// @brief Get next inventory id and increment it's counter
|
||||
/// @return integer >= 1
|
||||
int64_t getNextInventoryId() {
|
||||
return nextInventoryId++;
|
||||
return info.nextInventoryId++;
|
||||
}
|
||||
|
||||
/// @brief Get current world Content instance
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user