diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2020-07-27 23:12:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-27 23:12:53 +0200 |
commit | f1e6ccd798b643308c2b468fc081bd2ad552c840 (patch) | |
tree | bfa380e1b81ab848766becff8322e783e4dcde1a /src/World.cpp | |
parent | Merge pull request #40 from LaG1924/lua-scripting (diff) | |
parent | Support for non-overworld dimensions (diff) | |
download | AltCraft-f1e6ccd798b643308c2b468fc081bd2ad552c840.tar AltCraft-f1e6ccd798b643308c2b468fc081bd2ad552c840.tar.gz AltCraft-f1e6ccd798b643308c2b468fc081bd2ad552c840.tar.bz2 AltCraft-f1e6ccd798b643308c2b468fc081bd2ad552c840.tar.lz AltCraft-f1e6ccd798b643308c2b468fc081bd2ad552c840.tar.xz AltCraft-f1e6ccd798b643308c2b468fc081bd2ad552c840.tar.zst AltCraft-f1e6ccd798b643308c2b468fc081bd2ad552c840.zip |
Diffstat (limited to 'src/World.cpp')
-rw-r--r-- | src/World.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/World.cpp b/src/World.cpp index 00a1a19..d767871 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -9,6 +9,16 @@ #include "Packet.hpp" #include "Collision.hpp" +std::map<int, Dimension> registeredDimensions; + +void RegisterNewDimension(int dimensionId, Dimension newDimension) { + registeredDimensions[dimensionId] = newDimension; +} + +World::World(int dimensionId) : dimension(dimensionId) { + +} + void World::ParseChunkData(std::shared_ptr<PacketChunkData> packet) { StreamBuffer chunkData(packet->Data.data(), packet->Data.size()); std::bitset<16> bitmask(packet->PrimaryBitMask); @@ -24,7 +34,13 @@ void World::ParseChunkData(std::shared_ptr<PacketChunkData> packet) { UpdateSectionsList(); } else { - std::swap(sections.at(chunkPosition), section); + auto it = sections.find(chunkPosition); + if (it == sections.end()) { + LOG(WARNING) << "Chunk updating empty chunk"; + sections.insert(std::make_pair(chunkPosition, section)); + } + else + std::swap(sections.at(chunkPosition), section); } PUSH_EVENT("ChunkChanged", chunkPosition); @@ -44,7 +60,7 @@ Section World::ParseSection(StreamInput *data, Vector position) { auto dataArray = data->ReadByteArray(dataArrayLength * 8); auto blockLight = data->ReadByteArray(2048); std::vector<unsigned char> skyLight; - if (dimension == 0) + if (registeredDimensions[dimension].skylight) skyLight = data->ReadByteArray(2048); long long *blockData = reinterpret_cast<long long*>(dataArray.data()); |