summaryrefslogtreecommitdiff
path: root/src/network/clientpackethandler.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-01-25 21:19:29 +0100
committersfan5 <sfan5@live.de>2020-02-01 20:31:41 +0100
commitace3c76112a839aaad34f4343cd924412310bbd3 (patch)
tree6efeeb3537314a3cf8594f1a8f80eb28523ccad9 /src/network/clientpackethandler.cpp
parentea5e231959365622607c8bfd953f6d96ec54a394 (diff)
downloadminetest-ace3c76112a839aaad34f4343cd924412310bbd3.tar.gz
minetest-ace3c76112a839aaad34f4343cd924412310bbd3.tar.bz2
minetest-ace3c76112a839aaad34f4343cd924412310bbd3.zip
Improve core.sound_play with ephemeral sounds and player exclusion
Diffstat (limited to 'src/network/clientpackethandler.cpp')
-rw-r--r--src/network/clientpackethandler.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 79f2b95ba..ceb4b3b17 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -778,6 +778,7 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
[25 + len] bool loop
[26 + len] f32 fade
[30 + len] f32 pitch
+ [34 + len] bool ephemeral
*/
s32 server_id;
@@ -790,12 +791,14 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
bool loop;
float fade = 0.0f;
float pitch = 1.0f;
+ bool ephemeral = false;
*pkt >> server_id >> name >> gain >> type >> pos >> object_id >> loop;
try {
*pkt >> fade;
*pkt >> pitch;
+ *pkt >> ephemeral;
} catch (PacketError &e) {};
// Start playing
@@ -813,7 +816,6 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
if (cao)
pos = cao->getPosition();
client_id = m_sound->playSoundAt(name, loop, gain, pos, pitch);
- // TODO: Set up sound to move with object
break;
}
default:
@@ -821,8 +823,11 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
}
if (client_id != -1) {
- m_sounds_server_to_client[server_id] = client_id;
- m_sounds_client_to_server[client_id] = server_id;
+ // for ephemeral sounds, server_id is not meaningful
+ if (!ephemeral) {
+ 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;
}