1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Re-order sound-related code (#12382)

Dropped ServerSoundParams -> moved to ServerPlayingSound. This gets rid of the duplicated
'fade' and 'pitch' values on server-side where only one was used anyway.
SimpleSoundSpec is the basic sound without positional information, hence 'loop' is included.

Recursively added PROTOCOL_VERSION to most functions to reduce the versioning mess in the
future. Per-type version numbers are kept for now as a safety rope in a special case.
This commit is contained in:
SmallJoker 2022-06-20 21:56:12 +02:00 committed by GitHub
parent 0b41533763
commit a463620edb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 140 additions and 188 deletions

View file

@ -778,7 +778,7 @@ void Client::handleCommand_NodeDef(NetworkPacket* pkt)
decompressZlib(tmp_is, tmp_os);
// Deserialize node definitions
m_nodedef->deSerialize(tmp_os);
m_nodedef->deSerialize(tmp_os, m_proto_ver);
m_nodedef_received = true;
}
@ -797,7 +797,7 @@ void Client::handleCommand_ItemDef(NetworkPacket* pkt)
decompressZlib(tmp_is, tmp_os);
// Deserialize node definitions
m_itemdef->deSerialize(tmp_os);
m_itemdef->deSerialize(tmp_os, m_proto_ver);
m_itemdef_received = true;
}
@ -818,22 +818,18 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
*/
s32 server_id;
std::string name;
float gain;
SimpleSoundSpec spec;
u8 type; // 0=local, 1=positional, 2=object
v3f pos;
u16 object_id;
bool loop;
float fade = 0.0f;
float pitch = 1.0f;
bool ephemeral = false;
*pkt >> server_id >> name >> gain >> type >> pos >> object_id >> loop;
*pkt >> server_id >> spec.name >> spec.gain >> type >> pos >> object_id >> spec.loop;
try {
*pkt >> fade;
*pkt >> pitch;
*pkt >> spec.fade;
*pkt >> spec.pitch;
*pkt >> ephemeral;
} catch (PacketError &e) {};
@ -841,17 +837,17 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
int client_id = -1;
switch(type) {
case 0: // local
client_id = m_sound->playSound(name, loop, gain, fade, pitch);
client_id = m_sound->playSound(spec);
break;
case 1: // positional
client_id = m_sound->playSoundAt(name, loop, gain, pos, pitch);
client_id = m_sound->playSoundAt(spec, pos);
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, pitch);
client_id = m_sound->playSoundAt(spec, pos);
break;
}
default: