mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 08:31:14 +00:00
- let the sound code use the current UI level.
This is what should be audible. To prevent other levels from playing sound, all entry points check whether the sound playing entity belongs to the current UI level.
This commit is contained in:
parent
b4a95ccaa9
commit
4d98c10ea3
6 changed files with 44 additions and 35 deletions
|
@ -701,7 +701,7 @@ void P_DrawRailTrail(AActor *source, TArray<SPortalHit> &portalhits, int color1,
|
||||||
{
|
{
|
||||||
if (shortest == NULL || shortest->sounddist > seg.sounddist) shortest = &seg;
|
if (shortest == NULL || shortest->sounddist > seg.sounddist) shortest = &seg;
|
||||||
}
|
}
|
||||||
S_Sound (DVector3(shortest->soundpos, r_viewpoint.Pos.Z), CHAN_WEAPON, sound, 1, ATTN_NORM);
|
S_Sound (source->Level, DVector3(shortest->soundpos, r_viewpoint.Pos.Z), CHAN_WEAPON, sound, 1, ATTN_NORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6058,7 +6058,7 @@ foundone:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
S_Sound(pos, CHAN_ITEM, smallsplash ?
|
S_Sound(thing->Level, pos, CHAN_ITEM, smallsplash ?
|
||||||
splash->SmallSplashSound : splash->NormalSplashSound,
|
splash->SmallSplashSound : splash->NormalSplashSound,
|
||||||
1, ATTN_IDLE);
|
1, ATTN_IDLE);
|
||||||
}
|
}
|
||||||
|
@ -6266,7 +6266,7 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner)
|
||||||
// If there is no spawner use the spawn position.
|
// If there is no spawner use the spawn position.
|
||||||
// But not in a silenced sector.
|
// But not in a silenced sector.
|
||||||
if (!(missile->Sector->Flags & SECF_SILENT))
|
if (!(missile->Sector->Flags & SECF_SILENT))
|
||||||
S_Sound (missile->Pos(), CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM);
|
S_Sound (missile->Level, missile->Pos(), CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, uint8_t special, bool *q
|
||||||
}
|
}
|
||||||
if (playsound)
|
if (playsound)
|
||||||
{
|
{
|
||||||
S_Sound (DVector3(pt, 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC);
|
S_Sound (side->GetLevel(), DVector3(pt, 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC);
|
||||||
}
|
}
|
||||||
if (quest != NULL)
|
if (quest != NULL)
|
||||||
{
|
{
|
||||||
|
@ -398,7 +398,7 @@ void DActiveButton::Tick ()
|
||||||
if (def != NULL)
|
if (def != NULL)
|
||||||
{
|
{
|
||||||
m_Frame = -1;
|
m_Frame = -1;
|
||||||
S_Sound (DVector3(m_Pos, 0), CHAN_VOICE|CHAN_LISTENERZ,
|
S_Sound (Level, DVector3(m_Pos, 0), CHAN_VOICE|CHAN_LISTENERZ,
|
||||||
def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"),
|
def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"),
|
||||||
1, ATTN_STATIC);
|
1, ATTN_STATIC);
|
||||||
bFlippable = false;
|
bFlippable = false;
|
||||||
|
|
|
@ -1195,6 +1195,11 @@ struct side_t
|
||||||
Light = l;
|
Light = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLevelLocals *GetLevel()
|
||||||
|
{
|
||||||
|
return sector->Level;
|
||||||
|
}
|
||||||
|
|
||||||
FTextureID GetTexture(int which) const
|
FTextureID GetTexture(int which) const
|
||||||
{
|
{
|
||||||
return textures[which].texture;
|
return textures[which].texture;
|
||||||
|
|
|
@ -140,7 +140,7 @@ static bool MusicPaused; // whether music is paused
|
||||||
MusPlayingInfo mus_playing; // music currently being played
|
MusPlayingInfo mus_playing; // music currently being played
|
||||||
static FString LastSong; // last music that was played
|
static FString LastSong; // last music that was played
|
||||||
static FPlayList *PlayList;
|
static FPlayList *PlayList;
|
||||||
static int RestartEvictionsAt; // do not restart evicted channels before this level.time
|
static int RestartEvictionsAt; // do not restart evicted channels before this time
|
||||||
|
|
||||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||||
|
|
||||||
|
@ -402,16 +402,16 @@ void S_Start ()
|
||||||
FString LocalSndSeq;
|
FString LocalSndSeq;
|
||||||
|
|
||||||
// To be certain better check whether level is valid!
|
// To be certain better check whether level is valid!
|
||||||
if (level.info)
|
if (currentUILevel->info)
|
||||||
{
|
{
|
||||||
LocalSndInfo = level.info->SoundInfo;
|
LocalSndInfo = currentUILevel->info->SoundInfo;
|
||||||
LocalSndSeq = level.info->SndSeq;
|
LocalSndSeq = currentUILevel->info->SndSeq;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool parse_ss = false;
|
bool parse_ss = false;
|
||||||
|
|
||||||
// This level uses a different local SNDINFO
|
// This level uses a different local SNDINFO
|
||||||
if (LastLocalSndInfo.CompareNoCase(LocalSndInfo) != 0 || !level.info)
|
if (LastLocalSndInfo.CompareNoCase(LocalSndInfo) != 0 || !currentUILevel->info)
|
||||||
{
|
{
|
||||||
// First delete the old sound list
|
// First delete the old sound list
|
||||||
for(unsigned i = 1; i < S_sfx.Size(); i++)
|
for(unsigned i = 1; i < S_sfx.Size(); i++)
|
||||||
|
@ -456,10 +456,10 @@ void S_Start ()
|
||||||
|
|
||||||
// Don't start the music if loading a savegame, because the music is stored there.
|
// Don't start the music if loading a savegame, because the music is stored there.
|
||||||
// Don't start the music if revisiting a level in a hub for the same reason.
|
// Don't start the music if revisiting a level in a hub for the same reason.
|
||||||
if (!level.IsReentering())
|
if (!currentUILevel->IsReentering())
|
||||||
{
|
{
|
||||||
if (level.cdtrack == 0 || !S_ChangeCDMusic (level.cdtrack, level.cdid))
|
if (currentUILevel->cdtrack == 0 || !S_ChangeCDMusic (currentUILevel->cdtrack, currentUILevel->cdid))
|
||||||
S_ChangeMusic (level.Music, level.musicorder);
|
S_ChangeMusic (currentUILevel->Music, currentUILevel->musicorder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ void S_PrecacheLevel ()
|
||||||
FSoundID(snd).MarkUsed();
|
FSoundID(snd).MarkUsed();
|
||||||
}
|
}
|
||||||
// Precache all extra sounds requested by this map.
|
// Precache all extra sounds requested by this map.
|
||||||
for (auto snd : level.info->PrecacheSounds)
|
for (auto snd : currentUILevel->info->PrecacheSounds)
|
||||||
{
|
{
|
||||||
FSoundID(snd).MarkUsed();
|
FSoundID(snd).MarkUsed();
|
||||||
}
|
}
|
||||||
|
@ -706,7 +706,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector,
|
||||||
if(type == SOURCE_Unattached)
|
if(type == SOURCE_Unattached)
|
||||||
{
|
{
|
||||||
sector_t *sec = P_PointInSector(pt[0], pt[2]);
|
sector_t *sec = P_PointInSector(pt[0], pt[2]);
|
||||||
DVector2 disp = level.Displacements.getOffset(pgroup, sec->PortalGroup);
|
DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, sec->PortalGroup);
|
||||||
pos->X = pt[0] - (float)disp.X;
|
pos->X = pt[0] - (float)disp.X;
|
||||||
pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : (float)listenpos.Z;
|
pos->Y = !(chanflags & CHAN_LISTENERZ) ? pt[1] : (float)listenpos.Z;
|
||||||
pos->Z = pt[2] - (float)disp.Y;
|
pos->Z = pt[2] - (float)disp.Y;
|
||||||
|
@ -723,7 +723,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector,
|
||||||
//assert(actor != NULL);
|
//assert(actor != NULL);
|
||||||
if (actor != NULL)
|
if (actor != NULL)
|
||||||
{
|
{
|
||||||
DVector2 disp = level.Displacements.getOffset(pgroup, actor->Sector->PortalGroup);
|
DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, actor->Sector->PortalGroup);
|
||||||
DVector3 posi = actor->Pos() - disp;
|
DVector3 posi = actor->Pos() - disp;
|
||||||
*pos = { (float)posi.X, (float)posi.Z, (float)posi.Y };
|
*pos = { (float)posi.X, (float)posi.Z, (float)posi.Y };
|
||||||
}
|
}
|
||||||
|
@ -733,7 +733,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector,
|
||||||
assert(sector != NULL);
|
assert(sector != NULL);
|
||||||
if (sector != NULL)
|
if (sector != NULL)
|
||||||
{
|
{
|
||||||
DVector2 disp = level.Displacements.getOffset(pgroup, sector->PortalGroup);
|
DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, sector->PortalGroup);
|
||||||
if (chanflags & CHAN_AREA)
|
if (chanflags & CHAN_AREA)
|
||||||
{
|
{
|
||||||
// listener must be reversely offset to calculate the proper sound origin.
|
// listener must be reversely offset to calculate the proper sound origin.
|
||||||
|
@ -755,7 +755,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector,
|
||||||
assert(poly != NULL);
|
assert(poly != NULL);
|
||||||
if (poly != NULL)
|
if (poly != NULL)
|
||||||
{
|
{
|
||||||
DVector2 disp = level.Displacements.getOffset(pgroup, poly->CenterSubsector->sector->PortalGroup);
|
DVector2 disp = currentUILevel->Displacements.getOffset(pgroup, poly->CenterSubsector->sector->PortalGroup);
|
||||||
CalcPolyobjSoundOrg(listenpos + disp, poly, *pos);
|
CalcPolyobjSoundOrg(listenpos + disp, poly, *pos);
|
||||||
pos->X -= (float)disp.X;
|
pos->X -= (float)disp.X;
|
||||||
pos->Z -= (float)disp.Y;
|
pos->Z -= (float)disp.Y;
|
||||||
|
@ -916,7 +916,7 @@ static void CalcPolyobjSoundOrg(const DVector3 &listenpos, const FPolyObj *poly,
|
||||||
//
|
//
|
||||||
// S_StartSound
|
// S_StartSound
|
||||||
//
|
//
|
||||||
// 0 attenuation means full volume over whole level.
|
// 0 attenuation means full volume over whole currentUILevel->
|
||||||
// 0 < attenuation means to scale the distance by that amount when
|
// 0 < attenuation means to scale the distance by that amount when
|
||||||
// calculating volume.
|
// calculating volume.
|
||||||
//
|
//
|
||||||
|
@ -1337,9 +1337,9 @@ DEFINE_ACTION_FUNCTION(DObject, S_Sound)
|
||||||
|
|
||||||
void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float attenuation)
|
void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float attenuation)
|
||||||
{
|
{
|
||||||
if (ent == NULL || ent->Sector->Flags & SECF_SILENT)
|
if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != currentUILevel)
|
||||||
return;
|
return;
|
||||||
S_StartSound (ent, NULL, NULL, NULL, channel, sound_id, volume, attenuation);
|
S_StartSound (ent, nullptr, nullptr, nullptr, channel, sound_id, volume, attenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1352,7 +1352,7 @@ void S_Sound (AActor *ent, int channel, FSoundID sound_id, float volume, float a
|
||||||
|
|
||||||
void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume, float mindist, float maxdist)
|
void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume, float mindist, float maxdist)
|
||||||
{
|
{
|
||||||
if (ent == NULL || ent->Sector->Flags & SECF_SILENT)
|
if (ent == nullptr || ent->Sector->Flags & SECF_SILENT || ent->Level != currentUILevel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FRolloffInfo rolloff;
|
FRolloffInfo rolloff;
|
||||||
|
@ -1360,7 +1360,7 @@ void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume
|
||||||
rolloff.RolloffType = ROLLOFF_Linear;
|
rolloff.RolloffType = ROLLOFF_Linear;
|
||||||
rolloff.MinDistance = mindist;
|
rolloff.MinDistance = mindist;
|
||||||
rolloff.MaxDistance = maxdist;
|
rolloff.MaxDistance = maxdist;
|
||||||
S_StartSound(ent, NULL, NULL, NULL, channel, sound_id, volume, 1, &rolloff);
|
S_StartSound(ent, nullptr, nullptr, nullptr, channel, sound_id, volume, 1, &rolloff);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1371,7 +1371,8 @@ void S_SoundMinMaxDist(AActor *ent, int channel, FSoundID sound_id, float volume
|
||||||
|
|
||||||
void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume, float attenuation)
|
void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume, float attenuation)
|
||||||
{
|
{
|
||||||
S_StartSound (NULL, NULL, poly, NULL, channel, sound_id, volume, attenuation);
|
if (poly->GetLevel() != currentUILevel) return;
|
||||||
|
S_StartSound (nullptr, nullptr, poly, nullptr, channel, sound_id, volume, attenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1380,11 +1381,12 @@ void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void S_Sound(const DVector3 &pos, int channel, FSoundID sound_id, float volume, float attenuation)
|
void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, FSoundID sound_id, float volume, float attenuation)
|
||||||
{
|
{
|
||||||
|
if (Level != currentUILevel) return;
|
||||||
// The sound system switches Y and Z around.
|
// The sound system switches Y and Z around.
|
||||||
FVector3 p((float)pos.X, (float)pos.Z, (float)pos.Y);
|
FVector3 p((float)pos.X, (float)pos.Z, (float)pos.Y);
|
||||||
S_StartSound (NULL, NULL, NULL, &p, channel, sound_id, volume, attenuation);
|
S_StartSound (nullptr, nullptr, nullptr, &p, channel, sound_id, volume, attenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1395,7 +1397,8 @@ void S_Sound(const DVector3 &pos, int channel, FSoundID sound_id, float volume,
|
||||||
|
|
||||||
void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation)
|
void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation)
|
||||||
{
|
{
|
||||||
S_StartSound (NULL, sec, NULL, NULL, channel, sfxid, volume, attenuation);
|
if (sec->Level != currentUILevel) return;
|
||||||
|
S_StartSound (nullptr, sec, nullptr, nullptr, channel, sfxid, volume, attenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1408,7 +1411,7 @@ void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, fl
|
||||||
|
|
||||||
void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local)
|
void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local)
|
||||||
{
|
{
|
||||||
if (a == nullptr)
|
if (a == nullptr || a->Sector->Flags & SECF_SILENT || a->Level != currentUILevel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!local)
|
if (!local)
|
||||||
|
@ -2182,7 +2185,7 @@ void S_UpdateSounds (AActor *listenactor)
|
||||||
GSnd->UpdateListener(&listener);
|
GSnd->UpdateListener(&listener);
|
||||||
GSnd->UpdateSounds();
|
GSnd->UpdateSounds();
|
||||||
|
|
||||||
if (level.time >= RestartEvictionsAt)
|
if (currentUILevel->time >= RestartEvictionsAt)
|
||||||
{
|
{
|
||||||
RestartEvictionsAt = 0;
|
RestartEvictionsAt = 0;
|
||||||
S_RestoreEvictedChannels();
|
S_RestoreEvictedChannels();
|
||||||
|
@ -2208,8 +2211,8 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor)
|
||||||
listener.velocity.Zero();
|
listener.velocity.Zero();
|
||||||
listener.position = listenactor->SoundPos();
|
listener.position = listenactor->SoundPos();
|
||||||
listener.underwater = listenactor->waterlevel == 3;
|
listener.underwater = listenactor->waterlevel == 3;
|
||||||
assert(level.Zones.Size() > listenactor->Sector->ZoneNumber);
|
assert(currentUILevel->Zones.Size() > listenactor->Sector->ZoneNumber);
|
||||||
listener.Environment = level.Zones[listenactor->Sector->ZoneNumber].Environment;
|
listener.Environment = currentUILevel->Zones[listenactor->Sector->ZoneNumber].Environment;
|
||||||
listener.valid = true;
|
listener.valid = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2487,7 +2490,7 @@ void S_SerializeSounds(FSerializer &arc)
|
||||||
// playing before the wipe, and depending on the synchronization
|
// playing before the wipe, and depending on the synchronization
|
||||||
// between the main thread and the mixer thread at the time, the
|
// between the main thread and the mixer thread at the time, the
|
||||||
// sounds might be heard briefly before pausing for the wipe.
|
// sounds might be heard briefly before pausing for the wipe.
|
||||||
RestartEvictionsAt = level.time + 2;
|
RestartEvictionsAt = currentUILevel->time + 2;
|
||||||
}
|
}
|
||||||
GSnd->Sync(false);
|
GSnd->Sync(false);
|
||||||
GSnd->UpdateSounds();
|
GSnd->UpdateSounds();
|
||||||
|
@ -2577,8 +2580,8 @@ bool S_ChangeMusic (const char *musicname, int order, bool looping, bool force)
|
||||||
{
|
{
|
||||||
if (gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL)
|
if (gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL)
|
||||||
{
|
{
|
||||||
musicname = level.Music;
|
musicname = currentUILevel->Music;
|
||||||
order = level.musicorder;
|
order = currentUILevel->musicorder;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
class AActor;
|
class AActor;
|
||||||
class FScanner;
|
class FScanner;
|
||||||
class FSerializer;
|
class FSerializer;
|
||||||
|
struct FLevelLocals;
|
||||||
|
|
||||||
//
|
//
|
||||||
// SoundFX struct.
|
// SoundFX struct.
|
||||||
|
@ -228,7 +229,7 @@ void S_Sound (AActor *ent, int channel, FSoundID sfxid, float volume, float atte
|
||||||
void S_SoundMinMaxDist (AActor *ent, int channel, FSoundID sfxid, float volume, float mindist, float maxdist);
|
void S_SoundMinMaxDist (AActor *ent, int channel, FSoundID sfxid, float volume, float mindist, float maxdist);
|
||||||
void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, float attenuation);
|
void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, float attenuation);
|
||||||
void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation);
|
void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation);
|
||||||
void S_Sound(const DVector3 &pos, int channel, FSoundID sfxid, float volume, float attenuation);
|
void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, FSoundID sfxid, float volume, float attenuation);
|
||||||
|
|
||||||
// [Nash] Used by ACS and DECORATE
|
// [Nash] Used by ACS and DECORATE
|
||||||
void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local);
|
void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool local);
|
||||||
|
|
Loading…
Reference in a new issue