- s32 server_id = readS32(is);
- std::map<s32, int>::iterator i =
- m_sounds_server_to_client.find(server_id);
- if(i != m_sounds_server_to_client.end()){
- int client_id = i->second;
- m_sound->stopSound(client_id);
- }
- }
- else if(command == TOCLIENT_PRIVILEGES)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- m_privileges.clear();
- infostream<<"Client: Privileges updated: ";
- u16 num_privileges = readU16(is);
- for(unsigned int i=0; i<num_privileges; i++){
- std::string priv = deSerializeString(is);
- m_privileges.insert(priv);
- infostream<<priv<<" ";
- }
- infostream<<std::endl;
- }
- else if(command == TOCLIENT_INVENTORY_FORMSPEC)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- // Store formspec in LocalPlayer
- player->inventory_formspec = deSerializeLongString(is);
- }
- else if(command == TOCLIENT_DETACHED_INVENTORY)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- std::string name = deSerializeString(is);
-
- infostream<<"Client: Detached inventory update: \""<<name<<"\""<<std::endl;
-
- Inventory *inv = NULL;
- if(m_detached_inventories.count(name) > 0)
- inv = m_detached_inventories[name];
- else{
- inv = new Inventory(m_itemdef);
- m_detached_inventories[name] = inv;
- }
- inv->deSerialize(is);
- }
- else if(command == TOCLIENT_SHOW_FORMSPEC)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- std::string formspec = deSerializeLongString(is);
- std::string formname = deSerializeString(is);
-
- ClientEvent event;
- event.type = CE_SHOW_FORMSPEC;
- // pointer is required as event is a struct only!
- // adding a std:string to a struct isn't possible
- event.show_formspec.formspec = new std::string(formspec);
- event.show_formspec.formname = new std::string(formname);
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_SPAWN_PARTICLE)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- v3f pos = readV3F1000(is);
- v3f vel = readV3F1000(is);
- v3f acc = readV3F1000(is);
- float expirationtime = readF1000(is);
- float size = readF1000(is);
- bool collisiondetection = readU8(is);
- std::string texture = deSerializeLongString(is);
- bool vertical = false;
- try {
- vertical = readU8(is);
- } catch (...) {}
-
- ClientEvent event;
- event.type = CE_SPAWN_PARTICLE;
- event.spawn_particle.pos = new v3f (pos);
- event.spawn_particle.vel = new v3f (vel);
- event.spawn_particle.acc = new v3f (acc);
- event.spawn_particle.expirationtime = expirationtime;
- event.spawn_particle.size = size;
- event.spawn_particle.collisiondetection = collisiondetection;
- event.spawn_particle.vertical = vertical;
- event.spawn_particle.texture = new std::string(texture);
-
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_ADD_PARTICLESPAWNER)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- u16 amount = readU16(is);
- float spawntime = readF1000(is);
- v3f minpos = readV3F1000(is);
- v3f maxpos = readV3F1000(is);
- v3f minvel = readV3F1000(is);
- v3f maxvel = readV3F1000(is);
- v3f minacc = readV3F1000(is);
- v3f maxacc = readV3F1000(is);
- float minexptime = readF1000(is);
- float maxexptime = readF1000(is);
- float minsize = readF1000(is);
- float maxsize = readF1000(is);
- bool collisiondetection = readU8(is);
- std::string texture = deSerializeLongString(is);
- u32 id = readU32(is);
- bool vertical = false;
- try {
- vertical = readU8(is);
- } catch (...) {}
-
- ClientEvent event;
- event.type = CE_ADD_PARTICLESPAWNER;
- event.add_particlespawner.amount = amount;
- event.add_particlespawner.spawntime = spawntime;
- event.add_particlespawner.minpos = new v3f (minpos);
- event.add_particlespawner.maxpos = new v3f (maxpos);
- event.add_particlespawner.minvel = new v3f (minvel);
- event.add_particlespawner.maxvel = new v3f (maxvel);
- event.add_particlespawner.minacc = new v3f (minacc);
- event.add_particlespawner.maxacc = new v3f (maxacc);
- event.add_particlespawner.minexptime = minexptime;
- event.add_particlespawner.maxexptime = maxexptime;
- event.add_particlespawner.minsize = minsize;
- event.add_particlespawner.maxsize = maxsize;
- event.add_particlespawner.collisiondetection = collisiondetection;
- event.add_particlespawner.vertical = vertical;
- event.add_particlespawner.texture = new std::string(texture);
- event.add_particlespawner.id = id;
-
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_DELETE_PARTICLESPAWNER)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- u32 id = readU16(is);
-
- ClientEvent event;
- event.type = CE_DELETE_PARTICLESPAWNER;
- event.delete_particlespawner.id = id;
-
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_HUDADD)
- {
- std::string datastring((char *)&data[2], datasize - 2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- u32 id = readU32(is);
- u8 type = readU8(is);
- v2f pos = readV2F1000(is);
- std::string name = deSerializeString(is);
- v2f scale = readV2F1000(is);
- std::string text = deSerializeString(is);
- u32 number = readU32(is);
- u32 item = readU32(is);
- u32 dir = readU32(is);
- v2f align = readV2F1000(is);
- v2f offset = readV2F1000(is);
- v3f world_pos;
- try{
- world_pos = readV3F1000(is);
- }catch(SerializationError &e) {};
-
- ClientEvent event;
- event.type = CE_HUDADD;
- event.hudadd.id = id;
- event.hudadd.type = type;
- event.hudadd.pos = new v2f(pos);
- event.hudadd.name = new std::string(name);
- event.hudadd.scale = new v2f(scale);
- event.hudadd.text = new std::string(text);
- event.hudadd.number = number;
- event.hudadd.item = item;
- event.hudadd.dir = dir;
- event.hudadd.align = new v2f(align);
- event.hudadd.offset = new v2f(offset);
- event.hudadd.world_pos = new v3f(world_pos);
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_HUDRM)
- {
- std::string datastring((char *)&data[2], datasize - 2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- u32 id = readU32(is);
-
- ClientEvent event;
- event.type = CE_HUDRM;
- event.hudrm.id = id;
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_HUDCHANGE)
- {
- std::string sdata;
- v2f v2fdata;
- v3f v3fdata;
- u32 intdata = 0;
-
- std::string datastring((char *)&data[2], datasize - 2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- u32 id = readU32(is);
- u8 stat = (HudElementStat)readU8(is);
-
- if (stat == HUD_STAT_POS || stat == HUD_STAT_SCALE ||
- stat == HUD_STAT_ALIGN || stat == HUD_STAT_OFFSET)
- v2fdata = readV2F1000(is);
- else if (stat == HUD_STAT_NAME || stat == HUD_STAT_TEXT)
- sdata = deSerializeString(is);
- else if (stat == HUD_STAT_WORLD_POS)
- v3fdata = readV3F1000(is);
- else
- intdata = readU32(is);
-
- ClientEvent event;
- event.type = CE_HUDCHANGE;
- event.hudchange.id = id;
- event.hudchange.stat = (HudElementStat)stat;
- event.hudchange.v2fdata = new v2f(v2fdata);
- event.hudchange.v3fdata = new v3f(v3fdata);
- event.hudchange.sdata = new std::string(sdata);
- event.hudchange.data = intdata;
- m_client_event_queue.push_back(event);
- }
- else if(command == TOCLIENT_HUD_SET_FLAGS)
- {
- std::string datastring((char *)&data[2], datasize - 2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- u32 flags = readU32(is);
- u32 mask = readU32(is);
-
- player->hud_flags &= ~mask;
- player->hud_flags |= flags;
- }
- else if(command == TOCLIENT_HUD_SET_PARAM)
- {
- std::string datastring((char *)&data[2], datasize - 2);
- std::istringstream is(datastring, std::ios_base::binary);
-
- u16 param = readU16(is);
- std::string value = deSerializeString(is);