- Fixed: Starting in a sector with a musinfo thing would not trigger the thing.

SVN r3313 (trunk)
This commit is contained in:
Randy Heit 2011-11-07 00:31:17 +00:00
commit 66f86add05
3 changed files with 47 additions and 10 deletions

View file

@ -293,6 +293,7 @@ float S_GetMusicVolume (const char *music)
}
//==========================================================================
//
// S_HashSounds
//
@ -2248,6 +2249,8 @@ class AMusicChanger : public ASectorAction
DECLARE_CLASS (AMusicChanger, ASectorAction)
public:
virtual bool TriggerAction (AActor *triggerer, int activationType);
virtual void Tick();
virtual void PostBeginPlay();
};
IMPLEMENT_CLASS(AMusicChanger)
@ -2256,19 +2259,46 @@ bool AMusicChanger::TriggerAction (AActor *triggerer, int activationType)
{
if (activationType & SECSPAC_Enter)
{
if (args[0] != 0)
{
FName *music = level.info->MusicMap.CheckKey(args[0]);
if (music != NULL)
{
S_ChangeMusic(music->GetChars(), args[1]);
}
}
else
{
S_ChangeMusic("*");
if (args[0] == 0 || level.info->MusicMap.CheckKey(args[0]))
{
level.nextmusic = args[0];
reactiontime = 30;
}
}
return Super::TriggerAction (triggerer, activationType);
}
void AMusicChanger::Tick()
{
Super::Tick();
if (reactiontime > -1 && --reactiontime == 0)
{
// Is it our music that's queued for being played?
if (level.nextmusic == args[0])
{
if (args[0] != 0)
{
FName *music = level.info->MusicMap.CheckKey(args[0]);
if (music != NULL)
{
S_ChangeMusic(music->GetChars(), args[1]);
}
}
else
{
S_ChangeMusic("*");
}
}
}
}
void AMusicChanger::PostBeginPlay()
{
// The music changer should consider itself activated if the player
// spawns in its sector as well as if it enters the sector during a P_TryMove.
if (players[consoleplayer].mo && players[consoleplayer].mo->Sector == this->Sector)
{
TriggerAction(players[consoleplayer].mo, SECSPAC_Enter);
}
}