| 189 | |
| 190 | |
| 191 | void cClientHandle::Authenticate(void) |
| 192 | { |
| 193 | if (m_State != csAuthenticating) |
| 194 | { |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | ASSERT( m_Player == NULL ); |
| 199 | |
| 200 | // Spawn player (only serversided, so data is loaded) |
| 201 | m_Player = new cPlayer(this, GetUsername()); |
| 202 | |
| 203 | cWorld * World = cRoot::Get()->GetWorld(m_Player->GetLoadedWorldName()); |
| 204 | if (World == NULL) |
| 205 | { |
| 206 | World = cRoot::Get()->GetDefaultWorld(); |
| 207 | } |
| 208 | |
| 209 | if (m_Player->GetGameMode() == eGameMode_NotSet) |
| 210 | { |
| 211 | m_Player->LoginSetGameMode(World->GetGameMode()); |
| 212 | } |
| 213 | |
| 214 | m_Player->SetIP (m_IPString); |
| 215 | |
| 216 | if (!cRoot::Get()->GetPluginManager()->CallHookPlayerJoined(*m_Player)) |
| 217 | { |
| 218 | cRoot::Get()->BroadcastChatJoin(Printf("%s has joined the game", GetUsername().c_str())); |
| 219 | LOGINFO("Player %s has joined the game.", m_Username.c_str()); |
| 220 | } |
| 221 | |
| 222 | m_ConfirmPosition = m_Player->GetPosition(); |
| 223 | |
| 224 | // Return a server login packet |
| 225 | m_Protocol->SendLogin(*m_Player, *World); |
| 226 | |
| 227 | // Send Weather if raining: |
| 228 | if ((World->GetWeather() == 1) || (World->GetWeather() == 2)) |
| 229 | { |
| 230 | m_Protocol->SendWeather(World->GetWeather()); |
| 231 | } |
| 232 | |
| 233 | // Send time |
| 234 | m_Protocol->SendTimeUpdate(World->GetWorldAge(), World->GetTimeOfDay()); |
| 235 | |
| 236 | // Send contents of the inventory window |
| 237 | m_Protocol->SendWholeInventory(*m_Player->GetWindow()); |
| 238 | |
| 239 | // Send health |
| 240 | m_Player->SendHealth(); |
| 241 | |
| 242 | // Send experience |
| 243 | m_Player->SendExperience(); |
| 244 | |
| 245 | m_Player->Initialize(World); |
| 246 | m_State = csAuthenticated; |
| 247 | |
| 248 | // Query player team |
no test coverage detected