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

Method ReadBlockArea

src/Generating/ChunkDesc.cpp:256–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254
255
256void cChunkDesc::ReadBlockArea(cBlockArea & a_Dest, int a_MinRelX, int a_MaxRelX, int a_MinRelY, int a_MaxRelY, int a_MinRelZ, int a_MaxRelZ)
257{
258 // Normalize the coords:
259 if (a_MinRelX > a_MaxRelX)
260 {
261 std::swap(a_MinRelX, a_MaxRelX);
262 }
263 if (a_MinRelY > a_MaxRelY)
264 {
265 std::swap(a_MinRelY, a_MaxRelY);
266 }
267 if (a_MinRelZ > a_MaxRelZ)
268 {
269 std::swap(a_MinRelZ, a_MaxRelZ);
270 }
271
272 // Include the Max coords:
273 a_MaxRelX += 1;
274 a_MaxRelY += 1;
275 a_MaxRelZ += 1;
276
277 // Check coords validity:
278 if (a_MinRelX < 0)
279 {
280 LOGWARNING("%s: MinRelX less than zero, adjusting to zero", __FUNCTION__);
281 a_MinRelX = 0;
282 }
283 else if (a_MinRelX >= cChunkDef::Width)
284 {
285 LOGWARNING("%s: MinRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
286 a_MinRelX = cChunkDef::Width - 1;
287 }
288 if (a_MaxRelX < 0)
289 {
290 LOGWARNING("%s: MaxRelX less than zero, adjusting to zero", __FUNCTION__);
291 a_MaxRelX = 0;
292 }
293 else if (a_MinRelX >= cChunkDef::Width)
294 {
295 LOGWARNING("%s: MaxRelX more than chunk width, adjusting to chunk width", __FUNCTION__);
296 a_MaxRelX = cChunkDef::Width - 1;
297 }
298
299 if (a_MinRelY < 0)
300 {
301 LOGWARNING("%s: MinRelY less than zero, adjusting to zero", __FUNCTION__);
302 a_MinRelY = 0;
303 }
304 else if (a_MinRelY >= cChunkDef::Height)
305 {
306 LOGWARNING("%s: MinRelY more than chunk height, adjusting to chunk height", __FUNCTION__);
307 a_MinRelY = cChunkDef::Height - 1;
308 }
309 if (a_MaxRelY < 0)
310 {
311 LOGWARNING("%s: MaxRelY less than zero, adjusting to zero", __FUNCTION__);
312 a_MaxRelY = 0;
313 }

Callers

nothing calls this directly

Calls 3

SetRelBlockTypeMetaMethod · 0.80
ClearMethod · 0.45
SetSizeMethod · 0.45

Tested by

no test coverage detected