void ServerImpl::onClientInfo( CL_NetGameConnection *p_conn, const CL_NetGameEvent &p_event ) { ClientInfo clientInfo; clientInfo.parseEvent(p_event); // check the version if (clientInfo.getProtocolVersion().getMajor() != PROTOCOL_VERSION_MAJOR) { cl_log_event( LOG_EVENT, "unsupported protocol version for player '%2'", reinterpret_cast<unsigned>(p_conn) ); // send goodbye Net::Goodbye goodbye; goodbye.setGoodbyeReason(GR_UNSUPPORTED_PROTOCOL_VERSION); send(p_conn, goodbye.buildEvent()); return; } // check name availability // check name availability bool nameAvailable = true; TConnectionPlayerPair pair; foreach (pair, m_connections) { if (pair.second.m_name == clientInfo.getName()) { nameAvailable = false; } } if (!nameAvailable) { cl_log_event( LOG_EVENT, "name '%1' already in use for player '%2'", clientInfo.getName(), reinterpret_cast<unsigned>(p_conn) ); // send goodbye Goodbye goodbye; goodbye.setGoodbyeReason(GR_NAME_ALREADY_IN_USE); send(p_conn, goodbye.buildEvent()); return; } // set the name and inform all m_connections[p_conn].m_name = clientInfo.getName(); cl_log_event( LOG_EVENT, "'%1' is now known as '%2', sending gamestate...", reinterpret_cast<unsigned>(p_conn), clientInfo.getName() ); PlayerJoined playerJoined; playerJoined.setName(clientInfo.getName()); sendToAll(playerJoined.buildEvent(), p_conn); // send the gamestate const GameState gamestate = prepareGameState(); send(p_conn, gamestate.buildEvent()); m_connections[p_conn].m_gameStateSent = true; }