summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2020-07-27 23:12:53 +0200
committerGitHub <noreply@github.com>2020-07-27 23:12:53 +0200
commitf1e6ccd798b643308c2b468fc081bd2ad552c840 (patch)
treebfa380e1b81ab848766becff8322e783e4dcde1a /src/World.cpp
parentMerge pull request #40 from LaG1924/lua-scripting (diff)
parentSupport for non-overworld dimensions (diff)
downloadAltCraft-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.cpp20
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());