1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Improve core.sound_play with ephemeral sounds and player exclusion

This commit is contained in:
sfan5 2020-01-25 21:19:29 +01:00
parent ea5e231959
commit ace3c76112
9 changed files with 78 additions and 29 deletions

View file

@ -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;
}

View file

@ -200,6 +200,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Unknown inventory serialization fields no longer throw an error
Mod-specific formspec version
Player FOV override API
"ephemeral" added to TOCLIENT_PLAY_SOUND
*/
#define LATEST_PROTOCOL_VERSION 38
@ -450,6 +451,7 @@ enum ToClientCommand
s32[3] pos_nodes*10000
u16 object_id
u8 loop (bool)
u8 ephemeral (bool)
*/
TOCLIENT_STOP_SOUND = 0x40,