mirror of
https://github.com/blendogames/thirtyflightsofloving.git
synced 2024-11-14 08:31:04 +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
|
||||
===============
|
||||
*/
|
||||
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
|
||||
{
|
||||
|
@ -739,7 +739,7 @@ void CL_InitFailedDownloadList (void)
|
|||
CL_CheckDownloadFailed
|
||||
===============
|
||||
*/
|
||||
qboolean CL_CheckDownloadFailed (char *name)
|
||||
qboolean CL_CheckDownloadFailed (const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -758,7 +758,7 @@ qboolean CL_CheckDownloadFailed (char *name)
|
|||
CL_AddToFailedDownloadList
|
||||
===============
|
||||
*/
|
||||
void CL_AddToFailedDownloadList (char *name)
|
||||
void CL_AddToFailedDownloadList (const char *name)
|
||||
{
|
||||
int i;
|
||||
qboolean found = false;
|
||||
|
@ -792,7 +792,7 @@ Returns true if the file exists, otherwise it attempts
|
|||
to start a download from the server.
|
||||
===============
|
||||
*/
|
||||
qboolean CL_CheckOrDownloadFile (char *filename)
|
||||
qboolean CL_CheckOrDownloadFile (const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
char name[MAX_OSPATH];
|
||||
|
|
|
@ -887,7 +887,7 @@ void CL_ParseClientinfo (int player);
|
|||
//
|
||||
void CL_ResetPrecacheCheck (void);
|
||||
void CL_RequestNextDownload (void);
|
||||
qboolean CL_CheckOrDownloadFile (char *filename);
|
||||
qboolean CL_CheckOrDownloadFile (const char *filename);
|
||||
void CL_Download_f (void);
|
||||
void CL_ParseDownload (void);
|
||||
void CL_Download_Reset_KBps_counter (void);
|
||||
|
|
|
@ -81,6 +81,7 @@ cvar_t *s_khz;
|
|||
cvar_t *s_show;
|
||||
cvar_t *s_mixahead;
|
||||
cvar_t *s_primary;
|
||||
cvar_t *s_usedefaultsound; // Knightmare added
|
||||
#ifdef OGG_SUPPORT
|
||||
cvar_t *s_musicvolume;
|
||||
#endif
|
||||
|
@ -145,6 +146,8 @@ void S_Init (void)
|
|||
Cvar_SetDescription ("s_testsound", "Enables generated test sound.");
|
||||
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.");
|
||||
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
|
||||
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.");
|
||||
|
|
|
@ -183,6 +183,7 @@ extern cvar_t *s_show;
|
|||
extern cvar_t *s_mixahead;
|
||||
extern cvar_t *s_testsound;
|
||||
extern cvar_t *s_primary;
|
||||
extern cvar_t *s_usedefaultsound; // Knightmare added
|
||||
#ifdef OGG_SUPPORT
|
||||
extern cvar_t *s_musicvolume; // Q2E
|
||||
#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
|
||||
|
@ -278,14 +305,14 @@ S_LoadSound
|
|||
*/
|
||||
sfxcache_t *S_LoadSound (sfx_t *s)
|
||||
{
|
||||
char namebuffer[MAX_QPATH];
|
||||
byte *data;
|
||||
char namebuffer[MAX_QPATH];
|
||||
byte *data;
|
||||
wavinfo_t info;
|
||||
int len;
|
||||
float stepscale;
|
||||
int len;
|
||||
float stepscale;
|
||||
sfxcache_t *sc;
|
||||
int size;
|
||||
char *name;
|
||||
int size;
|
||||
char *name;
|
||||
|
||||
if (s->name[0] == '*')
|
||||
return NULL;
|
||||
|
@ -313,8 +340,19 @@ sfxcache_t *S_LoadSound (sfx_t *s)
|
|||
|
||||
if (!data)
|
||||
{
|
||||
Com_DPrintf ("Couldn't load %s\n", namebuffer);
|
||||
return NULL;
|
||||
if (s_usedefaultsound->integer)
|
||||
{
|
||||
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);
|
||||
|
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "../game/q_shared.h"
|
||||
|
||||
#define VERSION 0.20 // was 3.21
|
||||
#define VERSION_UPDATE 8
|
||||
#define VERSION_UPDATE 8
|
||||
|
||||
#define BASEDIRNAME "baseq2"
|
||||
|
||||
|
|
Loading…
Reference in a new issue