From 866fde81ca50f223c88af77d0092a2f4e60f7ce9 Mon Sep 17 00:00:00 2001 From: andrew Date: Sat, 22 Feb 2014 13:59:49 +0200 Subject: Documented and exported cMap --- src/Map.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'src/Map.cpp') 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); -- cgit v1.2.3