MCPcopy Create free account
hub / github.com/cuberite/cuberite / ServerTick

Method ServerTick

src/ClientHandle.cpp:1713–1750  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1711
1712
1713void 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

Callers 1

TickClientsMethod · 0.80

Calls 6

sizeMethod · 0.80
ClientMovedToWorldMethod · 0.80
GetServerMethod · 0.80
DataReceivedMethod · 0.45
AddPlayerMethod · 0.45
GetWorldMethod · 0.45

Tested by

no test coverage detected