diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index cdd0361c5..b4a3485c3 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -44,8 +44,11 @@ #include "m_random.h" #include "printf.h" #include "c_cvars.h" +#include "gamestate.h" CVARD(Bool, snd_enabled, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enables/disables sound effects") +CVAR(Bool, i_soundinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, i_pauseinbackground, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) int SoundEnabled() { @@ -1710,3 +1713,160 @@ void S_SoundReset() S_RestartMusic(); } +//========================================================================== +// +// CCMD cachesound +// +//========================================================================== + +#include "s_music.h" +#include "vm.h" +#include "c_dispatch.h" +#include "stats.h" +#include "i_net.h" +#include "i_interface.h" + + +CCMD(cachesound) +{ + if (argv.argc() < 2) + { + Printf("Usage: cachesound ...\n"); + return; + } + for (int i = 1; i < argv.argc(); ++i) + { + FSoundID sfxnum = argv[i]; + if (sfxnum != FSoundID(0)) + { + soundEngine->CacheSound(sfxnum); + } + } +} + + +CCMD(listsoundchannels) +{ + Printf("%s", soundEngine->ListSoundChannels().GetChars()); +} + +// intentionally moved here to keep the s_music include out of the rest of the file. + +//========================================================================== +// +// S_PauseSound +// +// Stop music and sound effects, during game PAUSE. +//========================================================================== + +void S_PauseSound(bool notmusic, bool notsfx) +{ + if (!notmusic) + { + S_PauseMusic(); + } + if (!notsfx) + { + soundEngine->SetPaused(true); + GSnd->SetSfxPaused(true, 0); + } +} + +DEFINE_ACTION_FUNCTION(DObject, S_PauseSound) +{ + PARAM_PROLOGUE; + PARAM_BOOL(notmusic); + PARAM_BOOL(notsfx); + S_PauseSound(notmusic, notsfx); + return 0; +} + +//========================================================================== +// +// S_ResumeSound +// +// Resume music and sound effects, after game PAUSE. +//========================================================================== + +void S_ResumeSound(bool notsfx) +{ + S_ResumeMusic(); + if (!notsfx) + { + soundEngine->SetPaused(false); + GSnd->SetSfxPaused(false, 0); + } +} + +DEFINE_ACTION_FUNCTION(DObject, S_ResumeSound) +{ + PARAM_PROLOGUE; + PARAM_BOOL(notsfx); + S_ResumeSound(notsfx); + return 0; +} + +//========================================================================== +// +// S_SetSoundPaused +// +// Called with state non-zero when the app is active, zero when it isn't. +// +//========================================================================== + +void S_SetSoundPaused(int state) +{ + if (!netgame && (i_pauseinbackground)) + { + pauseext = !state; + } + + if ((state || i_soundinbackground) && !pauseext) + { + if (paused == 0) + { + S_ResumeSound(true); + if (GSnd != nullptr) + { + GSnd->SetInactive(SoundRenderer::INACTIVE_Active); + } + } + } + else + { + if (paused == 0) + { + S_PauseSound(false, true); + if (GSnd != nullptr) + { + GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ? + SoundRenderer::INACTIVE_Complete : + SoundRenderer::INACTIVE_Mute); + } + } + } +} + + + +CCMD(snd_status) +{ + GSnd->PrintStatus(); +} + +CCMD(snd_reset) +{ + S_SoundReset(); +} + +CCMD(snd_listdrivers) +{ + GSnd->PrintDriversList(); +} + +ADD_STAT(sound) +{ + return GSnd->GatherStats(); +} + + diff --git a/src/common/audio/sound/s_soundinternal.h b/src/common/audio/sound/s_soundinternal.h index f15c994dc..a30dd3fc0 100644 --- a/src/common/audio/sound/s_soundinternal.h +++ b/src/common/audio/sound/s_soundinternal.h @@ -306,6 +306,7 @@ public: void MarkUsed(int num); void CacheMarkedSounds(); TArray AllActiveChannels(); + virtual void SetSoundPaused(int state) {} void MarkAllUnused() { diff --git a/src/common/console/c_cvars.cpp b/src/common/console/c_cvars.cpp index 2d08d7b68..15b2ca747 100644 --- a/src/common/console/c_cvars.cpp +++ b/src/common/console/c_cvars.cpp @@ -43,6 +43,7 @@ #include "engineerrors.h" #include "printf.h" #include "palutil.h" +#include "i_interface.h" struct FLatchedValue @@ -1462,7 +1463,7 @@ EXTERN_CVAR(Bool, sv_cheats); void FBaseCVar::CmdSet (const char *newval) { - if ((GetFlags() & CVAR_CHEAT) && CheckCheatmode ()) + if ((GetFlags() & CVAR_CHEAT) && sysCallbacks.CheckCheatmode && sysCallbacks.CheckCheatmode(true, false)) return; MarkUnsafe(); diff --git a/src/common/console/c_dispatch.h b/src/common/console/c_dispatch.h index 57d681c49..532ed9b92 100644 --- a/src/common/console/c_dispatch.h +++ b/src/common/console/c_dispatch.h @@ -59,8 +59,6 @@ extern bool ParsingKeyConf, UnsafeExecutionContext; extern FString StoredWarp; // [RH] +warp at the command line -extern bool CheckCheatmode (bool printmsg = true, bool sponly = false); - FExecList *C_ParseCmdLineParams(FExecList *exec); // Add commands to the console as if they were typed in. Can handle wait diff --git a/src/common/engine/i_interface.cpp b/src/common/engine/i_interface.cpp index ab054b076..59e7f7a82 100644 --- a/src/common/engine/i_interface.cpp +++ b/src/common/engine/i_interface.cpp @@ -17,6 +17,8 @@ bool AppActive = true; int chatmodeon; gamestate_t gamestate = GS_STARTUP; bool ToggleFullscreen; +int paused; +bool pauseext; FStartupInfo GameStartupInfo; diff --git a/src/common/engine/i_interface.h b/src/common/engine/i_interface.h index be3651886..d302ef0d7 100644 --- a/src/common/engine/i_interface.h +++ b/src/common/engine/i_interface.h @@ -35,6 +35,7 @@ struct SystemCallbacks void (*ToggleFullConsole)(); void (*StartCutscene)(bool blockui); void (*SetTransition)(int type); + bool (*CheckCheatmode)(bool printmsg, bool sponly); }; extern SystemCallbacks sysCallbacks; @@ -50,5 +51,7 @@ extern FString endoomName; extern bool batchrun; extern float menuBlurAmount; extern bool generic_ui; +extern int paused; +extern bool pauseext; void UpdateGenericUI(bool cvar); diff --git a/src/console/c_cmds.cpp b/src/console/c_cmds.cpp index 665cc0389..b1824aa04 100644 --- a/src/console/c_cmds.cpp +++ b/src/console/c_cmds.cpp @@ -69,6 +69,7 @@ #include "s_music.h" #include "texturemanager.h" #include "v_draw.h" +#include "d_main.h" extern FILE *Logfile; extern bool insave; diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index bd25c267b..576a621bf 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -50,7 +50,7 @@ #include "i_interface.h" EXTERN_CVAR(Bool, queryiwad); -EXTERN_CVAR(Bool, defaultiwad); +EXTERN_CVAR(String, defaultiwad); //========================================================================== // diff --git a/src/d_main.cpp b/src/d_main.cpp index 7505fc125..aabea4fe4 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -3529,6 +3529,7 @@ static int D_DoomMain_Internal (void) System_ToggleFullConsole, System_StartCutscene, System_SetTransition, + CheckCheatmode, }; diff --git a/src/d_main.h b/src/d_main.h index 5f0ce7582..2698a738d 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -161,4 +161,6 @@ inline bool V_IsTrueColor() return vid_rendermode == 1 || vid_rendermode == 4; } +bool CheckCheatmode(bool printmsg = true, bool sponly = false); + #endif diff --git a/src/d_net.cpp b/src/d_net.cpp index ad8d0c5be..99cb5a5b2 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -69,6 +69,8 @@ #include "gstrings.h" #include "s_music.h" #include "screenjob.h" +#include "d_main.h" +#include "i_interface.h" EXTERN_CVAR (Int, disableautosave) EXTERN_CVAR (Int, autosavecount) diff --git a/src/doomstat.h b/src/doomstat.h index 729d3fffe..c95d0cdca 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -108,8 +108,6 @@ EXTERN_CVAR (Float, snd_musicvolume) // maximum volume for music #include "menustate.h" extern bool automapactive; // In AutoMap mode? -extern int paused; // Game Pause? -extern bool pauseext; extern bool viewactive; diff --git a/src/g_dumpinfo.cpp b/src/g_dumpinfo.cpp index 72c928906..72400708b 100644 --- a/src/g_dumpinfo.cpp +++ b/src/g_dumpinfo.cpp @@ -44,6 +44,7 @@ #include "c_functions.h" #include "gstrings.h" #include "texturemanager.h" +#include "d_main.h" //========================================================================== // diff --git a/src/g_game.cpp b/src/g_game.cpp index 00453a486..8a4db9c3f 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -89,6 +89,7 @@ #include "hwrenderer/scene/hw_drawinfo.h" #include "doommenu.h" #include "screenjob.h" +#include "i_interface.h" static FRandom pr_dmspawn ("DMSpawn"); @@ -145,8 +146,6 @@ extern bool playedtitlemusic; gameaction_t gameaction; -int paused; -bool pauseext; bool sendpause; // send a pause event next tic bool sendsave; // send a save event next tic bool sendturn180; // [RH] send a 180 degree turn next tic diff --git a/src/g_level.cpp b/src/g_level.cpp index 15c000cc6..043a8ac4a 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -46,6 +46,7 @@ #include "filesystem.h" #include "am_map.h" #include "c_dispatch.h" +#include "i_interface.h" #include "p_setup.h" #include "p_local.h" diff --git a/src/gamedata/info.cpp b/src/gamedata/info.cpp index c72d789ab..22ad8d42b 100644 --- a/src/gamedata/info.cpp +++ b/src/gamedata/info.cpp @@ -53,6 +53,7 @@ #include "filesystem.h" #include "g_levellocals.h" #include "texturemanager.h" +#include "d_main.h" extern void LoadActors (); extern void InitBotStuff(); diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index b85f87c0d..a4ac6bc39 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -54,6 +54,7 @@ #include "a_morph.h" #include "g_levellocals.h" #include "vm.h" +#include "d_main.h" uint8_t globalfreeze, globalchangefreeze; // user's freeze state. diff --git a/src/p_tick.cpp b/src/p_tick.cpp index 2889a06a5..57cc986af 100644 --- a/src/p_tick.cpp +++ b/src/p_tick.cpp @@ -38,6 +38,7 @@ #include "events.h" #include "actorinlines.h" #include "g_game.h" +#include "i_interface.h" extern gamestate_t wipegamestate; extern uint8_t globalfreeze, globalchangefreeze; diff --git a/src/playsim/bots/b_bot.cpp b/src/playsim/bots/b_bot.cpp index d9abf4a9f..415cc271d 100644 --- a/src/playsim/bots/b_bot.cpp +++ b/src/playsim/bots/b_bot.cpp @@ -51,6 +51,7 @@ #include "filesystem.h" #include "vm.h" #include "g_levellocals.h" +#include "d_main.h" IMPLEMENT_CLASS(DBot, false, true) diff --git a/src/playsim/p_interaction.cpp b/src/playsim/p_interaction.cpp index da0d6a72f..2c89e3cc1 100644 --- a/src/playsim/p_interaction.cpp +++ b/src/playsim/p_interaction.cpp @@ -61,6 +61,7 @@ #include "g_levellocals.h" #include "events.h" #include "actorinlines.h" +#include "d_main.h" static FRandom pr_botrespawn ("BotRespawn"); static FRandom pr_killmobj ("ActorDie"); diff --git a/src/rendering/r_utility.cpp b/src/rendering/r_utility.cpp index f1a74671b..c87db0e26 100644 --- a/src/rendering/r_utility.cpp +++ b/src/rendering/r_utility.cpp @@ -65,6 +65,7 @@ #include "g_game.h" #include "i_system.h" #include "v_draw.h" +#include "i_interface.h" // EXTERNAL DATA DECLARATIONS ---------------------------------------------- diff --git a/src/rendering/swrenderer/things/r_particle.cpp b/src/rendering/swrenderer/things/r_particle.cpp index 3986a8b2d..23a859c0e 100644 --- a/src/rendering/swrenderer/things/r_particle.cpp +++ b/src/rendering/swrenderer/things/r_particle.cpp @@ -26,6 +26,7 @@ #include "doomdef.h" #include "m_swap.h" +#include "i_interface.h" #include "filesystem.h" #include "c_console.h" diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index d70318e60..fc0d0d6d8 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -71,8 +71,6 @@ FBoolCVar noisedebug("noise", false, 0); // [RH] Print sound debugging info? -CVAR (Bool, i_soundinbackground, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Bool, i_pauseinbackground, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) static FString LastLocalSndInfo; @@ -922,52 +920,6 @@ void S_SerializeSounds(FSerializer &arc) GSnd->UpdateSounds(); } -//========================================================================== -// -// S_SetSoundPaused -// -// Called with state non-zero when the app is active, zero when it isn't. -// -//========================================================================== - -void S_SetSoundPaused(int state) -{ - if (!netgame && (i_pauseinbackground) -#ifdef _DEBUG - && !demoplayback -#endif - ) - { - pauseext = !state; - } - - if ((state || i_soundinbackground) && !pauseext) - { - if (paused == 0) - { - S_ResumeSound(true); - if (GSnd != nullptr) - { - GSnd->SetInactive(SoundRenderer::INACTIVE_Active); - } - } - } - else - { - if (paused == 0) - { - S_PauseSound(false, true); - if (GSnd != nullptr) - { - GSnd->SetInactive(gamestate == GS_LEVEL || gamestate == GS_TITLELEVEL ? - SoundRenderer::INACTIVE_Complete : - SoundRenderer::INACTIVE_Mute); - } - } - } -} - - //========================================================================== // // CalcSectorSoundOrg @@ -1475,111 +1427,3 @@ CCMD (loopsound) } } -//========================================================================== -// -// CCMD cachesound -// -//========================================================================== - -CCMD (cachesound) -{ - if (argv.argc() < 2) - { - Printf ("Usage: cachesound ...\n"); - return; - } - for (int i = 1; i < argv.argc(); ++i) - { - FSoundID sfxnum = argv[i]; - if (sfxnum != FSoundID(0)) - { - soundEngine->CacheSound(sfxnum); - } - } -} - - -CCMD(listsoundchannels) -{ - Printf("%s", soundEngine->ListSoundChannels().GetChars()); -} - -// intentionally moved here to keep the s_music include out of the rest of the file. - -//========================================================================== -// -// S_PauseSound -// -// Stop music and sound effects, during game PAUSE. -//========================================================================== -#include "s_music.h" - -void S_PauseSound (bool notmusic, bool notsfx) -{ - if (!notmusic) - { - S_PauseMusic(); - } - if (!notsfx) - { - soundEngine->SetPaused(true); - GSnd->SetSfxPaused (true, 0); - } -} - -DEFINE_ACTION_FUNCTION(DObject, S_PauseSound) -{ - PARAM_PROLOGUE; - PARAM_BOOL(notmusic); - PARAM_BOOL(notsfx); - S_PauseSound(notmusic, notsfx); - return 0; -} - -//========================================================================== -// -// S_ResumeSound -// -// Resume music and sound effects, after game PAUSE. -//========================================================================== - -void S_ResumeSound (bool notsfx) -{ - S_ResumeMusic(); - if (!notsfx) - { - soundEngine->SetPaused(false); - GSnd->SetSfxPaused (false, 0); - } -} - -DEFINE_ACTION_FUNCTION(DObject, S_ResumeSound) -{ - PARAM_PROLOGUE; - PARAM_BOOL(notsfx); - S_ResumeSound(notsfx); - return 0; -} - - -CCMD (snd_status) -{ - GSnd->PrintStatus (); -} - -CCMD (snd_reset) -{ - S_SoundReset(); -} - -CCMD (snd_listdrivers) -{ - GSnd->PrintDriversList (); -} - -ADD_STAT (sound) -{ - return GSnd->GatherStats (); -} - - diff --git a/src/sound/s_sndseq.cpp b/src/sound/s_sndseq.cpp index 9182575da..5c9761d36 100644 --- a/src/sound/s_sndseq.cpp +++ b/src/sound/s_sndseq.cpp @@ -34,6 +34,7 @@ #include "po_man.h" #include "gi.h" #include "c_dispatch.h" +#include "i_interface.h" #include "g_level.h" #include "serializer_doom.h" diff --git a/src/st_stuff.cpp b/src/st_stuff.cpp index 59e28d590..d9fe13bc2 100644 --- a/src/st_stuff.cpp +++ b/src/st_stuff.cpp @@ -35,6 +35,7 @@ #include "doomstat.h" #include "g_level.h" #include "g_levellocals.h" +#include "d_main.h" EXTERN_CVAR (Bool, ticker); EXTERN_CVAR (Bool, noisedebug);