diff options
author | Brandon <brandon@bremaweb.com> | 2016-07-10 00:08:26 -0500 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2017-05-03 03:12:45 +0100 |
commit | bd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2 (patch) | |
tree | 55f92cc02fce2acc9bb041a34de3c474b894bd00 /src/network/clientpackethandler.cpp | |
parent | f1d7a26b7c341b468f34325cec5c3d495f175a8f (diff) | |
download | minetest-bd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2.tar.gz minetest-bd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2.tar.bz2 minetest-bd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2.zip |
Sound API: Add fading sounds
Diffstat (limited to 'src/network/clientpackethandler.cpp')
-rw-r--r-- | src/network/clientpackethandler.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index defc83f31..a895acc84 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -755,21 +755,39 @@ void Client::handleCommand_ItemDef(NetworkPacket* pkt) void Client::handleCommand_PlaySound(NetworkPacket* pkt) { + /* + [0] u32 server_id + [4] u16 name length + [6] char name[len] + [ 6 + len] f32 gain + [10 + len] u8 type + [11 + len] (f32 * 3) pos + [23 + len] u16 object_id + [25 + len] bool loop + [26 + len] f32 fade + */ + s32 server_id; std::string name; + float gain; u8 type; // 0=local, 1=positional, 2=object v3f pos; u16 object_id; bool loop; + float fade = 0; *pkt >> server_id >> name >> gain >> type >> pos >> object_id >> loop; + try { + *pkt >> fade; + } catch (SerializationError &e) {}; + // Start playing int client_id = -1; switch(type) { case 0: // local - client_id = m_sound->playSound(name, loop, gain); + client_id = m_sound->playSound(name, loop, gain, fade); break; case 1: // positional client_id = m_sound->playSoundAt(name, loop, gain, pos); @@ -808,6 +826,21 @@ void Client::handleCommand_StopSound(NetworkPacket* pkt) } } +void Client::handleCommand_FadeSound(NetworkPacket *pkt) +{ + s32 sound_id; + float step; + float gain; + + *pkt >> sound_id >> step >> gain; + + UNORDERED_MAP<s32, int>::iterator i = + m_sounds_server_to_client.find(sound_id); + + if (i != m_sounds_server_to_client.end()) + m_sound->fadeSound(i->second, step, gain); +} + void Client::handleCommand_Privileges(NetworkPacket* pkt) { m_privileges.clear(); |