| 92 | |
| 93 | |
| 94 | void cSandSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) |
| 95 | { |
| 96 | if ((a_Chunk == NULL) || !a_Chunk->IsValid()) |
| 97 | { |
| 98 | return; |
| 99 | } |
| 100 | int RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width; |
| 101 | int RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width; |
| 102 | if (!IsAllowedBlock(a_Chunk->GetBlock(RelX, a_BlockY, RelZ))) |
| 103 | { |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | // Check for duplicates: |
| 108 | cSandSimulatorChunkData & ChunkData = a_Chunk->GetSandSimulatorData(); |
| 109 | for (cSandSimulatorChunkData::iterator itr = ChunkData.begin(); itr != ChunkData.end(); ++itr) |
| 110 | { |
| 111 | if ((itr->x == RelX) && (itr->y == a_BlockY) && (itr->z == RelZ)) |
| 112 | { |
| 113 | return; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | m_TotalBlocks += 1; |
| 118 | ChunkData.push_back(cCoordWithInt(RelX, a_BlockY, RelZ)); |
| 119 | } |
| 120 | |
| 121 | |
| 122 | |