- /*infostream<<"Client received chat message: "
- <<wide_to_narrow(message)<<std::endl;*/
-
- m_chat_queue.push_back(message);
- }
- else if(command == TOCLIENT_ACTIVE_OBJECT_REMOVE_ADD)
- {
- //if(g_settings->getBool("enable_experimental"))
- {
- /*
- u16 command
- u16 count of removed objects
- for all removed objects {
- u16 id
- }
- u16 count of added objects
- for all added objects {
- u16 id
- u8 type
- u32 initialization data length
- string initialization data
- }
- */
-
- char buf[6];
- // Get all data except the command number
- std::string datastring((char*)&data[2], datasize-2);
- // Throw them in an istringstream
- std::istringstream is(datastring, std::ios_base::binary);
-
- // Read stuff
-
- // Read removed objects
- is.read(buf, 2);
- u16 removed_count = readU16((u8*)buf);
- for(u16 i=0; i<removed_count; i++)
- {
- is.read(buf, 2);
- u16 id = readU16((u8*)buf);
- // Remove it
- {
- //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
- m_env.removeActiveObject(id);
- }
- }
-
- // Read added objects
- is.read(buf, 2);
- u16 added_count = readU16((u8*)buf);
- for(u16 i=0; i<added_count; i++)
- {
- is.read(buf, 2);
- u16 id = readU16((u8*)buf);
- is.read(buf, 1);
- u8 type = readU8((u8*)buf);
- std::string data = deSerializeLongString(is);
- // Add it
- {
- //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
- m_env.addActiveObject(id, type, data);
- }
- }
- }
- }
- else if(command == TOCLIENT_ACTIVE_OBJECT_MESSAGES)
- {
- //if(g_settings->getBool("enable_experimental"))
- {
- /*
- u16 command
- for all objects
- {
- u16 id
- u16 message length
- string message
- }
- */
- char buf[6];
- // Get all data except the command number
- std::string datastring((char*)&data[2], datasize-2);
- // Throw them in an istringstream
- std::istringstream is(datastring, std::ios_base::binary);
-
- while(is.eof() == false)
- {
- // Read stuff
- is.read(buf, 2);
- u16 id = readU16((u8*)buf);
- if(is.eof())
- break;
- is.read(buf, 2);
- u16 message_size = readU16((u8*)buf);
- std::string message;
- message.reserve(message_size);
- for(u16 i=0; i<message_size; i++)
- {
- is.read(buf, 1);
- message.append(buf, 1);
- }
- // Pass on to the environment
- {
- //JMutexAutoLock envlock(m_env_mutex); //bulk comment-out
- m_env.processActiveObjectMessage(id, message);
- }
- }
- }
- }
- else if(command == TOCLIENT_HP)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
- Player *player = m_env.getLocalPlayer();
- assert(player != NULL);
- u8 oldhp = player->hp;
- u8 hp = readU8(is);
- player->hp = hp;
-
- if(hp < oldhp)
- {
- // Add to ClientEvent queue
- ClientEvent event;
- event.type = CE_PLAYER_DAMAGE;
- event.player_damage.amount = oldhp - hp;
- m_client_event_queue.push_back(event);
- }
- }
- else if(command == TOCLIENT_MOVE_PLAYER)
- {
- std::string datastring((char*)&data[2], datasize-2);
- std::istringstream is(datastring, std::ios_base::binary);
- Player *player = m_env.getLocalPlayer();
- assert(player != NULL);
- v3f pos = readV3F1000(is);
- f32 pitch = readF1000(is);
- f32 yaw = readF1000(is);
- player->setPosition(pos);
- /*player->setPitch(pitch);
- player->setYaw(yaw);*/
-
- infostream<<"Client got TOCLIENT_MOVE_PLAYER"
- <<" pos=("<<pos.X<<","<<pos.Y<<","<<pos.Z<<")"
- <<" pitch="<<pitch
- <<" yaw="<<yaw
- <<std::endl;