mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 21:11:50 +00:00
cleanup
This commit is contained in:
parent
923ca2b89e
commit
d708e8d21c
4 changed files with 8 additions and 10 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
#include "Inventories.hpp"
|
#include "Inventories.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "world/Level.hpp"
|
#include "world/Level.hpp"
|
||||||
#include "world/World.hpp"
|
#include "world/World.hpp"
|
||||||
|
#include "content/Content.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
Inventories::Inventories(Level& level) : level(level) {
|
Inventories::Inventories(Level& level) : level(level) {
|
||||||
}
|
}
|
||||||
|
|
@ -32,8 +33,9 @@ std::shared_ptr<Inventory> Inventories::createVirtual(size_t size) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inventories::store(const std::shared_ptr<Inventory>& inv) {
|
void Inventories::store(const std::shared_ptr<Inventory>& inventory) {
|
||||||
map[inv->getId()] = inv;
|
inventory->check(*level.content.getIndices());
|
||||||
|
map[inventory->getId()] = inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inventories::remove(int64_t id) {
|
void Inventories::remove(int64_t id) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
/// @brief Create runtime-only inventory (has negative id)
|
/// @brief Create runtime-only inventory (has negative id)
|
||||||
std::shared_ptr<Inventory> createVirtual(size_t size);
|
std::shared_ptr<Inventory> createVirtual(size_t size);
|
||||||
|
|
||||||
/// @brief Store inventory
|
/// @brief Check and add inventory to the storage
|
||||||
void store(const std::shared_ptr<Inventory>& inv);
|
void store(const std::shared_ptr<Inventory>& inv);
|
||||||
|
|
||||||
/// @brief Remove inventory from map
|
/// @brief Remove inventory from map
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,7 @@ Player* Players::create(int64_t id) {
|
||||||
auto player = playerPtr.get();
|
auto player = playerPtr.get();
|
||||||
add(std::move(playerPtr));
|
add(std::move(playerPtr));
|
||||||
|
|
||||||
auto inventory = player->getInventory();
|
level.inventories->store(player->getInventory());
|
||||||
inventory->check(*level.content.getIndices());
|
|
||||||
level.inventories->store(std::move(inventory));
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,7 +148,6 @@ void Players::deserialize(const dv::value& src) {
|
||||||
if (inventory->getId() == 0) {
|
if (inventory->getId() == 0) {
|
||||||
inventory->setId(level.getWorld()->getNextInventoryId());
|
inventory->setId(level.getWorld()->getNextInventoryId());
|
||||||
}
|
}
|
||||||
inventory->check(*level.content.getIndices());
|
|
||||||
level.inventories->store(inventory);
|
level.inventories->store(inventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,6 @@ std::shared_ptr<Chunk> GlobalChunks::create(int x, int z, bool lighting) {
|
||||||
|
|
||||||
chunk->flags.loaded = true;
|
chunk->flags.loaded = true;
|
||||||
for (auto& entry : chunk->inventories) {
|
for (auto& entry : chunk->inventories) {
|
||||||
entry.second->check(indices);
|
|
||||||
level.inventories->store(entry.second);
|
level.inventories->store(entry.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue