| 102 | |
| 103 | |
| 104 | cClientHandle::~cClientHandle() |
| 105 | { |
| 106 | ASSERT(m_State >= csDestroyedWaiting); // Has Destroy() been called? |
| 107 | |
| 108 | LOGD("Deleting client \"%s\" at %p", GetUsername().c_str(), this); |
| 109 | |
| 110 | { |
| 111 | cCSLock Lock(m_CSChunkLists); |
| 112 | m_LoadedChunks.clear(); |
| 113 | m_ChunksToSend.clear(); |
| 114 | } |
| 115 | |
| 116 | if (m_Player != NULL) |
| 117 | { |
| 118 | cWorld * World = m_Player->GetWorld(); |
| 119 | if (!m_Username.empty() && (World != NULL)) |
| 120 | { |
| 121 | // Send the Offline PlayerList packet: |
| 122 | World->BroadcastPlayerListItem(*m_Player, false, this); |
| 123 | } |
| 124 | if (World != NULL) |
| 125 | { |
| 126 | World->RemovePlayer(m_Player); |
| 127 | m_Player->Destroy(); |
| 128 | } |
| 129 | delete m_Player; |
| 130 | m_Player = NULL; |
| 131 | } |
| 132 | |
| 133 | if (!m_HasSentDC) |
| 134 | { |
| 135 | SendDisconnect("Server shut down? Kthnxbai"); |
| 136 | } |
| 137 | |
| 138 | // Close the socket as soon as it sends all outgoing data: |
| 139 | cRoot::Get()->GetServer()->RemoveClient(this); |
| 140 | |
| 141 | delete m_Protocol; |
| 142 | m_Protocol = NULL; |
| 143 | |
| 144 | LOGD("ClientHandle at %p deleted", this); |
| 145 | } |
| 146 | |
| 147 | |
| 148 |
nothing calls this directly
no test coverage detected