mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2025-01-31 04:30:39 +00:00
Added default generated tone for missing sounds when cvar s_defaultsound is enabled.
Const-ified functions in cl_download.c.
This commit is contained in:
parent
c18c245fe2
commit
9753f5f98c
6 changed files with 56 additions and 14 deletions
|
@ -699,7 +699,7 @@ void CL_RequestNextDownload (void)
|
||||||
CL_DownloadFileName
|
CL_DownloadFileName
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void CL_DownloadFileName (char *dest, int destlen, char *fn)
|
void CL_DownloadFileName (char *dest, int destlen, const char *fn)
|
||||||
{
|
{
|
||||||
if ( !stricmp(FS_Downloaddir(), FS_Gamedir()) ) // use basedir/gamedir if fs_downloaddir is the same as fs_gamedir
|
if ( !stricmp(FS_Downloaddir(), FS_Gamedir()) ) // use basedir/gamedir if fs_downloaddir is the same as fs_gamedir
|
||||||
{
|
{
|
||||||
|
@ -739,7 +739,7 @@ void CL_InitFailedDownloadList (void)
|
||||||
CL_CheckDownloadFailed
|
CL_CheckDownloadFailed
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
qboolean CL_CheckDownloadFailed (char *name)
|
qboolean CL_CheckDownloadFailed (const char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -758,7 +758,7 @@ qboolean CL_CheckDownloadFailed (char *name)
|
||||||
CL_AddToFailedDownloadList
|
CL_AddToFailedDownloadList
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void CL_AddToFailedDownloadList (char *name)
|
void CL_AddToFailedDownloadList (const char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
qboolean found = false;
|
qboolean found = false;
|
||||||
|
@ -792,7 +792,7 @@ Returns true if the file exists, otherwise it attempts
|
||||||
to start a download from the server.
|
to start a download from the server.
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
qboolean CL_CheckOrDownloadFile (char *filename)
|
qboolean CL_CheckOrDownloadFile (const char *filename)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char name[MAX_OSPATH];
|
char name[MAX_OSPATH];
|
||||||
|
|
|
@ -887,7 +887,7 @@ void CL_ParseClientinfo (int player);
|
||||||
//
|
//
|
||||||
void CL_ResetPrecacheCheck (void);
|
void CL_ResetPrecacheCheck (void);
|
||||||
void CL_RequestNextDownload (void);
|
void CL_RequestNextDownload (void);
|
||||||
qboolean CL_CheckOrDownloadFile (char *filename);
|
qboolean CL_CheckOrDownloadFile (const char *filename);
|
||||||
void CL_Download_f (void);
|
void CL_Download_f (void);
|
||||||
void CL_ParseDownload (void);
|
void CL_ParseDownload (void);
|
||||||
void CL_Download_Reset_KBps_counter (void);
|
void CL_Download_Reset_KBps_counter (void);
|
||||||
|
|
|
@ -81,6 +81,7 @@ cvar_t *s_khz;
|
||||||
cvar_t *s_show;
|
cvar_t *s_show;
|
||||||
cvar_t *s_mixahead;
|
cvar_t *s_mixahead;
|
||||||
cvar_t *s_primary;
|
cvar_t *s_primary;
|
||||||
|
cvar_t *s_usedefaultsound; // Knightmare added
|
||||||
#ifdef OGG_SUPPORT
|
#ifdef OGG_SUPPORT
|
||||||
cvar_t *s_musicvolume;
|
cvar_t *s_musicvolume;
|
||||||
#endif
|
#endif
|
||||||
|
@ -145,6 +146,8 @@ void S_Init (void)
|
||||||
Cvar_SetDescription ("s_testsound", "Enables generated test sound.");
|
Cvar_SetDescription ("s_testsound", "Enables generated test sound.");
|
||||||
s_primary = Cvar_Get ("s_primary", "0", CVAR_ARCHIVE); // win32 specific
|
s_primary = Cvar_Get ("s_primary", "0", CVAR_ARCHIVE); // win32 specific
|
||||||
Cvar_SetDescription ("s_primary", "Enables primary sound buffer. Set to 1 for better performance, or 0 for improved compatibility.");
|
Cvar_SetDescription ("s_primary", "Enables primary sound buffer. Set to 1 for better performance, or 0 for improved compatibility.");
|
||||||
|
s_usedefaultsound = Cvar_Get ("s_usedefaultsound", "0", CVAR_ARCHIVE); // Knightmare added
|
||||||
|
Cvar_SetDescription ("s_usedefaultsound", "Enables use of a default generated tone when a sound file can't be loaded.");
|
||||||
#ifdef OGG_SUPPORT
|
#ifdef OGG_SUPPORT
|
||||||
s_musicvolume = Cvar_Get ("s_musicvolume", "1.0", CVAR_ARCHIVE); // Q2E
|
s_musicvolume = Cvar_Get ("s_musicvolume", "1.0", CVAR_ARCHIVE); // Q2E
|
||||||
Cvar_SetDescription ("s_musicvolume", "Sets the music volume (normalized). 0 = mute, 1.0 = max.");
|
Cvar_SetDescription ("s_musicvolume", "Sets the music volume (normalized). 0 = mute, 1.0 = max.");
|
||||||
|
|
|
@ -183,6 +183,7 @@ extern cvar_t *s_show;
|
||||||
extern cvar_t *s_mixahead;
|
extern cvar_t *s_mixahead;
|
||||||
extern cvar_t *s_testsound;
|
extern cvar_t *s_testsound;
|
||||||
extern cvar_t *s_primary;
|
extern cvar_t *s_primary;
|
||||||
|
extern cvar_t *s_usedefaultsound; // Knightmare added
|
||||||
#ifdef OGG_SUPPORT
|
#ifdef OGG_SUPPORT
|
||||||
extern cvar_t *s_musicvolume; // Q2E
|
extern cvar_t *s_musicvolume; // Q2E
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -271,6 +271,33 @@ void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
S_CreateDefaultSound
|
||||||
|
==============
|
||||||
|
*/
|
||||||
|
void S_CreateDefaultSound (byte **wav, wavinfo_t *info)
|
||||||
|
{
|
||||||
|
byte *out;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!info || !wav) // catch null pointers
|
||||||
|
return;
|
||||||
|
|
||||||
|
info->rate = 22050;
|
||||||
|
info->width = 2;
|
||||||
|
info->channels = 1;
|
||||||
|
info->samples = 11025;
|
||||||
|
info->loopstart = -1;
|
||||||
|
info->dataofs = 0;
|
||||||
|
|
||||||
|
*wav = out = Z_Malloc(info->samples * info->width);
|
||||||
|
|
||||||
|
for (i = 0; i < info->samples; i++)
|
||||||
|
((short *)out)[i] = sin(i * 0.1) * 20000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
S_LoadSound
|
S_LoadSound
|
||||||
|
@ -278,14 +305,14 @@ S_LoadSound
|
||||||
*/
|
*/
|
||||||
sfxcache_t *S_LoadSound (sfx_t *s)
|
sfxcache_t *S_LoadSound (sfx_t *s)
|
||||||
{
|
{
|
||||||
char namebuffer[MAX_QPATH];
|
char namebuffer[MAX_QPATH];
|
||||||
byte *data;
|
byte *data;
|
||||||
wavinfo_t info;
|
wavinfo_t info;
|
||||||
int len;
|
int len;
|
||||||
float stepscale;
|
float stepscale;
|
||||||
sfxcache_t *sc;
|
sfxcache_t *sc;
|
||||||
int size;
|
int size;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (s->name[0] == '*')
|
if (s->name[0] == '*')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -313,8 +340,19 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
{
|
{
|
||||||
Com_DPrintf ("Couldn't load %s\n", namebuffer);
|
if (s_usedefaultsound->integer)
|
||||||
return NULL;
|
{
|
||||||
|
Com_Printf (S_COLOR_YELLOW"S_LoadSound: Couldn't load %s, generating default sound.\n", namebuffer);
|
||||||
|
S_CreateDefaultSound (&data, &info);
|
||||||
|
if (!data) {
|
||||||
|
Com_Printf ("S_LoadSound: Couldn't generate default sound for %s, returning NULL.\n", namebuffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Com_DPrintf ("Couldn't load %s\n", namebuffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info = GetWavinfo (s->name, data, size);
|
info = GetWavinfo (s->name, data, size);
|
||||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "../game/q_shared.h"
|
#include "../game/q_shared.h"
|
||||||
|
|
||||||
#define VERSION 0.20 // was 3.21
|
#define VERSION 0.20 // was 3.21
|
||||||
#define VERSION_UPDATE 8
|
#define VERSION_UPDATE 8
|
||||||
|
|
||||||
#define BASEDIRNAME "baseq2"
|
#define BASEDIRNAME "baseq2"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue