mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
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.
This commit is contained in:
parent
051181fa6e
commit
e51f474613
9 changed files with 112 additions and 108 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue