move block set logic to the blocks_agent

This commit is contained in:
MihailRis
2024-12-16 20:46:06 +03:00
parent 6157f8193d
commit 87c19d69dc
7 changed files with 210 additions and 133 deletions
-18
View File
@@ -16,16 +16,6 @@
#include "Block.hpp"
#include "Chunk.hpp"
inline uint64_t keyfrom(int32_t x, int32_t z) {
union {
int32_t pos[2];
uint64_t key;
} ekey;
ekey.pos[0] = x;
ekey.pos[1] = z;
return ekey.key;
}
static debug::Logger logger("chunks-storage");
GlobalChunks::GlobalChunks(Level* level)
@@ -208,11 +198,3 @@ void GlobalChunks::saveAll() {
void GlobalChunks::putChunk(std::shared_ptr<Chunk> chunk) {
chunksMap[keyfrom(chunk->x, chunk->z)] = std::move(chunk);
}
Chunk* GlobalChunks::getChunk(int cx, int cz) const {
const auto& found = chunksMap.find(keyfrom(cx, cz));
if (found == chunksMap.end()) {
return nullptr;
}
return found->second.get();
}