summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-20 17:21:29 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-20 17:21:29 +0200
commitc62e2cd49649109f0135e56ee8add0dab2254d01 (patch)
tree7e6240186a3801daf0189d1883081b93b5f1eb5c /src/World.cpp
parent2017-08-19 (diff)
downloadAltCraft-c62e2cd49649109f0135e56ee8add0dab2254d01.tar
AltCraft-c62e2cd49649109f0135e56ee8add0dab2254d01.tar.gz
AltCraft-c62e2cd49649109f0135e56ee8add0dab2254d01.tar.bz2
AltCraft-c62e2cd49649109f0135e56ee8add0dab2254d01.tar.lz
AltCraft-c62e2cd49649109f0135e56ee8add0dab2254d01.tar.xz
AltCraft-c62e2cd49649109f0135e56ee8add0dab2254d01.tar.zst
AltCraft-c62e2cd49649109f0135e56ee8add0dab2254d01.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 740c276..c79d1b7 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -130,12 +130,16 @@ std::vector<Vector> World::GetSectionsList() {
return sectionsList;
}
+static Section fallbackSection = Section(PackedSection());
+
const Section &World::GetSection(Vector sectionPos) {
auto result = cachedSections.find(sectionPos);
if (result == cachedSections.end()) {
auto it = sections.find(sectionPos);
- if (it == sections.end())
- LOG(ERROR) << "BAD";
+ if (it == sections.end()) {
+ LOG(ERROR) << "Accessed not loaded section " << sectionPos;
+ return fallbackSection;
+ }
Section section(it->second);
auto result = cachedSections.insert(std::make_pair(sectionPos, section));
return result.first->second;
@@ -216,7 +220,7 @@ void World::DeleteEntity(unsigned int EntityId)
void World::ParseChunkData(std::shared_ptr<PacketBlockChange> packet) {
Block& block = this->GetBlock(packet->Position);
- block = Block(packet->BlockId >> 4, packet->BlockId & 15);
+ block = Block(packet->BlockId >> 4, packet->BlockId & 15, block.light, block.sky);
Vector sectionPos(std::floor(packet->Position.x / 16.0), std::floor(packet->Position.y / 16.0), std::floor(packet->Position.z / 16.0));
EventAgregator::PushEvent(EventType::ChunkChanged, ChunkChangedData{ sectionPos });
}
@@ -229,7 +233,7 @@ void World::ParseChunkData(std::shared_ptr<PacketMultiBlockChange> packet) {
int z = (it.HorizontalPosition & 15) + (packet->ChunkZ * 16);
Vector worldPos(x, y, z);
Block& block = GetBlock(worldPos);
- block = Block(it.BlockId >> 4, it.BlockId & 15);
+ block = Block(it.BlockId >> 4, it.BlockId & 15, block.light, block.sky);
Vector sectionPos(packet->ChunkX, std::floor(it.YCoordinate / 16.0), packet->ChunkZ);
if (std::find(changedSections.begin(), changedSections.end(), sectionPos) == changedSections.end())