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

Method AddChunkStay

src/ChunkMap.cpp:2959–2987  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2957
2958
2959void cChunkMap::AddChunkStay(cChunkStay & a_ChunkStay)
2960{
2961 cCSLock Lock(m_CSLayers);
2962
2963 // Add it to the list:
2964 ASSERT(std::find(m_ChunkStays.begin(), m_ChunkStays.end(), &a_ChunkStay) == m_ChunkStays.end()); // Has not yet been added
2965 m_ChunkStays.push_back(&a_ChunkStay);
2966
2967 // Schedule all chunks to be loaded / generated, and mark each as locked:
2968 const cChunkCoordsVector & WantedChunks = a_ChunkStay.GetChunks();
2969 for (cChunkCoordsVector::const_iterator itr = WantedChunks.begin(); itr != WantedChunks.end(); ++itr)
2970 {
2971 cChunkPtr Chunk = GetChunk(itr->m_ChunkX, itr->m_ChunkY, itr->m_ChunkZ);
2972 if (Chunk == NULL)
2973 {
2974 continue;
2975 }
2976 Chunk->Stay(true);
2977 if (Chunk->IsValid())
2978 {
2979 if (a_ChunkStay.ChunkAvailable(itr->m_ChunkX, itr->m_ChunkZ))
2980 {
2981 // The chunkstay wants to be deactivated, disable it and bail out:
2982 a_ChunkStay.Disable();
2983 return;
2984 }
2985 }
2986 } // for itr - WantedChunks[]
2987}
2988
2989
2990

Callers 1

EnableMethod · 0.80

Calls 6

beginMethod · 0.80
endMethod · 0.80
StayMethod · 0.80
ChunkAvailableMethod · 0.80
IsValidMethod · 0.45
DisableMethod · 0.45

Tested by

no test coverage detected