summaryrefslogtreecommitdiff
path: root/src/network/clientpackethandler.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2022-07-09 22:32:24 +0200
committerGitHub <noreply@github.com>2022-07-09 22:32:24 +0200
commite51f474613c5d4bd53a8d213785bcb51f5cf447f (patch)
tree1278a6dbf5e9507ed97a4ed66afcbcb71da3639d /src/network/clientpackethandler.cpp
parent051181fa6ee00d8379e8a7dc7442b58342d4352b (diff)
downloadminetest-e51f474613c5d4bd53a8d213785bcb51f5cf447f.tar.gz
minetest-e51f474613c5d4bd53a8d213785bcb51f5cf447f.tar.bz2
minetest-e51f474613c5d4bd53a8d213785bcb51f5cf447f.zip
Sounds: Various little improvements (#12486)
Use SimpleSoundSpec where reasonable (OpenAL) Ensure the sound IDs do not underflow or get overwritten -> loop in u16 Proper use of an enum.
Diffstat (limited to 'src/network/clientpackethandler.cpp')
-rw-r--r--src/network/clientpackethandler.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index fba0fe72d..1901c6675 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -820,12 +820,12 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
s32 server_id;
SimpleSoundSpec spec;
- u8 type; // 0=local, 1=positional, 2=object
+ SoundLocation type; // 0=local, 1=positional, 2=object
v3f pos;
u16 object_id;
bool ephemeral = false;
- *pkt >> server_id >> spec.name >> spec.gain >> type >> pos >> object_id >> spec.loop;
+ *pkt >> server_id >> spec.name >> spec.gain >> (u8 &)type >> pos >> object_id >> spec.loop;
try {
*pkt >> spec.fade;
@@ -836,22 +836,20 @@ void Client::handleCommand_PlaySound(NetworkPacket* pkt)
// Start playing
int client_id = -1;
switch(type) {
- case 0: // local
- client_id = m_sound->playSound(spec);
- break;
- case 1: // positional
- client_id = m_sound->playSoundAt(spec, pos);
- break;
- case 2:
- { // object
+ case SoundLocation::Local:
+ client_id = m_sound->playSound(spec);
+ break;
+ case SoundLocation::Position:
+ client_id = m_sound->playSoundAt(spec, pos);
+ break;
+ case SoundLocation::Object:
+ {
ClientActiveObject *cao = m_env.getActiveObject(object_id);
if (cao)
pos = cao->getPosition();
client_id = m_sound->playSoundAt(spec, pos);
break;
}
- default:
- break;
}
if (client_id != -1) {