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

Method Read

src/BlockArea.cpp:337–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335
336
337bool cBlockArea::Read(cForEachChunkProvider * a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes)
338{
339 // Normalize the coords:
340 if (a_MinBlockX > a_MaxBlockX)
341 {
342 std::swap(a_MinBlockX, a_MaxBlockX);
343 }
344 if (a_MinBlockY > a_MaxBlockY)
345 {
346 std::swap(a_MinBlockY, a_MaxBlockY);
347 }
348 if (a_MinBlockZ > a_MaxBlockZ)
349 {
350 std::swap(a_MinBlockZ, a_MaxBlockZ);
351 }
352
353 // Include the Max coords:
354 a_MaxBlockX += 1;
355 a_MaxBlockY += 1;
356 a_MaxBlockZ += 1;
357
358 // Check coords validity:
359 if (a_MinBlockY < 0)
360 {
361 LOGWARNING("%s: MinBlockY less than zero, adjusting to zero", __FUNCTION__);
362 a_MinBlockY = 0;
363 }
364 else if (a_MinBlockY >= cChunkDef::Height)
365 {
366 LOGWARNING("%s: MinBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
367 a_MinBlockY = cChunkDef::Height - 1;
368 }
369 if (a_MaxBlockY < 0)
370 {
371 LOGWARNING("%s: MaxBlockY less than zero, adjusting to zero", __FUNCTION__);
372 a_MaxBlockY = 0;
373 }
374 else if (a_MaxBlockY > cChunkDef::Height)
375 {
376 LOGWARNING("%s: MaxBlockY more than chunk height, adjusting to chunk height", __FUNCTION__);
377 a_MaxBlockY = cChunkDef::Height;
378 }
379
380 // Allocate the needed memory:
381 Clear();
382 if (!SetSize(a_MaxBlockX - a_MinBlockX, a_MaxBlockY - a_MinBlockY, a_MaxBlockZ - a_MinBlockZ, a_DataTypes))
383 {
384 return false;
385 }
386 m_Origin.Set(a_MinBlockX, a_MinBlockY, a_MinBlockZ);
387 cChunkReader Reader(*this);
388
389 // Convert block coords to chunks coords:
390 int MinChunkX, MaxChunkX;
391 int MinChunkZ, MaxChunkZ;
392 cChunkDef::AbsoluteToRelative(a_MinBlockX, a_MinBlockY, a_MinBlockZ, MinChunkX, MinChunkZ);
393 cChunkDef::AbsoluteToRelative(a_MaxBlockX, a_MaxBlockY, a_MaxBlockZ, MaxChunkX, MaxChunkZ);
394

Callers 1

DoExplosionAtMethod · 0.45

Calls 2

SetMethod · 0.45
ForEachChunkInRectMethod · 0.45

Tested by

no test coverage detected