summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2020-07-29 05:26:36 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2020-07-29 05:26:36 +0200
commit8e71de537636dbeb0be9d018a8518e49a7e8e667 (patch)
treee683ba67fca6e1cee6f9c7dc4228c5a4b3f01432
parentMerge pull request #42 from LaG1924/ftr/chat_component_parse (diff)
downloadAltCraft-8e71de537636dbeb0be9d018a8518e49a7e8e667.tar
AltCraft-8e71de537636dbeb0be9d018a8518e49a7e8e667.tar.gz
AltCraft-8e71de537636dbeb0be9d018a8518e49a7e8e667.tar.bz2
AltCraft-8e71de537636dbeb0be9d018a8518e49a7e8e667.tar.lz
AltCraft-8e71de537636dbeb0be9d018a8518e49a7e8e667.tar.xz
AltCraft-8e71de537636dbeb0be9d018a8518e49a7e8e667.tar.zst
AltCraft-8e71de537636dbeb0be9d018a8518e49a7e8e667.zip
Diffstat (limited to '')
-rw-r--r--src/Section.cpp8
-rw-r--r--src/World.cpp7
2 files changed, 10 insertions, 5 deletions
diff --git a/src/Section.cpp b/src/Section.cpp
index 4a15c58..1d9c203 100644
--- a/src/Section.cpp
+++ b/src/Section.cpp
@@ -61,16 +61,16 @@ BlockId Section::GetBlockId(Vector pos) const {
return iter->second;
}
- int value;
+ unsigned int value;
- unsigned char individualValueMask = ((1 << bitsPerBlock) - 1);
+ unsigned int individualValueMask = ((1 << (unsigned int)bitsPerBlock) - 1);
int blockNumber = (((pos.y * 16) + pos.z) * 16) + pos.x;
int startLong = (blockNumber * bitsPerBlock) / 64;
int startOffset = (blockNumber * bitsPerBlock) % 64;
int endLong = ((blockNumber + 1) * bitsPerBlock - 1) / 64;
- unsigned char t;
+ unsigned int t;
if (startLong == endLong) {
t = (block[startLong] >> startOffset);
@@ -85,7 +85,7 @@ BlockId Section::GetBlockId(Vector pos) const {
if (t >= palette.size()) {
//LOG(ERROR) << "Out of palette: " << t;
- value = 0;
+ value = t;
}
else
value = palette[t];
diff --git a/src/World.cpp b/src/World.cpp
index d767871..c3246dc 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -378,7 +378,12 @@ void World::SetBlockId(Vector pos, BlockId block) {
std::floor(pos.y / 16.0),
std::floor(pos.z / 16.0));
Vector blockPos = pos - (sectionPos * 16);
- auto section = std::make_shared<Section>(*GetSectionPtr(sectionPos));
+ const Section* sectionPtr = GetSectionPtr(sectionPos);
+ if (!sectionPtr) {
+ LOG(ERROR) << "Updating unloaded chunk " << sectionPos;
+ return;
+ }
+ auto section = std::make_shared<Section>(*sectionPtr);
section->SetBlockId(blockPos, block);
sections[sectionPos] = section;
PUSH_EVENT("ChunkChanged",sectionPos);