diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2022-07-09 22:32:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-09 22:32:24 +0200 |
commit | e51f474613c5d4bd53a8d213785bcb51f5cf447f (patch) | |
tree | 1278a6dbf5e9507ed97a4ed66afcbcb71da3639d /src/server.cpp | |
parent | 051181fa6ee00d8379e8a7dc7442b58342d4352b (diff) | |
download | minetest-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/server.cpp')
-rw-r--r-- | src/server.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/server.cpp b/src/server.cpp index 24e352658..4eee14a30 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -138,21 +138,27 @@ void *ServerThread::run() v3f ServerPlayingSound::getPos(ServerEnvironment *env, bool *pos_exists) const { - if(pos_exists) *pos_exists = false; - switch(type){ - case SSP_LOCAL: + if (pos_exists) + *pos_exists = false; + + switch (type ){ + case SoundLocation::Local: return v3f(0,0,0); - case SSP_POSITIONAL: - if(pos_exists) *pos_exists = true; + case SoundLocation::Position: + if (pos_exists) + *pos_exists = true; return pos; - case SSP_OBJECT: { - if(object == 0) - return v3f(0,0,0); - ServerActiveObject *sao = env->getActiveObject(object); - if(!sao) - return v3f(0,0,0); - if(pos_exists) *pos_exists = true; - return sao->getBasePosition(); } + case SoundLocation::Object: + { + if (object == 0) + return v3f(0,0,0); + ServerActiveObject *sao = env->getActiveObject(object); + if (!sao) + return v3f(0,0,0); + if (pos_exists) + *pos_exists = true; + return sao->getBasePosition(); + } } return v3f(0,0,0); } @@ -2071,9 +2077,9 @@ s32 Server::playSound(ServerPlayingSound ¶ms, bool ephemeral) { // Find out initial position of sound bool pos_exists = false; - v3f pos = params.getPos(m_env, &pos_exists); + const v3f pos = params.getPos(m_env, &pos_exists); // If position is not found while it should be, cancel sound - if(pos_exists != (params.type != ServerPlayingSound::SSP_LOCAL)) + if(pos_exists != (params.type != SoundLocation::Local)) return -1; // Filter destination clients |