- ClientEvent event;
- event.type = CE_TEXTURES_UPDATED;
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_TOOLDEF)
- {
- infostream<<"Client: WARNING: Ignoring TOCLIENT_TOOLDEF"<<std::endl;
- }
- else if(command == TOCLIENT_NODEDEF)
- {
- infostream<<"Client: Received node definitions: packet size: "
- <<datasize<<std::endl;
-
- // Mesh update thread must be stopped while
- // updating content definitions
- assert(!m_mesh_update_thread.IsRunning());
-
- // Decompress node definitions
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
- std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
- std::ostringstream tmp_os;
- decompressZlib(tmp_is, tmp_os);
-
- // Deserialize node definitions
- std::istringstream tmp_is2(tmp_os.str());
- m_nodedef->deSerialize(tmp_is2);
- m_nodedef_received = true;
- }
- else if(command == TOCLIENT_CRAFTITEMDEF)
- {
- infostream<<"Client: WARNING: Ignoring TOCLIENT_CRAFTITEMDEF"<<std::endl;
- }
- else if(command == TOCLIENT_ITEMDEF)
- {
- infostream<<"Client: Received item definitions: packet size: "
- <<datasize<<std::endl;
-
- // Mesh update thread must be stopped while
- // updating content definitions
- assert(!m_mesh_update_thread.IsRunning());
-
- // Decompress item definitions
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
- std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
- std::ostringstream tmp_os;
- decompressZlib(tmp_is, tmp_os);
-
- // Deserialize node definitions
- std::istringstream tmp_is2(tmp_os.str());
- m_itemdef->deSerialize(tmp_is2);
- m_itemdef_received = true;
- }
- else if(command == TOCLIENT_PLAY_SOUND)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- s32 server_id = readS32(is);
- std::string name = deSerializeString(is);
- float gain = readF1000(is);
- int type = readU8(is); // 0=local, 1=positional, 2=object
- v3f pos = readV3F1000(is);
- u16 object_id = readU16(is);
- bool loop = readU8(is);
- // Start playing
- int client_id = -1;
- switch(type){
- case 0: // local
- client_id = m_sound->playSound(name, loop, gain);
- break;
- case 1: // positional
- client_id = m_sound->playSoundAt(name, loop, gain, pos);
- break;
- case 2: { // object
- ClientActiveObject *cao = m_env.getActiveObject(object_id);
- if(cao)
- pos = cao->getPosition();
- client_id = m_sound->playSoundAt(name, loop, gain, pos);
- // TODO: Set up sound to move with object
- break; }
- default:
+void Client::startAuth(AuthMechanism chosen_auth_mechanism)
+{
+ m_chosen_auth_mech = chosen_auth_mechanism;
+
+ switch (chosen_auth_mechanism) {
+ case AUTH_MECHANISM_FIRST_SRP: {
+ // send srp verifier to server
+ NetworkPacket resp_pkt(TOSERVER_FIRST_SRP, 0);
+ char *salt, *bytes_v;
+ std::size_t len_salt, len_v;
+ salt = NULL;
+ getSRPVerifier(getPlayerName(), m_password,
+ &salt, &len_salt, &bytes_v, &len_v);
+ resp_pkt
+ << std::string((char*)salt, len_salt)
+ << std::string((char*)bytes_v, len_v)
+ << (u8)((m_password == "") ? 1 : 0);
+ free(salt);
+ free(bytes_v);
+ Send(&resp_pkt);