diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index df89a38a8..c50c65008 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -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: diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index c18cfc2f8..906f372b7 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -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; } diff --git a/polymer/eduke32/source/sector.h b/polymer/eduke32/source/sector.h index ac8604f65..e1f82c49b 100644 --- a/polymer/eduke32/source/sector.h +++ b/polymer/eduke32/source/sector.h @@ -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);