mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 21:01:04 +00:00
Merge branch 'music-clean' into 'master'
Some code cleanup. See merge request STJr/SRB2!298
This commit is contained in:
commit
f974bb96ac
4 changed files with 96 additions and 99 deletions
|
@ -128,8 +128,6 @@ FUNCNORETURN static ATTRNORETURN void Command_Quit_f(void);
|
||||||
static void Command_Playintro_f(void);
|
static void Command_Playintro_f(void);
|
||||||
|
|
||||||
static void Command_Displayplayer_f(void);
|
static void Command_Displayplayer_f(void);
|
||||||
static void Command_Tunes_f(void);
|
|
||||||
static void Command_RestartAudio_f(void);
|
|
||||||
|
|
||||||
static void Command_ExitLevel_f(void);
|
static void Command_ExitLevel_f(void);
|
||||||
static void Command_Showmap_f(void);
|
static void Command_Showmap_f(void);
|
||||||
|
@ -319,7 +317,6 @@ consvar_t cv_overtime = {"overtime", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL,
|
||||||
consvar_t cv_rollingdemos = {"rollingdemos", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_rollingdemos = {"rollingdemos", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
consvar_t cv_timetic = {"timerres", "Normal", CV_SAVE, timetic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // use tics in display
|
consvar_t cv_timetic = {"timerres", "Normal", CV_SAVE, timetic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // use tics in display
|
||||||
consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
|
||||||
|
|
||||||
static CV_PossibleValue_t pointlimit_cons_t[] = {{0, "MIN"}, {999999990, "MAX"}, {0, NULL}};
|
static CV_PossibleValue_t pointlimit_cons_t[] = {{0, "MIN"}, {999999990, "MAX"}, {0, NULL}};
|
||||||
consvar_t cv_pointlimit = {"pointlimit", "0", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t,
|
consvar_t cv_pointlimit = {"pointlimit", "0", CV_NETVAR|CV_CALL|CV_NOINIT, pointlimit_cons_t,
|
||||||
|
@ -668,9 +665,6 @@ void D_RegisterClientCommands(void)
|
||||||
CV_RegisterVar(&cv_ghost_guest);
|
CV_RegisterVar(&cv_ghost_guest);
|
||||||
|
|
||||||
COM_AddCommand("displayplayer", Command_Displayplayer_f);
|
COM_AddCommand("displayplayer", Command_Displayplayer_f);
|
||||||
COM_AddCommand("tunes", Command_Tunes_f);
|
|
||||||
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
|
||||||
CV_RegisterVar(&cv_resetmusic);
|
|
||||||
|
|
||||||
// FIXME: not to be here.. but needs be done for config loading
|
// FIXME: not to be here.. but needs be done for config loading
|
||||||
CV_RegisterVar(&cv_usegamma);
|
CV_RegisterVar(&cv_usegamma);
|
||||||
|
@ -3881,94 +3875,6 @@ static void Command_Displayplayer_f(void)
|
||||||
CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayer);
|
CONS_Printf(M_GetText("Displayplayer is %d\n"), displayplayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Command_Tunes_f(void)
|
|
||||||
{
|
|
||||||
const char *tunearg;
|
|
||||||
UINT16 tunenum, track = 0;
|
|
||||||
const size_t argc = COM_Argc();
|
|
||||||
|
|
||||||
if (argc < 2) //tunes slot ...
|
|
||||||
{
|
|
||||||
CONS_Printf("tunes <name/num> [track] [speed] / <-show> / <-default> / <-none>:\n");
|
|
||||||
CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n"));
|
|
||||||
CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n"));
|
|
||||||
CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n"));
|
|
||||||
CONS_Printf(M_GetText("* With \"-default\", returns to the default music for the map.\n"));
|
|
||||||
CONS_Printf(M_GetText("* With \"-none\", any music playing will be stopped.\n"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tunearg = COM_Argv(1);
|
|
||||||
tunenum = (UINT16)atoi(tunearg);
|
|
||||||
track = 0;
|
|
||||||
|
|
||||||
if (!strcasecmp(tunearg, "-show"))
|
|
||||||
{
|
|
||||||
CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"),
|
|
||||||
mapmusname, (mapmusflags & MUSIC_TRACKMASK));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!strcasecmp(tunearg, "-none"))
|
|
||||||
{
|
|
||||||
S_StopMusic();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!strcasecmp(tunearg, "-default"))
|
|
||||||
{
|
|
||||||
tunearg = mapheaderinfo[gamemap-1]->musname;
|
|
||||||
track = mapheaderinfo[gamemap-1]->mustrack;
|
|
||||||
}
|
|
||||||
else if (!tunearg[2] && toupper(tunearg[0]) >= 'A' && toupper(tunearg[0]) <= 'Z')
|
|
||||||
tunenum = (UINT16)M_MapNumber(tunearg[0], tunearg[1]);
|
|
||||||
|
|
||||||
if (tunenum && tunenum >= 1036)
|
|
||||||
{
|
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("Valid music slots are 1 to 1035.\n"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!tunenum && strlen(tunearg) > 6) // This is automatic -- just show the error just in case
|
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("Music name too long - truncated to six characters.\n"));
|
|
||||||
|
|
||||||
if (argc > 2)
|
|
||||||
track = (UINT16)atoi(COM_Argv(2))-1;
|
|
||||||
|
|
||||||
if (tunenum)
|
|
||||||
snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum));
|
|
||||||
else
|
|
||||||
strncpy(mapmusname, tunearg, 7);
|
|
||||||
mapmusname[6] = 0;
|
|
||||||
mapmusflags = (track & MUSIC_TRACKMASK);
|
|
||||||
|
|
||||||
S_ChangeMusic(mapmusname, mapmusflags, true);
|
|
||||||
|
|
||||||
if (argc > 3)
|
|
||||||
{
|
|
||||||
float speed = (float)atof(COM_Argv(3));
|
|
||||||
if (speed > 0.0f)
|
|
||||||
S_SpeedMusic(speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Command_RestartAudio_f(void)
|
|
||||||
{
|
|
||||||
if (dedicated) // No point in doing anything if game is a dedicated server.
|
|
||||||
return;
|
|
||||||
|
|
||||||
S_StopMusic();
|
|
||||||
S_StopSounds();
|
|
||||||
I_ShutdownMusic();
|
|
||||||
I_ShutdownSound();
|
|
||||||
I_StartupSound();
|
|
||||||
I_InitMusic();
|
|
||||||
|
|
||||||
// These must be called or no sound and music until manually set.
|
|
||||||
|
|
||||||
I_SetSfxVolume(cv_soundvolume.value);
|
|
||||||
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
|
|
||||||
if (Playing()) // Gotta make sure the player is in a level
|
|
||||||
P_RestoreMusic(&players[consoleplayer]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Quits a game and returns to the title screen.
|
/** Quits a game and returns to the title screen.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -99,8 +99,6 @@ extern consvar_t cv_startinglives;
|
||||||
// for F_finale.c
|
// for F_finale.c
|
||||||
extern consvar_t cv_rollingdemos;
|
extern consvar_t cv_rollingdemos;
|
||||||
|
|
||||||
extern consvar_t cv_resetmusic;
|
|
||||||
|
|
||||||
extern consvar_t cv_ringslinger, cv_soundtest;
|
extern consvar_t cv_ringslinger, cv_soundtest;
|
||||||
|
|
||||||
extern consvar_t cv_specialrings, cv_powerstones, cv_matchboxes, cv_competitionboxes;
|
extern consvar_t cv_specialrings, cv_powerstones, cv_matchboxes, cv_competitionboxes;
|
||||||
|
@ -198,6 +196,4 @@ void D_SetPassword(const char *pw);
|
||||||
// used for the player setup menu
|
// used for the player setup menu
|
||||||
UINT8 CanChangeSkin(INT32 playernum);
|
UINT8 CanChangeSkin(INT32 playernum);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ extern INT32 msg_id;
|
||||||
#include "d_main.h"
|
#include "d_main.h"
|
||||||
#include "r_sky.h" // skyflatnum
|
#include "r_sky.h" // skyflatnum
|
||||||
#include "p_local.h" // camera info
|
#include "p_local.h" // camera info
|
||||||
|
#include "m_misc.h" // for tunes command
|
||||||
|
|
||||||
#ifdef HW3SOUND
|
#ifdef HW3SOUND
|
||||||
// 3D Sound Interface
|
// 3D Sound Interface
|
||||||
|
@ -46,6 +47,8 @@ static INT32 S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, I
|
||||||
|
|
||||||
CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}};
|
CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}};
|
||||||
static void SetChannelsNum(void);
|
static void SetChannelsNum(void);
|
||||||
|
static void Command_Tunes_f(void);
|
||||||
|
static void Command_RestartAudio_f(void);
|
||||||
|
|
||||||
// commands for music and sound servers
|
// commands for music and sound servers
|
||||||
#ifdef MUSSERV
|
#ifdef MUSSERV
|
||||||
|
@ -89,6 +92,7 @@ consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
#define S_MAX_VOLUME 127
|
#define S_MAX_VOLUME 127
|
||||||
|
|
||||||
|
@ -243,6 +247,11 @@ void S_RegisterSoundStuff(void)
|
||||||
#endif
|
#endif
|
||||||
CV_RegisterVar(&surround);
|
CV_RegisterVar(&surround);
|
||||||
CV_RegisterVar(&cv_samplerate);
|
CV_RegisterVar(&cv_samplerate);
|
||||||
|
CV_RegisterVar(&cv_resetmusic);
|
||||||
|
|
||||||
|
COM_AddCommand("tunes", Command_Tunes_f);
|
||||||
|
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
||||||
|
|
||||||
|
|
||||||
#if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff
|
#if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff
|
||||||
{
|
{
|
||||||
|
@ -1503,3 +1512,88 @@ void S_Start(void)
|
||||||
S_StopMusic();
|
S_StopMusic();
|
||||||
S_ChangeMusic(mapmusname, mapmusflags, true);
|
S_ChangeMusic(mapmusname, mapmusflags, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Command_Tunes_f(void)
|
||||||
|
{
|
||||||
|
const char *tunearg;
|
||||||
|
UINT16 tunenum, track = 0;
|
||||||
|
const size_t argc = COM_Argc();
|
||||||
|
|
||||||
|
if (argc < 2) //tunes slot ...
|
||||||
|
{
|
||||||
|
CONS_Printf("tunes <name/num> [track] [speed] / <-show> / <-default> / <-none>:\n");
|
||||||
|
CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n"));
|
||||||
|
CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n"));
|
||||||
|
CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n"));
|
||||||
|
CONS_Printf(M_GetText("* With \"-default\", returns to the default music for the map.\n"));
|
||||||
|
CONS_Printf(M_GetText("* With \"-none\", any music playing will be stopped.\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tunearg = COM_Argv(1);
|
||||||
|
tunenum = (UINT16)atoi(tunearg);
|
||||||
|
track = 0;
|
||||||
|
|
||||||
|
if (!strcasecmp(tunearg, "-show"))
|
||||||
|
{
|
||||||
|
CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"),
|
||||||
|
mapmusname, (mapmusflags & MUSIC_TRACKMASK));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!strcasecmp(tunearg, "-none"))
|
||||||
|
{
|
||||||
|
S_StopMusic();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!strcasecmp(tunearg, "-default"))
|
||||||
|
{
|
||||||
|
tunearg = mapheaderinfo[gamemap-1]->musname;
|
||||||
|
track = mapheaderinfo[gamemap-1]->mustrack;
|
||||||
|
}
|
||||||
|
else if (!tunearg[2] && toupper(tunearg[0]) >= 'A' && toupper(tunearg[0]) <= 'Z')
|
||||||
|
tunenum = (UINT16)M_MapNumber(tunearg[0], tunearg[1]);
|
||||||
|
|
||||||
|
if (tunenum && tunenum >= 1036)
|
||||||
|
{
|
||||||
|
CONS_Alert(CONS_NOTICE, M_GetText("Valid music slots are 1 to 1035.\n"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!tunenum && strlen(tunearg) > 6) // This is automatic -- just show the error just in case
|
||||||
|
CONS_Alert(CONS_NOTICE, M_GetText("Music name too long - truncated to six characters.\n"));
|
||||||
|
|
||||||
|
if (argc > 2)
|
||||||
|
track = (UINT16)atoi(COM_Argv(2))-1;
|
||||||
|
|
||||||
|
if (tunenum)
|
||||||
|
snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum));
|
||||||
|
else
|
||||||
|
strncpy(mapmusname, tunearg, 7);
|
||||||
|
mapmusname[6] = 0;
|
||||||
|
mapmusflags = (track & MUSIC_TRACKMASK);
|
||||||
|
|
||||||
|
S_ChangeMusic(mapmusname, mapmusflags, true);
|
||||||
|
|
||||||
|
if (argc > 3)
|
||||||
|
{
|
||||||
|
float speed = (float)atof(COM_Argv(3));
|
||||||
|
if (speed > 0.0f)
|
||||||
|
S_SpeedMusic(speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Command_RestartAudio_f(void)
|
||||||
|
{
|
||||||
|
S_StopMusic();
|
||||||
|
S_StopSounds();
|
||||||
|
I_ShutdownMusic();
|
||||||
|
I_ShutdownSound();
|
||||||
|
I_StartupSound();
|
||||||
|
I_InitMusic();
|
||||||
|
|
||||||
|
// These must be called or no sound and music until manually set.
|
||||||
|
|
||||||
|
I_SetSfxVolume(cv_soundvolume.value);
|
||||||
|
S_SetMusicVolume(cv_digmusicvolume.value, cv_midimusicvolume.value);
|
||||||
|
if (Playing()) // Gotta make sure the player is in a level
|
||||||
|
P_RestoreMusic(&players[consoleplayer]);
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
extern consvar_t stereoreverse;
|
extern consvar_t stereoreverse;
|
||||||
extern consvar_t cv_soundvolume, cv_digmusicvolume, cv_midimusicvolume;
|
extern consvar_t cv_soundvolume, cv_digmusicvolume, cv_midimusicvolume;
|
||||||
extern consvar_t cv_numChannels;
|
extern consvar_t cv_numChannels;
|
||||||
|
extern consvar_t cv_resetmusic;
|
||||||
|
|
||||||
#ifdef SNDSERV
|
#ifdef SNDSERV
|
||||||
extern consvar_t sndserver_cmd, sndserver_arg;
|
extern consvar_t sndserver_cmd, sndserver_arg;
|
||||||
|
|
Loading…
Reference in a new issue