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

Method SetAllData

src/Chunk.cpp:264–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262
263
264void cChunk::SetAllData(
265 const BLOCKTYPE * a_BlockTypes,
266 const NIBBLETYPE * a_BlockMeta,
267 const NIBBLETYPE * a_BlockLight,
268 const NIBBLETYPE * a_BlockSkyLight,
269 const HeightMap * a_HeightMap,
270 const BiomeMap & a_BiomeMap,
271 cBlockEntityList & a_BlockEntities
272)
273{
274 memcpy(m_BiomeMap, a_BiomeMap, sizeof(m_BiomeMap));
275
276 if (a_HeightMap != NULL)
277 {
278 memcpy(m_HeightMap, a_HeightMap, sizeof(m_HeightMap));
279 }
280
281 memcpy(m_BlockTypes, a_BlockTypes, sizeof(m_BlockTypes));
282 memcpy(m_BlockMeta, a_BlockMeta, sizeof(m_BlockMeta));
283 if (a_BlockLight != NULL)
284 {
285 memcpy(m_BlockLight, a_BlockLight, sizeof(m_BlockLight));
286 }
287 if (a_BlockSkyLight != NULL)
288 {
289 memcpy(m_BlockSkyLight, a_BlockSkyLight, sizeof(m_BlockSkyLight));
290 }
291
292 m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL);
293
294 if (a_HeightMap == NULL)
295 {
296 CalculateHeightmap();
297 }
298
299 // Clear the block entities present - either the loader / saver has better, or we'll create empty ones:
300 for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
301 {
302 delete *itr;
303 }
304 std::swap(a_BlockEntities, m_BlockEntities);
305
306 // Set all block entities' World variable:
307 for (cBlockEntityList::iterator itr = m_BlockEntities.begin(); itr != m_BlockEntities.end(); ++itr)
308 {
309 (*itr)->SetWorld(m_World);
310 }
311
312 // Create block entities that the loader didn't load; fill them with defaults
313 CreateBlockEntities();
314
315 // Set the chunk data as valid. This may be needed for some simulators that perform actions upon block adding (Vaporize)
316 SetValid();
317
318 // Wake up all simulators for their respective blocks:
319 WakeUpSimulators();
320
321 m_HasLoadFailed = false;

Callers 1

SetChunkDataMethod · 0.80

Calls 3

beginMethod · 0.80
endMethod · 0.80
SetWorldMethod · 0.45

Tested by

no test coverage detected