Rip out S_FindMusicSFX() from A_CallSound() and use in SE6/14 on-spawn init.

This makes the subway sound not played once on map initialization.

git-svn-id: https://svn.eduke32.com/eduke32@4481 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-05-23 20:25:29 +00:00
parent 123906a9d7
commit e61afe6d88
3 changed files with 56 additions and 39 deletions

View file

@ -6937,7 +6937,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
{
case SE_6_SUBWAY:
case SE_14_SUBWAY_CAR:
j = A_CallSound(sect,i);
S_FindMusicSFX(sect, &j);
if (j == -1) j = SUBWAY;
actor[i].lastvx = j;
case SE_30_TWO_WAY_TRAIN:

View file

@ -33,17 +33,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int32_t g_haltSoundHack = 0;
// this function activates a sector's MUSICANDSFX sprite
int32_t A_CallSound(int32_t sn, int32_t whatsprite)
int32_t S_FindMusicSFX(int32_t sn, int32_t *sndptr)
{
int32_t i;
if (g_haltSoundHack)
{
g_haltSoundHack = 0;
return -1;
}
for (SPRITES_OF_SECT(sn, i))
{
const int32_t snd = sprite[i].lotag;
@ -51,39 +44,62 @@ int32_t A_CallSound(int32_t sn, int32_t whatsprite)
if (PN == MUSICANDSFX && (unsigned)snd < 1000) // XXX: in other places, 999
{
if (whatsprite == -1)
whatsprite = i;
if (T1 == 0)
{
if ((g_sounds[snd].m & SF_GLOBAL) == 0)
{
if (snd)
{
A_PlaySound(snd, whatsprite);
if (SHT && snd != SHT && SHT < MAXSOUNDS)
S_StopEnvSound(SHT,T6);
T6 = whatsprite;
}
if ((sector[SECT].lotag&0xff) != ST_22_SPLITTING_DOOR)
T1 = 1;
}
}
else if (SHT < MAXSOUNDS)
{
if (SHT)
A_PlaySound(SHT, whatsprite);
if ((g_sounds[snd].m & SF_LOOP) || (SHT && SHT != snd))
S_StopEnvSound(snd, T6);
T6 = whatsprite;
T1 = 0;
}
return snd;
*sndptr = snd;
return i;
}
}
*sndptr = -1;
return -1;
}
// this function activates a sector's MUSICANDSFX sprite
int32_t A_CallSound(int32_t sn, int32_t whatsprite)
{
int32_t i, snd;
if (g_haltSoundHack)
{
g_haltSoundHack = 0;
return -1;
}
i = S_FindMusicSFX(sn, &snd);
if (i >= 0)
{
if (whatsprite == -1)
whatsprite = i;
if (T1 == 0)
{
if ((g_sounds[snd].m & SF_GLOBAL) == 0)
{
if (snd)
{
A_PlaySound(snd, whatsprite);
if (SHT && snd != SHT && SHT < MAXSOUNDS)
S_StopEnvSound(SHT,T6);
T6 = whatsprite;
}
if ((sector[SECT].lotag&0xff) != ST_22_SPLITTING_DOOR)
T1 = 1;
}
}
else if (SHT < MAXSOUNDS)
{
if (SHT)
A_PlaySound(SHT, whatsprite);
if ((g_sounds[snd].m & SF_LOOP) || (SHT && SHT != snd))
S_StopEnvSound(snd, T6);
T6 = whatsprite;
T1 = 0;
}
return snd;
}
return -1;
}

View file

@ -103,6 +103,7 @@ typedef struct {
//extern map_t MapInfo[(MAXVOLUMES+1)*MAXLEVELS]; // +1 volume for "intro", "briefing" music
void G_ActivateBySector(int32_t sect,int32_t j);
int32_t S_FindMusicSFX(int32_t sn, int32_t *sndptr);
int32_t A_CallSound(int32_t sn,int32_t whatsprite);
int32_t A_CheckHitSprite(int32_t i,int16_t *hitsp);
void A_DamageObject(int32_t i,int32_t sn);