From a463620edbe57071a7101297d33226507567ca73 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 20 Jun 2022 21:56:12 +0200 Subject: 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. --- src/network/clientpackethandler.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/network') diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 5fee908a3..764f6569f 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -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: -- cgit v1.2.3