mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
Make deletion of an ambient sound MUSICANDSFX sprite stop its sound again.
Add a test case source/lunatic/test/delmusicsfx.lua. git-svn-id: https://svn.eduke32.com/eduke32@3822 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
360aae414f
commit
1715b7631f
2 changed files with 57 additions and 0 deletions
|
@ -596,6 +596,12 @@ void A_DeleteSprite(int32_t s)
|
||||||
A_DeleteLight(s);
|
A_DeleteLight(s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (sprite[s].picnum == MUSICANDSFX && actor[s].t_data[8]==1)
|
||||||
|
{
|
||||||
|
// AMBIENT_SFX_PLAYING
|
||||||
|
S_StopEnvSound(sprite[s].lotag, s);
|
||||||
|
}
|
||||||
|
|
||||||
// NetAlloc
|
// NetAlloc
|
||||||
if (Net_IsRelevantSprite(s))
|
if (Net_IsRelevantSprite(s))
|
||||||
{
|
{
|
||||||
|
@ -1328,6 +1334,7 @@ ACTOR_STATIC void G_MoveFX(void)
|
||||||
|
|
||||||
if (T2 != ud.config.SoundToggle)
|
if (T2 != ud.config.SoundToggle)
|
||||||
{
|
{
|
||||||
|
// If sound playback was toggled, restart.
|
||||||
T2 = ud.config.SoundToggle;
|
T2 = ud.config.SoundToggle;
|
||||||
T1 = 0;
|
T1 = 0;
|
||||||
}
|
}
|
||||||
|
@ -1371,6 +1378,8 @@ ACTOR_STATIC void G_MoveFX(void)
|
||||||
|
|
||||||
if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1))
|
if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1))
|
||||||
{
|
{
|
||||||
|
// Start playing an ambience sound.
|
||||||
|
|
||||||
char om = g_sounds[s->lotag].m;
|
char om = g_sounds[s->lotag].m;
|
||||||
if (g_numEnvSoundsPlaying == ud.config.NumVoices)
|
if (g_numEnvSoundsPlaying == ud.config.NumVoices)
|
||||||
{
|
{
|
||||||
|
@ -1392,10 +1401,14 @@ ACTOR_STATIC void G_MoveFX(void)
|
||||||
A_PlaySound(s->lotag,i);
|
A_PlaySound(s->lotag,i);
|
||||||
g_sounds[s->lotag].m = om;
|
g_sounds[s->lotag].m = om;
|
||||||
T1 = 1;
|
T1 = 1;
|
||||||
|
T9 = 1; // AMBIENT_SFX_PLAYING
|
||||||
}
|
}
|
||||||
else if (x >= ht && T1 == 1)
|
else if (x >= ht && T1 == 1)
|
||||||
{
|
{
|
||||||
|
// Stop playing ambience sound because we're out of its range.
|
||||||
|
|
||||||
// T1 = 0;
|
// T1 = 0;
|
||||||
|
T9 = 0;
|
||||||
S_StopEnvSound(s->lotag,i);
|
S_StopEnvSound(s->lotag,i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
44
polymer/eduke32/source/lunatic/test/delmusicsfx.lua
Normal file
44
polymer/eduke32/source/lunatic/test/delmusicsfx.lua
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
local con = require "con"
|
||||||
|
|
||||||
|
local spritesofstat = spritesofstat
|
||||||
|
|
||||||
|
local Inf = 0/1
|
||||||
|
|
||||||
|
-- Insert MUSICANDSFX? (Delete it otherwise.)
|
||||||
|
-- XXX: should be a per-player gamevar, but this is testing code.
|
||||||
|
local insp = false
|
||||||
|
local hitag, lotag = 0, 0
|
||||||
|
|
||||||
|
gameevent("JUMP",
|
||||||
|
function(aci, pli)
|
||||||
|
local ps = player[pli]
|
||||||
|
|
||||||
|
if (insp) then
|
||||||
|
-- Insert MUSICANDSFX sprite with same lo-/hitag as last deleted one.
|
||||||
|
|
||||||
|
local spr = sprite[con.spawn(aci, 5)]
|
||||||
|
spr.lotag, spr.hitag = lotag, hitag
|
||||||
|
else
|
||||||
|
-- Delete nearest MUSICANDSFX sprite.
|
||||||
|
|
||||||
|
local nearestdst = Inf
|
||||||
|
local nearesti = -1
|
||||||
|
|
||||||
|
for i in spritesofstat(gv.STAT_FX) do
|
||||||
|
local dst = (sprite[i]-ps.pos):len2()
|
||||||
|
if (nearesti == -1 or dst < nearestdst) then
|
||||||
|
nearesti = i
|
||||||
|
nearestdst = dst
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (nearesti >= 0) then
|
||||||
|
local spr = sprite[nearesti]
|
||||||
|
lotag, hitag = spr.lotag, spr.hitag
|
||||||
|
actor.delete(nearesti)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
insp = not insp
|
||||||
|
end)
|
Loading…
Reference in a new issue