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

Method FastSetBlocks

src/ChunkMap.cpp:1065–1111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1063
1064
1065void cChunkMap::FastSetBlocks(sSetBlockList & a_BlockList)
1066{
1067 sSetBlockList Failed;
1068
1069 // Process all items from a_BlockList, either successfully or by placing into Failed
1070 while (!a_BlockList.empty())
1071 {
1072 int ChunkX = a_BlockList.front().ChunkX;
1073 int ChunkZ = a_BlockList.front().ChunkZ;
1074 cCSLock Lock(m_CSLayers);
1075 cChunkPtr Chunk = GetChunkNoGen(ChunkX, ZERO_CHUNK_Y, ChunkZ);
1076 if ((Chunk != NULL) && Chunk->IsValid())
1077 {
1078 for (sSetBlockList::iterator itr = a_BlockList.begin(); itr != a_BlockList.end();)
1079 {
1080 if ((itr->ChunkX == ChunkX) && (itr->ChunkZ == ChunkZ))
1081 {
1082 Chunk->FastSetBlock(itr->x, itr->y, itr->z, itr->BlockType, itr->BlockMeta);
1083 itr = a_BlockList.erase(itr);
1084 }
1085 else
1086 {
1087 ++itr;
1088 }
1089 } // for itr - a_BlockList[]
1090 }
1091 else
1092 {
1093 // The chunk is not valid, move all blocks within this chunk to Failed
1094 for (sSetBlockList::iterator itr = a_BlockList.begin(); itr != a_BlockList.end();)
1095 {
1096 if ((itr->ChunkX == ChunkX) && (itr->ChunkZ == ChunkZ))
1097 {
1098 Failed.push_back(*itr);
1099 itr = a_BlockList.erase(itr);
1100 }
1101 else
1102 {
1103 ++itr;
1104 }
1105 } // for itr - a_BlockList[]
1106 }
1107 }
1108
1109 // Return the failed:
1110 std::swap(Failed, a_BlockList);
1111}
1112
1113
1114

Callers 1

FastSetQueuedBlocksMethod · 0.95

Calls 5

emptyMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
IsValidMethod · 0.45
FastSetBlockMethod · 0.45

Tested by

no test coverage detected