summaryrefslogtreecommitdiff
path: root/src/network/clientpackethandler.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2022-06-20 21:56:12 +0200
committerGitHub <noreply@github.com>2022-06-20 21:56:12 +0200
commita463620edbe57071a7101297d33226507567ca73 (patch)
tree342d433ca55f4e3d1826508c303f2e6229d503f1 /src/network/clientpackethandler.cpp
parent0b41533763bc9f104a2da2e4191f4654b8d8dab4 (diff)
downloadminetest-a463620edbe57071a7101297d33226507567ca73.tar.gz
minetest-a463620edbe57071a7101297d33226507567ca73.tar.bz2
minetest-a463620edbe57071a7101297d33226507567ca73.zip
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.
Diffstat (limited to 'src/network/clientpackethandler.cpp')
-rw-r--r--src/network/clientpackethandler.cpp22
1 files changed, 9 insertions, 13 deletions
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: