X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fnetwork%2Fclientpackethandler.cpp;h=e6f0d7092fbfacf5d4df6f9a626082c99843f794;hb=c772e0e18c90e48f237e37a45230a1dacd945786;hp=59669fe6d0b933c2eabe8d333a117bca7c8cf2da;hpb=e25a38e3fbb156ae2bc72cc66aef014ae3963407;p=oweals%2Fminetest.git diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 59669fe6d..e6f0d7092 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -683,8 +683,7 @@ void Client::handleCommand_Media(NetworkPacket* pkt) if (num_files == 0) return; - if (m_media_downloader == NULL || - !m_media_downloader->isStarted()) { + if (!m_media_downloader || !m_media_downloader->isStarted()) { const char *problem = m_media_downloader ? "media has not been requested" : "all media has been received already"; @@ -764,6 +763,7 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt) [23 + len] u16 object_id [25 + len] bool loop [26 + len] f32 fade + [30 + len] f32 pitch */ s32 server_id; @@ -774,29 +774,31 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt) v3f pos; u16 object_id; bool loop; - float fade = 0; + float fade = 0.0f; + float pitch = 1.0f; *pkt >> server_id >> name >> gain >> type >> pos >> object_id >> loop; try { *pkt >> fade; + *pkt >> pitch; } catch (PacketError &e) {}; // Start playing int client_id = -1; switch(type) { case 0: // local - client_id = m_sound->playSound(name, loop, gain, fade); + client_id = m_sound->playSound(name, loop, gain, fade, pitch); break; case 1: // positional - client_id = m_sound->playSoundAt(name, loop, gain, pos); + client_id = m_sound->playSoundAt(name, loop, gain, pos, pitch); 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); + client_id = m_sound->playSoundAt(name, loop, gain, pos, pitch); // TODO: Set up sound to move with object break; } @@ -818,7 +820,7 @@ void Client::handleCommand_StopSound(NetworkPacket* pkt) *pkt >> server_id; - UNORDERED_MAP::iterator i = m_sounds_server_to_client.find(server_id); + std::unordered_map::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); @@ -833,7 +835,7 @@ void Client::handleCommand_FadeSound(NetworkPacket *pkt) *pkt >> sound_id >> step >> gain; - UNORDERED_MAP::iterator i = + std::unordered_map::const_iterator i = m_sounds_server_to_client.find(sound_id); if (i != m_sounds_server_to_client.end()) @@ -1172,9 +1174,21 @@ void Client::handleCommand_HudSetParam(NetworkPacket* pkt) player->hud_hotbar_itemcount = hotbar_itemcount; } else if (param == HUD_PARAM_HOTBAR_IMAGE) { + // If value not empty verify image exists in texture source + if (value != "" && !getTextureSource()->isKnownSourceImage(value)) { + errorstream << "Server sent wrong Hud hotbar image (sent value: '" + << value << "')" << std::endl; + return; + } player->hotbar_image = value; } else if (param == HUD_PARAM_HOTBAR_SELECTED_IMAGE) { + // If value not empty verify image exists in texture source + if (value != "" && !getTextureSource()->isKnownSourceImage(value)) { + errorstream << "Server sent wrong Hud hotbar selected image (sent value: '" + << value << "')" << std::endl; + return; + } player->hotbar_selected_image = value; } } @@ -1270,6 +1284,28 @@ void Client::handleCommand_EyeOffset(NetworkPacket* pkt) *pkt >> player->eye_offset_first >> player->eye_offset_third; } +void Client::handleCommand_UpdatePlayerList(NetworkPacket* pkt) +{ + u8 type; + u16 num_players; + *pkt >> type >> num_players; + PlayerListModifer notice_type = (PlayerListModifer) type; + + for (u16 i = 0; i < num_players; i++) { + std::string name; + *pkt >> name; + switch (notice_type) { + case PLAYER_LIST_INIT: + case PLAYER_LIST_ADD: + m_env.addPlayerName(name); + continue; + case PLAYER_LIST_REMOVE: + m_env.removePlayerName(name); + continue; + } + } +} + void Client::handleCommand_SrpBytesSandB(NetworkPacket* pkt) { if ((m_chosen_auth_mech != AUTH_MECHANISM_LEGACY_PASSWORD)