- Fixed default.cbd and Makefile.mingw for current code state.

- New: Pausing the game (through any means, not just the pause key) now pauses
  sound effects as well as music. "PauseMusicInMenus" has been added as a
  MAPINFO flag to also pause the music when a menu or the console are open.


SVN r134 (trunk)
This commit is contained in:
Randy Heit 2006-05-21 02:10:16 +00:00
parent f8bdceab38
commit 62b7dd3efc
19 changed files with 117 additions and 37 deletions

View file

@ -28,7 +28,7 @@ ifndef RELEASETARGET
RELEASETARGET = zdoomgcc.exe
endif
ifndef DEBUGTARGET
DEBUGTARGE = zdoomgccd.exe
DEBUGTARGET = zdoomgccd.exe
endif
DEBUGOBJDIR = debugobj
RELEASEOBJDIR = releaseobj
@ -156,6 +156,7 @@ OBJECTS += \
$(OBJDIR)/p_writemap.o \
$(OBJDIR)/p_xlat.o \
$(OBJDIR)/po_man.o \
$(OBJDIR)/r_anim.o \
$(OBJDIR)/r_bsp.o \
$(OBJDIR)/r_data.o \
$(OBJDIR)/r_draw.o \
@ -365,7 +366,6 @@ OBJECTS += \
ifndef NOASM
OBJECTS += \
$(OBJDIR)/a.o \
$(OBJDIR)/blocks.o \
$(OBJDIR)/misc.o \
$(OBJDIR)/tmap.o \
$(OBJDIR)/tmap2.o \

View file

@ -138,7 +138,6 @@ done
${COMPILER} "autostart.cpp \
a.nas \
blocks.nas \
misc.nas \
tmap.nas \
tmap2.nas \
@ -235,6 +234,7 @@ ${COMPILER} "autostart.cpp \
p_writemap.cpp \
p_xlat.cpp \
po_man.cpp \
r_anim.cpp \
r_bsp.cpp \
r_data.cpp \
r_draw.cpp \

View file

@ -1,3 +1,9 @@
May 20, 2006
- Fixed default.cbd and Makefile.mingw for current code state.
- New: Pausing the game (through any means, not just the pause key) now pauses
sound effects as well as music. "PauseMusicInMenus" has been added as a
MAPINFO flag to also pause the music when a menu or the console are open.
May 20, 2006 (Changes by Graf Zahl)
- Fixed: The automap code had the check for rotation reversed.
- Changed type PClass::FreeIndices to TArray<unsigned int> because that's

View file

@ -2175,7 +2175,7 @@ void Net_DoCommand (int type, byte **stream, int player)
else
{
paused = player + 1;
S_PauseSound ();
S_PauseSound (false);
}
BorderNeedRefresh = screen->GetPageCount ();
}

View file

@ -246,6 +246,7 @@ static const char *MapInfoMapLevel[] =
"wrapmidtextures",
"allowcrouch",
"nocrouch",
"pausemusicinmenus",
NULL
};
@ -361,6 +362,7 @@ MapHandlers[] =
{ MITYPE_SETFLAG, LEVEL_WRAPMIDTEX, 0 },
{ MITYPE_SCFLAGS, LEVEL_CROUCH_YES, ~LEVEL_CROUCH_NO },
{ MITYPE_SCFLAGS, LEVEL_CROUCH_NO, ~LEVEL_CROUCH_YES },
{ MITYPE_SCFLAGS, LEVEL_PAUSE_MUSIC_IN_MENUS, 0 },
};
static const char *MapInfoClusterLevel[] =

View file

@ -106,6 +106,8 @@
#define LEVEL_CROUCH_NO UCONST64(0x80000000000)
#define LEVEL_CROUCH_YES UCONST64(0x100000000000)
#define LEVEL_PAUSE_MUSIC_IN_MENUS UCONST64(0x200000000000)
struct acsdefered_s;
struct FSpecialAction

View file

@ -63,6 +63,7 @@
#include "templates.h"
#include "lists.h"
#include "gi.h"
#include "p_tick.h"
// MACROS ------------------------------------------------------------------
@ -587,6 +588,9 @@ void M_ActivateMenuInput ()
{
ResetButtonStates ();
menuactive = MENU_On;
// Pause sound effects before we play the menu switch sound.
// That way, it won't be paused.
P_CheckTickerPaused ();
}
void M_DeactivateMenuInput ()

View file

@ -170,7 +170,6 @@ int FRandom::HitDice (int count)
void FRandom::StaticClearRandom ()
{
Printf ("init with seed %d\n", rngseed);
const DWORD seed = rngseed*2+1; // add 3/26/98: add rngseed
FRandom *rng = FRandom::RNGList;

View file

@ -27,12 +27,40 @@
#include "p_acs.h"
#include "c_console.h"
#include "b_bot.h"
#include "s_sound.h"
#include "doomstat.h"
#include "sbar.h"
extern gamestate_t wipegamestate;
//==========================================================================
//
// P_CheckTickerPaused
//
// Returns true if the ticker should be paused. In that cause, it also
// pauses sound effects and possibly music. If the ticker should not be
// paused, then it returns false but does not unpause anything.
//
//==========================================================================
bool P_CheckTickerPaused ()
{
// pause if in menu or console and at least one tic has been run
if ( !netgame
&& gamestate != GS_TITLELEVEL
&& ((menuactive != MENU_Off && menuactive != MENU_OnNoPause) ||
ConsoleState == c_down || ConsoleState == c_falling)
&& !demoplayback
&& !demorecording
&& players[consoleplayer].viewz != 1
&& wipegamestate == gamestate)
{
S_PauseSound (!(level.flags & LEVEL_PAUSE_MUSIC_IN_MENUS));
return true;
}
return false;
}
//
// P_Ticker
//
@ -44,22 +72,10 @@ void P_Ticker (void)
r_NoInterpolate = true;
// run the tic
if (paused)
if (paused || P_CheckTickerPaused())
return;
// pause if in menu or console and at least one tic has been run
if ( !netgame
&& gamestate != GS_TITLELEVEL
&& ((menuactive != MENU_Off && menuactive != MENU_OnNoPause) ||
ConsoleState == c_down || ConsoleState == c_falling)
&& !demoplayback
&& !demorecording
&& players[consoleplayer].viewz != 1
&& wipegamestate == gamestate)
{
return;
}
S_ResumeSound ();
P_ResetSightCounters (false);
// Since things will be moving, it's okay to interpolate them in the renderer.

View file

@ -30,6 +30,7 @@
// Carries out all thinking of monsters and players.
void P_Ticker (void);
bool P_CheckTickerPaused ();
#endif

View file

@ -142,7 +142,8 @@ static void CalcPosVel (fixed_t *pt, AActor *mover, int constz, float pos[3],
int MAX_SND_DIST;
static channel_t *Channel; // the set of channels available
static BOOL mus_paused; // whether songs are paused
static bool SoundPaused; // whether sound effects are paused
static bool MusicPaused; // whether music is paused
static MusPlayingInfo mus_playing; // music currently being played
static FString LastSong; // last music that was played
static byte *SoundCurve;
@ -341,7 +342,8 @@ void S_Init ()
}
// no sounds are playing, and they are not paused
mus_paused = 0;
MusicPaused = false;
SoundPaused = false;
// Note that sounds have not been cached (yet).
// for (i=1; (size_t)i < S_sfx.Size (); i++)
@ -442,7 +444,8 @@ void S_Start ()
}
// start new music for the level
mus_paused = 0;
MusicPaused = false;
SoundPaused = false;
// [RH] This is a lot simpler now.
if (!savegamerestore)
@ -1227,15 +1230,20 @@ bool S_IsActorPlayingSomething (AActor *actor, int channel)
//
// S_PauseSound
//
// Stop music, during game PAUSE.
// Stop music and sound effects, during game PAUSE.
//==========================================================================
void S_PauseSound ()
void S_PauseSound (bool notmusic)
{
if (mus_playing.handle && !mus_paused)
if (!notmusic && mus_playing.handle && !MusicPaused)
{
I_PauseSong (mus_playing.handle);
mus_paused = true;
MusicPaused = true;
}
if (GSnd != NULL && !SoundPaused)
{
GSnd->SetSfxPaused (true);
SoundPaused = true;
}
}
@ -1243,15 +1251,20 @@ void S_PauseSound ()
//
// S_ResumeSound
//
// Resume music, after game PAUSE.
// Resume music and sound effects, after game PAUSE.
//==========================================================================
void S_ResumeSound ()
{
if (mus_playing.handle && mus_paused)
if (mus_playing.handle && MusicPaused)
{
I_ResumeSong (mus_playing.handle);
mus_paused = false;
MusicPaused = false;
}
if (GSnd != NULL && SoundPaused)
{
GSnd->SetSfxPaused (false);
SoundPaused = false;
}
}
@ -1603,7 +1616,7 @@ void S_StopMusic (bool force)
// [RH] Don't stop if a playlist is active.
if ((force || PlayList == NULL) && !mus_playing.name.IsEmpty())
{
if (mus_paused)
if (MusicPaused)
I_ResumeSong(mus_playing.handle);
I_StopSong(mus_playing.handle);

View file

@ -171,7 +171,7 @@ int S_GetMusic (char **name);
void S_StopMusic (bool force);
// Stop and resume music, during game PAUSE.
void S_PauseSound ();
void S_PauseSound (bool notmusic);
void S_ResumeSound ();
//

View file

@ -268,12 +268,12 @@ void MessagePump (const SDL_Event &sev)
{ // kill focus
FlushDIKState ();
if (!paused)
S_PauseSound ();
S_PauseSound (false);
}
else
{ // set focus
if (!paused)
S_ResumeSound ();
S_ResumeSound (false);
}
}
break;

View file

@ -75,6 +75,7 @@ struct AltSoundRenderer::Channel
SDWORD LeftVolume;
SDWORD RightVolume;
bool Looping;
bool Paused;
CRITICAL_SECTION CriticalSection;
};
@ -521,6 +522,7 @@ long AltSoundRenderer::StartSound (sfxinfo_t *sfx, int vol, int sep, int pitch,
chan->LeftVolume = left;
chan->RightVolume = right;
chan->Looping = !!looping;
chan->Paused = false;
LeaveCriticalSection (&chan->CriticalSection);
return channel + 1;
@ -541,6 +543,22 @@ void AltSoundRenderer::StopSound (long handle)
chan->Sample = NULL;
}
//==========================================================================
//
// AltSoundRenderer :: SetSfxPaused
//
//==========================================================================
void AltSoundRenderer::SetSfxPaused (bool paused)
{
if (Channels == NULL) return;
for (int i = 0; i < NumChannels; ++i)
{
Channels[i].Paused = paused;
}
}
//==========================================================================
//
// AltSoundRenderer :: IsPlayingSound
@ -857,7 +875,7 @@ void AltSoundRenderer::UpdateSound ()
for (int i = 0; i < NumChannels; ++i)
{
EnterCriticalSection (&Channels[i].CriticalSection);
if (Channels[i].Sample != NULL)
if (Channels[i].Sample != NULL && !Channels[i].Paused)
{
if (Channels[i].Sample->b16bit)
{

View file

@ -30,6 +30,9 @@ public:
// Stops a sound channel.
void StopSound (long handle);
// Pauses or resumes all sound effect channels.
void SetSfxPaused (bool paused);
// Returns true if the channel is still playing a sound.
bool IsPlayingSound (long handle);

View file

@ -739,7 +739,7 @@ long FMODSoundRenderer::StartSound3D (sfxinfo_t *sfx, float vol, int pitch, int
void FMODSoundRenderer::StopSound (long handle)
{
if (!handle ||!ChannelMap)
if (!handle || !ChannelMap)
return;
handle--;
@ -752,6 +752,16 @@ void FMODSoundRenderer::StopSound (long handle)
}
}
void FMODSoundRenderer::SetSfxPaused (bool paused)
{
for (int i = 0; i < NumChannels; ++i)
{
if (ChannelMap[i].soundID != -1)
{
FSOUND_SetPaused (ChannelMap[i].channelID, paused);
}
}
}
bool FMODSoundRenderer::IsPlayingSound (long handle)
{

View file

@ -32,6 +32,9 @@ public:
// Stops a sound channel.
void StopSound (long handle);
// Pauses or resumes all sound effect channels.
void SetSfxPaused (bool paused);
// Returns true if the channel is still playing a sound.
bool IsPlayingSound (long handle);

View file

@ -99,6 +99,9 @@ public:
// Stops a sound channel.
virtual void StopSound (long handle) = 0;
// Pauses or resumes all sound effect channels.
virtual void SetSfxPaused (bool paused) = 0;
// Returns true if the channel is still playing a sound.
virtual bool IsPlayingSound (long handle) = 0;

View file

@ -1538,7 +1538,7 @@ static void SetSoundPaused (int state)
{
if (paused == 0)
{
S_PauseSound ();
S_PauseSound (false);
if (!netgame
#ifdef _DEBUG
&& !demoplayback