summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorandrew <xdotftw@gmail.com>2014-02-22 12:59:49 +0100
committerandrew <xdotftw@gmail.com>2014-02-22 12:59:49 +0100
commit866fde81ca50f223c88af77d0092a2f4e60f7ce9 (patch)
treef6fadfe5a21d74bdf26d2be22eecd8e034b85393 /src
parentSemi-working implementation of cMap::UpdatePixel (diff)
downloadcuberite-866fde81ca50f223c88af77d0092a2f4e60f7ce9.tar
cuberite-866fde81ca50f223c88af77d0092a2f4e60f7ce9.tar.gz
cuberite-866fde81ca50f223c88af77d0092a2f4e60f7ce9.tar.bz2
cuberite-866fde81ca50f223c88af77d0092a2f4e60f7ce9.tar.lz
cuberite-866fde81ca50f223c88af77d0092a2f4e60f7ce9.tar.xz
cuberite-866fde81ca50f223c88af77d0092a2f4e60f7ce9.tar.zst
cuberite-866fde81ca50f223c88af77d0092a2f4e60f7ce9.zip
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/AllToLua.pkg1
-rw-r--r--src/Map.cpp49
-rw-r--r--src/Map.h12
3 files changed, 53 insertions, 9 deletions
diff --git a/src/Bindings/AllToLua.pkg b/src/Bindings/AllToLua.pkg
index ef61f55f0..dd45a2aab 100644
--- a/src/Bindings/AllToLua.pkg
+++ b/src/Bindings/AllToLua.pkg
@@ -73,6 +73,7 @@ $cfile "../CraftingRecipes.h"
$cfile "../UI/Window.h"
$cfile "../Mobs/Monster.h"
$cfile "../CompositeChat.h"
+$cfile "../Map.h"
diff --git a/src/Map.cpp b/src/Map.cpp
index 87fe9555f..e89fad8b0 100644
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -323,7 +323,7 @@ bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
ASSERT(m_World != NULL);
m_World->DoWithChunk(ChunkX, ChunkZ, CalculatePixelCb);
- m_Data[a_Z + (a_X * m_Height)] = CalculatePixelCb.GetPixelData();
+ SetPixel(a_X, a_Z, CalculatePixelCb.GetPixelData());
return true;
}
@@ -516,11 +516,6 @@ void cMap::Resize(unsigned int a_Width, unsigned int a_Height)
void cMap::SetPosition(int a_CenterX, int a_CenterZ)
{
- if ((m_CenterX == a_CenterX) && (m_CenterZ == a_CenterZ))
- {
- return;
- }
-
m_CenterX = a_CenterX;
m_CenterZ = a_CenterZ;
}
@@ -548,6 +543,40 @@ void cMap::SetScale(unsigned int a_Scale)
+bool cMap::SetPixel(unsigned int a_X, unsigned int a_Z, cMap::ColorID a_Data)
+{
+ if ((a_X < m_Width) && (a_Z < m_Height))
+ {
+ m_Data[a_Z + (a_X * m_Height)] = a_Data;
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
+
+
+
+cMap::ColorID cMap::GetPixel(unsigned int a_X, unsigned int a_Z)
+{
+ if ((a_X < m_Width) && (a_Z < m_Height))
+ {
+ return m_Data[a_Z + (a_X * m_Height)];
+ }
+ else
+ {
+ return E_BASE_COLOR_TRANSPARENT;
+ }
+}
+
+
+
+
+
void cMap::SendTo(cClientHandle & a_Client)
{
a_Client.SendMapInfo(m_ID, m_Scale);
@@ -575,6 +604,14 @@ unsigned int cMap::GetNumPixels(void) const
+unsigned int cMap::GetNumDecorators(void) const
+{
+ return m_Decorators.size();
+}
+
+
+
+
unsigned int cMap::GetPixelWidth(void) const
{
return pow(2, m_Scale);
diff --git a/src/Map.h b/src/Map.h
index a86de3dd3..fc754e6eb 100644
--- a/src/Map.h
+++ b/src/Map.h
@@ -155,6 +155,10 @@ public:
void SetScale(unsigned int a_Scale);
+ bool SetPixel(unsigned int a_X, unsigned int a_Z, ColorID a_Data);
+
+ ColorID GetPixel(unsigned int a_X, unsigned int a_Z);
+
unsigned int GetWidth (void) const { return m_Width; }
unsigned int GetHeight(void) const { return m_Height; }
@@ -171,14 +175,16 @@ public:
eDimension GetDimension(void) const;
- const cColorList & GetData(void) const { return m_Data; }
-
unsigned int GetNumPixels(void) const;
unsigned int GetPixelWidth(void) const;
// tolua_end
+ unsigned int GetNumDecorators(void) const;
+
+ const cColorList & GetData(void) const { return m_Data; }
+
protected:
@@ -247,7 +253,7 @@ private:
friend class cMapSerializer;
-};
+}; // tolua_export