| 2882 | |
| 2883 | |
| 2884 | void cWorld::TickQueuedBlocks(void) |
| 2885 | { |
| 2886 | if (m_BlockTickQueue.empty()) |
| 2887 | { |
| 2888 | return; |
| 2889 | } |
| 2890 | m_BlockTickQueueCopy.clear(); |
| 2891 | m_BlockTickQueue.swap(m_BlockTickQueueCopy); |
| 2892 | |
| 2893 | for (std::vector<BlockTickQueueItem *>::iterator itr = m_BlockTickQueueCopy.begin(); itr != m_BlockTickQueueCopy.end(); itr++) |
| 2894 | { |
| 2895 | BlockTickQueueItem * Block = (*itr); |
| 2896 | Block->TicksToWait -= 1; |
| 2897 | if (Block->TicksToWait <= 0) |
| 2898 | { |
| 2899 | // TODO: Handle the case when the chunk is already unloaded |
| 2900 | m_ChunkMap->TickBlock(Block->X, Block->Y, Block->Z); |
| 2901 | delete Block; // We don't have to remove it from the vector, this will happen automatically on the next tick |
| 2902 | } |
| 2903 | else |
| 2904 | { |
| 2905 | m_BlockTickQueue.push_back(Block); // Keep the block in the queue |
| 2906 | } |
| 2907 | } // for itr - m_BlockTickQueueCopy[] |
| 2908 | } |
| 2909 | |
| 2910 | |
| 2911 | |