- if (m_media_downloader->isDone()) {
- delete m_media_downloader;
- m_media_downloader = NULL;
- }
- }
- 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:
- break;
- }
- if(client_id != -1){
- m_sounds_server_to_client[server_id] = client_id;
- m_sounds_client_to_server[client_id] = server_id;
- if(object_id != 0)
- m_sounds_to_objects[client_id] = object_id;
- }
- }
- else if(command == TOCLIENT_STOP_SOUND)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);