| 1711 | |
| 1712 | |
| 1713 | void cClientHandle::ServerTick(float a_Dt) |
| 1714 | { |
| 1715 | // Handle clients that are waiting for final close while destroyed: |
| 1716 | if (m_State == csDestroyedWaiting) |
| 1717 | { |
| 1718 | // Do not wait while the client is not in the world, simply cut them off. |
| 1719 | m_State = csDestroyed; |
| 1720 | return; |
| 1721 | } |
| 1722 | |
| 1723 | // Process received network data: |
| 1724 | AString IncomingData; |
| 1725 | { |
| 1726 | cCSLock Lock(m_CSIncomingData); |
| 1727 | std::swap(IncomingData, m_IncomingData); |
| 1728 | } |
| 1729 | m_Protocol->DataReceived(IncomingData.data(), IncomingData.size()); |
| 1730 | |
| 1731 | if (m_State == csAuthenticated) |
| 1732 | { |
| 1733 | StreamChunks(); |
| 1734 | |
| 1735 | // Remove the client handle from the server, it will be ticked from its cPlayer object from now on |
| 1736 | cRoot::Get()->GetServer()->ClientMovedToWorld(this); |
| 1737 | |
| 1738 | // Add the player to the world (start ticking from there): |
| 1739 | m_State = csDownloadingWorld; |
| 1740 | m_Player->GetWorld()->AddPlayer(m_Player); |
| 1741 | return; |
| 1742 | } |
| 1743 | |
| 1744 | m_TimeSinceLastPacket += a_Dt; |
| 1745 | if (m_TimeSinceLastPacket > 30000.f) // 30 seconds time-out |
| 1746 | { |
| 1747 | SendDisconnect("Nooooo!! You timed out! D: Come back!"); |
| 1748 | Destroy(); |
| 1749 | } |
| 1750 | } |
| 1751 | |
| 1752 | |
| 1753 |
no test coverage detected