Skip to content

Commit

Permalink
Fixed|Server: Sounds emitted by sectors
Browse files Browse the repository at this point in the history
When a sound was emitted by a sector (not a plane), the client was not
up to speed about which sound origin to use.
  • Loading branch information
skyjake committed Mar 16, 2013
1 parent 544f6ee commit 3c71fa5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
16 changes: 13 additions & 3 deletions doomsday/client/src/client/cl_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ void Cl_ReadSoundDelta2(deltatype_t type, boolean skip)
// We can't play sounds from hidden mobjs, because we
// aren't sure exactly where they are located.
cmo = NULL;
LOG_DEBUG("Can't find sound emitter ") << mobjId;
}
else
{
Expand Down Expand Up @@ -124,6 +125,8 @@ void Cl_ReadSoundDelta2(deltatype_t type, boolean skip)
{
uint index = deltaId;

LOG_DEBUG("DT_POLY_SOUND: poly=%i") << index;

if(index < NUM_POLYOBJS)
{
DENG_ASSERT(theMap);
Expand All @@ -148,9 +151,18 @@ void Cl_ReadSoundDelta2(deltatype_t type, boolean skip)
{
// Select the origin for the sound.
if(flags & SNDDF_PLANE_FLOOR)
{
emitter = (mobj_t*) &sector->SP_floorsurface.base;
}
else if(flags & SNDDF_PLANE_CEILING)
{
emitter = (mobj_t*) &sector->SP_ceilsurface.base;
}
else
{
// Must be the sector's sound origin, then.
emitter = (mobj_t*) &sector->base;
}
}

if(type == DT_SIDE_SOUND)
Expand Down Expand Up @@ -214,9 +226,7 @@ void Cl_ReadSoundDelta2(deltatype_t type, boolean skip)
if(type != DT_SOUND && !emitter)
{
// Not enough information.
#ifdef _DEBUG
Con_Printf("Cl_ReadSoundDelta2(%i): Insufficient data, snd=%i\n", type, sound);
#endif
LOG_WARNING("Cl_ReadSoundDelta2(%i): Insufficient data, snd=%i") << type << sound;
return;
}

Expand Down
12 changes: 7 additions & 5 deletions doomsday/server/src/server/sv_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2328,6 +2328,11 @@ void Sv_NewSoundDelta(int soundId, mobj_t* emitter, Sector* sourceSector,
id = GameMap_SectorIndex(theMap, sourceSector);
// Client assumes the sector's sound origin.
}
else if(sourcePoly)
{
type = DT_POLY_SOUND;
id = sourcePoly->idx;
}
else if(sourceSurface)
{
switch(sourceSurface->owner->type())
Expand Down Expand Up @@ -2390,11 +2395,6 @@ void Sv_NewSoundDelta(int soundId, mobj_t* emitter, Sector* sourceSector,
return;
}
}
else if(sourcePoly)
{
type = DT_POLY_SOUND;
id = sourcePoly->idx;
}
else if(emitter)
{
type = DT_MOBJ_SOUND;
Expand All @@ -2412,6 +2412,8 @@ void Sv_NewSoundDelta(int soundId, mobj_t* emitter, Sector* sourceSector,
if(isRepeating)
df |= SNDDF_REPEAT;

LOG_DEBUG("New sound delta: type=%i id=%i flags=%x") << type << id << df;

// This is used by mobj/sector sounds.
soundDelta.sound = soundId;

Expand Down
4 changes: 2 additions & 2 deletions doomsday/server/src/server/sv_sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static inline boolean isRealMobj(const mobj_t* base)
* Find the map object to whom @a base belongs.
*/
static void Sv_IdentifySoundBase(mobj_t** base, Sector** sector, Polyobj** poly,
Surface** surface)
Surface** surface)
{
*sector = 0;
*poly = 0;
Expand Down Expand Up @@ -109,7 +109,7 @@ void Sv_SoundAtVolume(int soundIDAndFlags, mobj_t* origin, float volume, int toP
<< soundID << volume << targetPlayers;

Sv_NewSoundDelta(soundID, origin, sector, poly, surface, volume,
!!(soundIDAndFlags & DDSF_REPEAT), targetPlayers);
(soundIDAndFlags & DDSF_REPEAT) != 0, targetPlayers);
}

void Sv_StopSound(int soundId, mobj_t* origin)
Expand Down

0 comments on commit 3c71fa5

Please sign in to comment.