| 776 | |
| 777 | |
| 778 | void cChunk::TickBlocks(void) |
| 779 | { |
| 780 | // Tick dem blocks |
| 781 | // _X: We must limit the random number or else we get a nasty int overflow bug ( http://forum.mc-server.org/showthread.php?tid=457 ) |
| 782 | int RandomX = m_World->GetTickRandomNumber(0x00ffffff); |
| 783 | int RandomY = m_World->GetTickRandomNumber(0x00ffffff); |
| 784 | int RandomZ = m_World->GetTickRandomNumber(0x00ffffff); |
| 785 | int TickX = m_BlockTickX; |
| 786 | int TickY = m_BlockTickY; |
| 787 | int TickZ = m_BlockTickZ; |
| 788 | |
| 789 | cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); |
| 790 | cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); |
| 791 | |
| 792 | // This for loop looks disgusting, but it actually does a simple thing - first processes m_BlockTick, then adds random to it |
| 793 | // This is so that SetNextBlockTick() works |
| 794 | for (int i = 0; i < 50; i++, |
| 795 | |
| 796 | // This weird construct (*2, then /2) is needed, |
| 797 | // otherwise the blocktick distribution is too biased towards even coords! |
| 798 | |
| 799 | TickX = (TickX + RandomX) % (Width * 2), |
| 800 | TickY = (TickY + RandomY) % (Height * 2), |
| 801 | TickZ = (TickZ + RandomZ) % (Width * 2), |
| 802 | m_BlockTickX = TickX / 2, |
| 803 | m_BlockTickY = TickY / 2, |
| 804 | m_BlockTickZ = TickZ / 2 |
| 805 | ) |
| 806 | { |
| 807 | |
| 808 | if (m_BlockTickY > cChunkDef::GetHeight(m_HeightMap, m_BlockTickX, m_BlockTickZ)) |
| 809 | { |
| 810 | continue; // It's all air up here |
| 811 | } |
| 812 | |
| 813 | unsigned int Index = MakeIndexNoCheck(m_BlockTickX, m_BlockTickY, m_BlockTickZ); |
| 814 | cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); |
| 815 | ASSERT(Handler != NULL); // Happenned on server restart, FS #243 |
| 816 | Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); |
| 817 | } // for i - tickblocks |
| 818 | } |
| 819 | |
| 820 | |
| 821 |
nothing calls this directly
no test coverage detected