| 1921 | |
| 1922 | |
| 1923 | void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) |
| 1924 | { |
| 1925 | ASSERT(m_Player != NULL); |
| 1926 | |
| 1927 | // Check chunks being sent, erase them from m_ChunksToSend: |
| 1928 | bool Found = false; |
| 1929 | { |
| 1930 | cCSLock Lock(m_CSChunkLists); |
| 1931 | for (cChunkCoordsList::iterator itr = m_ChunksToSend.begin(); itr != m_ChunksToSend.end(); ++itr) |
| 1932 | { |
| 1933 | if ((itr->m_ChunkX == a_ChunkX) && (itr->m_ChunkZ == a_ChunkZ)) |
| 1934 | { |
| 1935 | m_ChunksToSend.erase(itr); |
| 1936 | Found = true; |
| 1937 | break; |
| 1938 | } |
| 1939 | } // for itr - m_ChunksToSend[] |
| 1940 | } |
| 1941 | if (!Found) |
| 1942 | { |
| 1943 | // This just sometimes happens. If you have a reliably replicatable situation for this, go ahead and fix it |
| 1944 | // It's not a big issue anyway, just means that some chunks may be compressed several times |
| 1945 | // LOGD("Refusing to send chunk [%d, %d] to client \"%s\" at [%d, %d].", ChunkX, ChunkZ, m_Username.c_str(), m_Player->GetChunkX(), m_Player->GetChunkZ()); |
| 1946 | return; |
| 1947 | } |
| 1948 | |
| 1949 | m_Protocol->SendChunkData(a_ChunkX, a_ChunkZ, a_Serializer); |
| 1950 | |
| 1951 | // If it is the chunk the player's in, make them spawn (in the tick thread): |
| 1952 | if ((m_State == csAuthenticated) || (m_State == csDownloadingWorld)) |
| 1953 | { |
| 1954 | if ((a_ChunkX == m_Player->GetChunkX()) && (a_ChunkZ == m_Player->GetChunkZ())) |
| 1955 | { |
| 1956 | m_HasSentPlayerChunk = true; |
| 1957 | } |
| 1958 | } |
| 1959 | } |
| 1960 | |
| 1961 | |
| 1962 | |