summaryrefslogtreecommitdiffstats
path: root/Section.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-04-23 15:39:59 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-04-21 15:39:59 +0200
commitd46f3a7180afdb5213afc80c97ae5fc8db43248a (patch)
tree2e00ab460474084042176d71df3f6f2cee8d3d63 /Section.cpp
parent2017-04-21 (diff)
downloadAltCraft-d46f3a7180afdb5213afc80c97ae5fc8db43248a.tar
AltCraft-d46f3a7180afdb5213afc80c97ae5fc8db43248a.tar.gz
AltCraft-d46f3a7180afdb5213afc80c97ae5fc8db43248a.tar.bz2
AltCraft-d46f3a7180afdb5213afc80c97ae5fc8db43248a.tar.lz
AltCraft-d46f3a7180afdb5213afc80c97ae5fc8db43248a.tar.xz
AltCraft-d46f3a7180afdb5213afc80c97ae5fc8db43248a.tar.zst
AltCraft-d46f3a7180afdb5213afc80c97ae5fc8db43248a.zip
Diffstat (limited to 'Section.cpp')
-rw-r--r--Section.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Section.cpp b/Section.cpp
index a04ed41..8df5953 100644
--- a/Section.cpp
+++ b/Section.cpp
@@ -34,7 +34,12 @@ Section::~Section() {
Block &Section::GetBlock(PositionI pos) {
if (m_dataBlocks != nullptr) {
- Parse();
+ std::mutex parseMutex;
+ std::unique_lock<std::mutex> parseLocker(parseMutex);
+ parseWaiter.wait(parseLocker);
+ while (m_dataBlocks != nullptr) {
+ parseWaiter.wait(parseLocker);
+ }
}
return m_blocks[pos.GetY() * 256 + pos.GetZ() * 16 + pos.GetX()];
}
@@ -89,6 +94,7 @@ void Section::Parse() {
m_dataLight = nullptr;
delete[] m_dataSkyLight;
m_dataSkyLight = nullptr;
+ parseWaiter.notify_all();
}
Section &Section::operator=(Section other) {
@@ -109,14 +115,14 @@ void Section::swap(Section &other) {
Section::Section(const Section &other) {
m_dataBlocksLen = other.m_dataBlocksLen;
m_dataBlocks = new byte[m_dataBlocksLen];
- std::copy(other.m_dataBlocks,other.m_dataBlocks+m_dataBlocksLen,m_dataBlocks);
+ std::copy(other.m_dataBlocks, other.m_dataBlocks + m_dataBlocksLen, m_dataBlocks);
m_dataLight = new byte[2048];
- std::copy(other.m_dataLight,other.m_dataLight+2048,m_dataLight);
+ std::copy(other.m_dataLight, other.m_dataLight + 2048, m_dataLight);
if (other.m_dataSkyLight) {
m_dataSkyLight = new byte[2048];
- std::copy(other.m_dataSkyLight,other.m_dataSkyLight+2048,m_dataSkyLight);
+ std::copy(other.m_dataSkyLight, other.m_dataSkyLight + 2048, m_dataSkyLight);
}
m_palette = other.m_palette;