MCPcopy Create free account
hub / github.com/cuberite/cuberite / UpdatePixel

Method UpdatePixel

src/Map.cpp:196–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194
195
196bool cMap::UpdatePixel(unsigned int a_X, unsigned int a_Z)
197{
198 unsigned int PixelWidth = GetPixelWidth();
199
200 int BlockX = m_CenterX + ((a_X - (m_Width / 2)) * PixelWidth);
201 int BlockZ = m_CenterZ + ((a_Z - (m_Height / 2)) * PixelWidth);
202
203 int ChunkX, ChunkY, ChunkZ;
204 m_World->BlockToChunk(BlockX, 0, BlockZ, ChunkX, ChunkY, ChunkZ);
205
206 int RelX = BlockX - (ChunkX * cChunkDef::Width);
207 int RelZ = BlockZ - (ChunkZ * cChunkDef::Width);
208
209 class cCalculatePixelCb :
210 public cChunkCallback
211 {
212 cMap * m_Map;
213
214 int m_RelX, m_RelZ;
215
216 ColorID m_PixelData;
217
218 public:
219 cCalculatePixelCb(cMap * a_Map, int a_RelX, int a_RelZ)
220 : m_Map(a_Map), m_RelX(a_RelX), m_RelZ(a_RelZ), m_PixelData(E_BASE_COLOR_TRANSPARENT) {}
221
222 virtual bool Item(cChunk * a_Chunk) override
223 {
224 if (a_Chunk == NULL)
225 {
226 return false;
227 }
228
229 unsigned int PixelWidth = m_Map->GetPixelWidth();
230
231 if (m_Map->GetDimension() == dimNether)
232 {
233 // TODO 2014-02-22 xdot: Nether maps
234
235 return false;
236 }
237
238 typedef std::map<ColorID, unsigned int> ColorCountMap;
239 ColorCountMap ColorCounts;
240
241 // Count surface blocks
242 for (unsigned int X = m_RelX; X < m_RelX + PixelWidth; ++X)
243 {
244 for (unsigned int Z = m_RelZ; Z < m_RelZ + PixelWidth; ++Z)
245 {
246 // unsigned int WaterDepth = 0;
247
248 BLOCKTYPE TargetBlock = E_BLOCK_AIR;
249 NIBBLETYPE TargetMeta = 0;
250
251 int Height = a_Chunk->GetHeight(X, Z);
252
253 while (Height > 0)

Callers

nothing calls this directly

Calls 3

GetPixelDataMethod · 0.80
BlockToChunkMethod · 0.45
DoWithChunkMethod · 0.45

Tested by

no test coverage detected