diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/cl_cgame.c | 10 | ||||
-rw-r--r-- | src/client/cl_curl.c | 8 | ||||
-rw-r--r-- | src/client/cl_keys.c | 126 | ||||
-rw-r--r-- | src/client/cl_main.c | 89 | ||||
-rw-r--r-- | src/client/cl_parse.c | 4 | ||||
-rw-r--r-- | src/client/cl_ui.c | 10 | ||||
-rw-r--r-- | src/client/client.h | 4 | ||||
-rw-r--r-- | src/client/keycodes.h | 111 | ||||
-rw-r--r-- | src/client/keys.h | 2 | ||||
-rw-r--r-- | src/client/qal.c | 2 | ||||
-rw-r--r-- | src/client/snd_dma.c | 12 | ||||
-rw-r--r-- | src/client/snd_openal.c | 26 |
12 files changed, 347 insertions, 57 deletions
diff --git a/src/client/cl_cgame.c b/src/client/cl_cgame.c index 262f6b47..b2fafe08 100644 --- a/src/client/cl_cgame.c +++ b/src/client/cl_cgame.c @@ -413,10 +413,10 @@ The cgame module is making a system call intptr_t CL_CgameSystemCalls( intptr_t *args ) { switch( args[0] ) { case CG_PRINT: - Com_Printf( "%s", VMA(1) ); + Com_Printf( "%s", (const char*)VMA(1) ); return 0; case CG_ERROR: - Com_Error( ERR_DROP, "%s", VMA(1) ); + Com_Error( ERR_DROP, "%s", (const char*)VMA(1) ); return 0; case CG_MILLISECONDS: return Sys_Milliseconds(); @@ -726,7 +726,7 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) { default: assert(0); // bk010102 - Com_Error( ERR_DROP, "Bad cgame system trap: %i", args[0] ); + Com_Error( ERR_DROP, "Bad cgame system trap: %ld", (long int) args[0] ); } return 0; } @@ -774,6 +774,10 @@ void CL_InitCGame( void ) { // otherwise server commands sent just before a gamestate are dropped VM_Call( cgvm, CG_INIT, clc.serverMessageSequence, clc.lastExecutedServerCommand, clc.clientNum ); + // reset any CVAR_CHEAT cvars registered by cgame + if ( !cl_connectedToCheatServer ) + Cvar_SetCheatState(); + // we will send a usercmd this frame, which // will cause the server to send us the first snapshot cls.state = CA_PRIMED; diff --git a/src/client/cl_curl.c b/src/client/cl_curl.c index 246095a1..734cc306 100644 --- a/src/client/cl_curl.c +++ b/src/client/cl_curl.c @@ -105,7 +105,7 @@ static void *GPA(char *str) } else { - Com_DPrintf("Loaded symbol %s (0x%08X)\n", str, rv); + Com_DPrintf("Loaded symbol %s (0x%p)\n", str, rv); return rv; } } @@ -131,8 +131,8 @@ qboolean CL_cURL_Init() #else char fn[1024]; getcwd(fn, sizeof(fn)); - strncat(fn, "/", sizeof(fn)); - strncat(fn, cl_cURLLib->string, sizeof(fn)); + strncat(fn, "/", sizeof(fn)-strlen(fn)-1); + strncat(fn, cl_cURLLib->string, sizeof(fn)-strlen(fn)-1); if( (cURLLib = OBJLOAD(fn)) == 0 ) { @@ -347,7 +347,7 @@ void CL_cURL_PerformDownload(void) qcurl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &code); - Com_Error(ERR_DROP, "Download Error: %s Code: %d URL: %s", + Com_Error(ERR_DROP, "Download Error: %s Code: %ld URL: %s", qcurl_easy_strerror(msg->data.result), code, clc.downloadURL); } diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c index c65ce916..c768e743 100644 --- a/src/client/cl_keys.c +++ b/src/client/cl_keys.c @@ -87,6 +87,9 @@ keyname_t keynames[] = {"F10", K_F10}, {"F11", K_F11}, {"F12", K_F12}, + {"F13", K_F13}, + {"F14", K_F14}, + {"F15", K_F15}, {"INS", K_INS}, {"DEL", K_DEL}, @@ -177,6 +180,116 @@ keyname_t keynames[] = {"SEMICOLON", ';'}, // because a raw semicolon seperates commands + {"WORLD_0", K_WORLD_0}, + {"WORLD_1", K_WORLD_1}, + {"WORLD_2", K_WORLD_2}, + {"WORLD_3", K_WORLD_3}, + {"WORLD_4", K_WORLD_4}, + {"WORLD_5", K_WORLD_5}, + {"WORLD_6", K_WORLD_6}, + {"WORLD_7", K_WORLD_7}, + {"WORLD_8", K_WORLD_8}, + {"WORLD_9", K_WORLD_9}, + {"WORLD_10", K_WORLD_10}, + {"WORLD_11", K_WORLD_11}, + {"WORLD_12", K_WORLD_12}, + {"WORLD_13", K_WORLD_13}, + {"WORLD_14", K_WORLD_14}, + {"WORLD_15", K_WORLD_15}, + {"WORLD_16", K_WORLD_16}, + {"WORLD_17", K_WORLD_17}, + {"WORLD_18", K_WORLD_18}, + {"WORLD_19", K_WORLD_19}, + {"WORLD_20", K_WORLD_20}, + {"WORLD_21", K_WORLD_21}, + {"WORLD_22", K_WORLD_22}, + {"WORLD_23", K_WORLD_23}, + {"WORLD_24", K_WORLD_24}, + {"WORLD_25", K_WORLD_25}, + {"WORLD_26", K_WORLD_26}, + {"WORLD_27", K_WORLD_27}, + {"WORLD_28", K_WORLD_28}, + {"WORLD_29", K_WORLD_29}, + {"WORLD_30", K_WORLD_30}, + {"WORLD_31", K_WORLD_31}, + {"WORLD_32", K_WORLD_32}, + {"WORLD_33", K_WORLD_33}, + {"WORLD_34", K_WORLD_34}, + {"WORLD_35", K_WORLD_35}, + {"WORLD_36", K_WORLD_36}, + {"WORLD_37", K_WORLD_37}, + {"WORLD_38", K_WORLD_38}, + {"WORLD_39", K_WORLD_39}, + {"WORLD_40", K_WORLD_40}, + {"WORLD_41", K_WORLD_41}, + {"WORLD_42", K_WORLD_42}, + {"WORLD_43", K_WORLD_43}, + {"WORLD_44", K_WORLD_44}, + {"WORLD_45", K_WORLD_45}, + {"WORLD_46", K_WORLD_46}, + {"WORLD_47", K_WORLD_47}, + {"WORLD_48", K_WORLD_48}, + {"WORLD_49", K_WORLD_49}, + {"WORLD_50", K_WORLD_50}, + {"WORLD_51", K_WORLD_51}, + {"WORLD_52", K_WORLD_52}, + {"WORLD_53", K_WORLD_53}, + {"WORLD_54", K_WORLD_54}, + {"WORLD_55", K_WORLD_55}, + {"WORLD_56", K_WORLD_56}, + {"WORLD_57", K_WORLD_57}, + {"WORLD_58", K_WORLD_58}, + {"WORLD_59", K_WORLD_59}, + {"WORLD_60", K_WORLD_60}, + {"WORLD_61", K_WORLD_61}, + {"WORLD_62", K_WORLD_62}, + {"WORLD_63", K_WORLD_63}, + {"WORLD_64", K_WORLD_64}, + {"WORLD_65", K_WORLD_65}, + {"WORLD_66", K_WORLD_66}, + {"WORLD_67", K_WORLD_67}, + {"WORLD_68", K_WORLD_68}, + {"WORLD_69", K_WORLD_69}, + {"WORLD_70", K_WORLD_70}, + {"WORLD_71", K_WORLD_71}, + {"WORLD_72", K_WORLD_72}, + {"WORLD_73", K_WORLD_73}, + {"WORLD_74", K_WORLD_74}, + {"WORLD_75", K_WORLD_75}, + {"WORLD_76", K_WORLD_76}, + {"WORLD_77", K_WORLD_77}, + {"WORLD_78", K_WORLD_78}, + {"WORLD_79", K_WORLD_79}, + {"WORLD_80", K_WORLD_80}, + {"WORLD_81", K_WORLD_81}, + {"WORLD_82", K_WORLD_82}, + {"WORLD_83", K_WORLD_83}, + {"WORLD_84", K_WORLD_84}, + {"WORLD_85", K_WORLD_85}, + {"WORLD_86", K_WORLD_86}, + {"WORLD_87", K_WORLD_87}, + {"WORLD_88", K_WORLD_88}, + {"WORLD_89", K_WORLD_89}, + {"WORLD_90", K_WORLD_90}, + {"WORLD_91", K_WORLD_91}, + {"WORLD_92", K_WORLD_92}, + {"WORLD_93", K_WORLD_93}, + {"WORLD_94", K_WORLD_94}, + {"WORLD_95", K_WORLD_95}, + + {"WINDOWS", K_SUPER}, + {"COMPOSE", K_COMPOSE}, + {"MODE", K_MODE}, + {"HELP", K_HELP}, + {"PRINT", K_PRINT}, + {"SYSREQ", K_SYSREQ}, + {"SCROLLOCK", K_SCROLLOCK }, + {"BREAK", K_BREAK}, + {"MENU", K_MENU}, + {"POWER", K_POWER}, + {"EURO", K_EURO}, + {"UNDO", K_UNDO}, + {NULL,0} }; @@ -752,7 +865,7 @@ char *Key_KeynumToString( int keynum ) { return "<KEY NOT FOUND>"; } - if ( keynum < 0 || keynum > 255 ) { + if ( keynum < 0 || keynum >= MAX_KEYS ) { return "<OUT OF RANGE>"; } @@ -937,7 +1050,7 @@ void Key_WriteBindings( fileHandle_t f ) { FS_Printf (f, "unbindall\n" ); - for (i=0 ; i<256 ; i++) { + for (i=0 ; i<MAX_KEYS ; i++) { if (keys[i].binding && keys[i].binding[0] ) { FS_Printf (f, "bind %s \"%s\"\n", Key_KeynumToString(i), keys[i].binding); @@ -956,7 +1069,7 @@ Key_Bindlist_f void Key_Bindlist_f( void ) { int i; - for ( i = 0 ; i < 256 ; i++ ) { + for ( i = 0 ; i < MAX_KEYS ; i++ ) { if ( keys[i].binding && keys[i].binding[0] ) { Com_Printf( "%s \"%s\"\n", Key_KeynumToString(i), keys[i].binding ); } @@ -981,7 +1094,7 @@ void CL_InitKeyCommands( void ) { CL_AddKeyUpCommands =================== */ -void CL_AddKeyUpCommands( int key, char *kb ) { +void CL_AddKeyUpCommands( int key, char *kb, unsigned time) { int i; char button[1024], *buttonPtr; char cmd[1024]; @@ -1067,7 +1180,8 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) { #endif // console key is hardcoded, so the user can never unbind it - if (key == '`' || key == '~') { + if (key == '`' || key == '~' || + ( key == K_ESCAPE && keys[K_SHIFT].down ) ) { if (!down) { return; } @@ -1127,7 +1241,7 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) { if (!down) { kb = keys[key].binding; - CL_AddKeyUpCommands( key, kb ); + CL_AddKeyUpCommands( key, kb, time ); if ( cls.keyCatchers & KEYCATCH_UI && uivm ) { VM_Call( uivm, UI_KEY_EVENT, key, down ); diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 6c7dd032..2fe3151d 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -75,6 +75,8 @@ cvar_t *cl_trn; cvar_t *cl_lanForcePackets; +cvar_t *cl_guidServerUniq; + clientActive_t cl; clientConnection_t clc; clientStatic_t cls; @@ -758,6 +760,28 @@ void CL_ClearState (void) { Com_Memset( &cl, 0, sizeof( cl ) ); } +/* +==================== +CL_UpdateGUID + +update cl_guid using QKEY_FILE and optional prefix +==================== +*/ +static void CL_UpdateGUID( char *prefix, int prefix_len ) +{ + fileHandle_t f; + int len; + + len = FS_SV_FOpenFileRead( QKEY_FILE, &f ); + FS_FCloseFile( f ); + + if( len != QKEY_SIZE ) + Cvar_Set( "cl_guid", "" ); + else + Cvar_Set( "cl_guid", Com_MD5File( QKEY_FILE, QKEY_SIZE, + prefix, prefix_len ) ); +} + /* ===================== @@ -826,6 +850,7 @@ void CL_Disconnect( qboolean showMainMenu ) { if( CL_VideoRecording( ) ) { CL_CloseAVI( ); } + CL_UpdateGUID( NULL, 0 ); } @@ -953,7 +978,7 @@ void CL_Setenv_f( void ) { if ( env ) { Com_Printf( "%s=%s\n", Cmd_Argv(1), env ); } else { - Com_Printf( "%s undefined\n", Cmd_Argv(1), env ); + Com_Printf( "%s undefined\n", Cmd_Argv(1)); } } } @@ -996,6 +1021,7 @@ CL_Connect_f */ void CL_Connect_f( void ) { char *server; + char serverString[ 22 ]; if ( Cmd_Argc() != 2 ) { Com_Printf( "usage: connect [server]\n"); @@ -1038,10 +1064,17 @@ void CL_Connect_f( void ) { if (clc.serverAddress.port == 0) { clc.serverAddress.port = BigShort( PORT_SERVER ); } - Com_Printf( "%s resolved to %i.%i.%i.%i:%i\n", cls.servername, - clc.serverAddress.ip[0], clc.serverAddress.ip[1], - clc.serverAddress.ip[2], clc.serverAddress.ip[3], - BigShort( clc.serverAddress.port ) ); + Com_sprintf( serverString, sizeof( serverString ), "%i.%i.%i.%i:%i", + clc.serverAddress.ip[0], clc.serverAddress.ip[1], + clc.serverAddress.ip[2], clc.serverAddress.ip[3], + BigShort( clc.serverAddress.port ) ); + + Com_Printf( "%s resolved to %s\n", cls.servername, serverString ); + + if( cl_guidServerUniq->integer ) + CL_UpdateGUID( serverString, strlen( serverString ) ); + else + CL_UpdateGUID( NULL, 0 ); // if we aren't playing on a lan, we need to authenticate // with the cd key @@ -2429,25 +2462,44 @@ void CL_StopVideo_f( void ) CL_CloseAVI( ); } +/* +=============== +CL_GenerateQKey + +test to see if a valid QKEY_FILE exists. If one does not, try to generate +it by filling it with 2048 bytes of random data. +=============== +*/ static void CL_GenerateQKey(void) { int len = 0; - unsigned char buff[2048]; + unsigned char buff[ QKEY_SIZE ]; + fileHandle_t f; - len = FS_ReadFile(QKEY_FILE, NULL); - if(len >= (int)sizeof(buff)) { - Com_Printf("QKEY found.\n"); + len = FS_SV_FOpenFileRead( QKEY_FILE, &f ); + FS_FCloseFile( f ); + if( len == QKEY_SIZE ) { + Com_Printf( "QKEY found.\n" ); return; } else { - int i; - srand(time(0)); - for(i = 0; i < sizeof(buff) - 1; i++) { - buff[i] = (unsigned char)(rand() % 255); + if( len > 0 ) { + Com_Printf( "QKEY file size != %d, regenerating\n", + QKEY_SIZE ); } - buff[i] = 0; - Com_Printf("QKEY generated\n"); - FS_WriteFile(QKEY_FILE, buff, sizeof(buff)); + + Com_Printf( "QKEY building random string\n" ); + Com_RandomBytes( buff, sizeof(buff) ); + + f = FS_SV_FOpenFileWrite( QKEY_FILE ); + if( !f ) { + Com_Printf( "QKEY could not open %s for write\n", + QKEY_FILE ); + return; + } + FS_Write( buff, sizeof(buff), f ); + FS_FCloseFile( f ); + Com_Printf( "QKEY generated\n" ); } } @@ -2546,6 +2598,8 @@ void CL_Init( void ) { cl_lanForcePackets = Cvar_Get ("cl_lanForcePackets", "1", CVAR_ARCHIVE); + cl_guidServerUniq = Cvar_Get ("cl_guidServerUniq", "1", CVAR_ARCHIVE); + // userinfo playerName = getenv( "USER" ); // Unixy stuff if( playerName == NULL ) @@ -2614,7 +2668,8 @@ void CL_Init( void ) { Cvar_Set( "cl_running", "1" ); CL_GenerateQKey(); - Cvar_Get("cl_guid", Com_MD5File(QKEY_FILE, 0), CVAR_USERINFO | CVAR_ROM); + Cvar_Get( "cl_guid", "", CVAR_USERINFO | CVAR_ROM ); + CL_UpdateGUID( NULL, 0 ); Com_Printf( "----- Client Initialization Complete -----\n" ); } diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c index 093893a6..63b1b6e5 100644 --- a/src/client/cl_parse.c +++ b/src/client/cl_parse.c @@ -326,6 +326,7 @@ void CL_ParseSnapshot( msg_t *msg ) { //===================================================================== int cl_connectedToPureServer; +int cl_connectedToCheatServer; /* ================== @@ -356,7 +357,8 @@ void CL_SystemInfoChanged( void ) { } s = Info_ValueForKey( systemInfo, "sv_cheats" ); - if ( atoi(s) == 0 ) { + cl_connectedToCheatServer = atoi( s ); + if ( !cl_connectedToCheatServer ) { Cvar_SetCheatState(); } diff --git a/src/client/cl_ui.c b/src/client/cl_ui.c index c740d3e8..2ba7736a 100644 --- a/src/client/cl_ui.c +++ b/src/client/cl_ui.c @@ -690,11 +690,11 @@ The ui module is making a system call intptr_t CL_UISystemCalls( intptr_t *args ) { switch( args[0] ) { case UI_ERROR: - Com_Error( ERR_DROP, "%s", VMA(1) ); + Com_Error( ERR_DROP, "%s", (const char*)VMA(1) ); return 0; case UI_PRINT: - Com_Printf( "%s", VMA(1) ); + Com_Printf( "%s", (const char*)VMA(1) ); return 0; case UI_MILLISECONDS: @@ -1019,7 +1019,7 @@ intptr_t CL_UISystemCalls( intptr_t *args ) { return 0; default: - Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] ); + Com_Error( ERR_DROP, "Bad UI system trap: %ld", (long int) args[0] ); } @@ -1080,6 +1080,10 @@ void CL_InitUI( void ) { // init for this gamestate VM_Call( uivm, UI_INIT, (cls.state >= CA_AUTHORIZING && cls.state < CA_ACTIVE) ); } + + // reset any CVAR_CHEAT cvars registered by ui + if ( !cl_connectedToCheatServer ) + Cvar_SetCheatState(); } /* diff --git a/src/client/client.h b/src/client/client.h index 77cf7dca..ea98c4f2 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -35,8 +35,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cl_curl.h" #endif /* USE_CURL */ -// tjw: file full of random crap that gets used to create cl_guid +// file full of random crap that gets used to create cl_guid #define QKEY_FILE "qkey" +#define QKEY_SIZE 2048 #define RETRANSMIT_TIMEOUT 3000 // time between connection packet retransmits @@ -443,6 +444,7 @@ char *Key_KeynumToString (int keynum); // cl_parse.c // extern int cl_connectedToPureServer; +extern int cl_connectedToCheatServer; void CL_SystemInfoChanged( void ); void CL_ParseServerMessage( msg_t *msg ); diff --git a/src/client/keycodes.h b/src/client/keycodes.h index 69abb9f6..b18c04f6 100644 --- a/src/client/keycodes.h +++ b/src/client/keycodes.h @@ -153,7 +153,116 @@ typedef enum { K_AUX15, K_AUX16, - K_LAST_KEY // this had better be <256! + K_WORLD_0, + K_WORLD_1, + K_WORLD_2, + K_WORLD_3, + K_WORLD_4, + K_WORLD_5, + K_WORLD_6, + K_WORLD_7, + K_WORLD_8, + K_WORLD_9, + K_WORLD_10, + K_WORLD_11, + K_WORLD_12, + K_WORLD_13, + K_WORLD_14, + K_WORLD_15, + K_WORLD_16, + K_WORLD_17, + K_WORLD_18, + K_WORLD_19, + K_WORLD_20, + K_WORLD_21, + K_WORLD_22, + K_WORLD_23, + K_WORLD_24, + K_WORLD_25, + K_WORLD_26, + K_WORLD_27, + K_WORLD_28, + K_WORLD_29, + K_WORLD_30, + K_WORLD_31, + K_WORLD_32, + K_WORLD_33, + K_WORLD_34, + K_WORLD_35, + K_WORLD_36, + K_WORLD_37, + K_WORLD_38, + K_WORLD_39, + K_WORLD_40, + K_WORLD_41, + K_WORLD_42, + K_WORLD_43, + K_WORLD_44, + K_WORLD_45, + K_WORLD_46, + K_WORLD_47, + K_WORLD_48, + K_WORLD_49, + K_WORLD_50, + K_WORLD_51, + K_WORLD_52, + K_WORLD_53, + K_WORLD_54, + K_WORLD_55, + K_WORLD_56, + K_WORLD_57, + K_WORLD_58, + K_WORLD_59, + K_WORLD_60, + K_WORLD_61, + K_WORLD_62, + K_WORLD_63, + K_WORLD_64, + K_WORLD_65, + K_WORLD_66, + K_WORLD_67, + K_WORLD_68, + K_WORLD_69, + K_WORLD_70, + K_WORLD_71, + K_WORLD_72, + K_WORLD_73, + K_WORLD_74, + K_WORLD_75, + K_WORLD_76, + K_WORLD_77, + K_WORLD_78, + K_WORLD_79, + K_WORLD_80, + K_WORLD_81, + K_WORLD_82, + K_WORLD_83, + K_WORLD_84, + K_WORLD_85, + K_WORLD_86, + K_WORLD_87, + K_WORLD_88, + K_WORLD_89, + K_WORLD_90, + K_WORLD_91, + K_WORLD_92, + K_WORLD_93, + K_WORLD_94, + K_WORLD_95, + + K_SUPER, + K_COMPOSE, + K_MODE, + K_HELP, + K_PRINT, + K_SYSREQ, + K_SCROLLOCK, + K_BREAK, + K_MENU, + K_EURO, + K_UNDO, + + K_LAST_KEY // this had better be < MAX_KEYS! } keyNum_t; diff --git a/src/client/keys.h b/src/client/keys.h index fbab475f..c768fc99 100644 --- a/src/client/keys.h +++ b/src/client/keys.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "keycodes.h" -#define MAX_KEYS 256 +#define MAX_KEYS 384 typedef struct { qboolean down; diff --git a/src/client/qal.c b/src/client/qal.c index 4c04bd41..c0b4a215 100644 --- a/src/client/qal.c +++ b/src/client/qal.c @@ -154,7 +154,7 @@ static void *GPA(char *str) } else { - Com_DPrintf( " Loaded symbol %s (0x%08X)\n", str, rv); + Com_DPrintf( " Loaded symbol %s (%p)\n", str, rv); return rv; } } diff --git a/src/client/snd_dma.c b/src/client/snd_dma.c index d55f9697..7e7897b1 100644 --- a/src/client/snd_dma.c +++ b/src/client/snd_dma.c @@ -110,7 +110,7 @@ void S_Base_SoundInfo(void) { Com_Printf("%5d samplebits\n", dma.samplebits); Com_Printf("%5d submission_chunk\n", dma.submission_chunk); Com_Printf("%5d speed\n", dma.speed); - Com_Printf("0x%x dma buffer\n", dma.buffer); + Com_Printf("%p dma buffer\n", dma.buffer); if ( s_backgroundStream ) { Com_Printf("Background file: %s\n", s_backgroundLoop ); } else { @@ -467,7 +467,7 @@ void S_Base_StartSound(vec3_t origin, int entityNum, int entchannel, sfxHandle_t } if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) { - Com_Printf( S_COLOR_YELLOW, "S_StartSound: handle %i out of range\n", sfxHandle ); + Com_Printf( S_COLOR_YELLOW "S_StartSound: handle %i out of range\n", sfxHandle ); return; } @@ -579,7 +579,7 @@ void S_Base_StartLocalSound( sfxHandle_t sfxHandle, int channelNum ) { } if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) { - Com_Printf( S_COLOR_YELLOW, "S_StartLocalSound: handle %i out of range\n", sfxHandle ); + Com_Printf( S_COLOR_YELLOW "S_StartLocalSound: handle %i out of range\n", sfxHandle ); return; } @@ -688,7 +688,7 @@ void S_Base_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t ve } if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) { - Com_Printf( S_COLOR_YELLOW, "S_AddLoopingSound: handle %i out of range\n", sfxHandle ); + Com_Printf( S_COLOR_YELLOW "S_AddLoopingSound: handle %i out of range\n", sfxHandle ); return; } @@ -751,7 +751,7 @@ void S_Base_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_ } if ( sfxHandle < 0 || sfxHandle >= s_numSfx ) { - Com_Printf( S_COLOR_YELLOW, "S_AddRealLoopingSound: handle %i out of range\n", sfxHandle ); + Com_Printf( S_COLOR_YELLOW "S_AddRealLoopingSound: handle %i out of range\n", sfxHandle ); return; } @@ -1116,7 +1116,7 @@ void S_Base_Update( void ) { ch = s_channels; for (i=0 ; i<MAX_CHANNELS; i++, ch++) { if (ch->thesfx && (ch->leftvol || ch->rightvol) ) { - Com_Printf ("%f %f %s\n", ch->leftvol, ch->rightvol, ch->thesfx->soundName); + Com_Printf ("%d %d %s\n", ch->leftvol, ch->rightvol, ch->thesfx->soundName); total++; } } diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c index 6f5396c4..61b250d6 100644 --- a/src/client/snd_openal.c +++ b/src/client/snd_openal.c @@ -43,7 +43,6 @@ cvar_t *s_alGraceDistance; cvar_t *s_alDriver; cvar_t *s_alDevice; cvar_t *s_alAvailableDevices; -cvar_t *s_alMaxSpeakerDistance; /* ================= @@ -531,15 +530,13 @@ Adapt the gain if necessary to get a quicker fadeout when the source is too far static void S_AL_ScaleGain(src_t *chksrc, vec3_t origin) { float distance; - - if(chksrc->local) - distance = VectorLength(origin); - else + + if(!chksrc->local) distance = Distance(origin, lastListenerOrigin); - + // If we exceed a certain distance, scale the gain linearly until the sound // vanishes into nothingness. - if((distance -= s_alMaxDistance->value) > 0) + if(!chksrc->local && (distance -= s_alMaxDistance->value) > 0) { float scaleFactor; @@ -897,7 +894,7 @@ static qboolean S_AL_CheckInput(int entityNum, sfxHandle_t sfx) if (sfx < 0 || sfx >= numSfx) { - Com_Printf(S_COLOR_RED, "ERROR: S_AL_CheckInput: handle %i out of range\n", sfx); + Com_Printf(S_COLOR_RED "ERROR: S_AL_CheckInput: handle %i out of range\n", sfx); return qtrue; } @@ -914,11 +911,14 @@ Play a local (non-spatialized) sound effect static void S_AL_StartLocalSound(sfxHandle_t sfx, int channel) { + srcHandle_t src; + if(S_AL_CheckInput(0, sfx)) return; // Try to grab a source - srcHandle_t src = S_AL_SrcAlloc(SRCPRI_LOCAL, -1, channel); + src = S_AL_SrcAlloc(SRCPRI_LOCAL, -1, channel); + if(src == -1) return; @@ -940,12 +940,13 @@ static void S_AL_StartSound( vec3_t origin, int entnum, int entchannel, sfxHandle_t sfx ) { vec3_t sorigin; + srcHandle_t src; if(S_AL_CheckInput(origin ? 0 : entnum, sfx)) return; // Try to grab a source - srcHandle_t src = S_AL_SrcAlloc(SRCPRI_ONESHOT, entnum, entchannel); + src = S_AL_SrcAlloc(SRCPRI_ONESHOT, entnum, entchannel); if(src == -1) return; @@ -1095,8 +1096,8 @@ void S_AL_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t // There are certain maps (*cough* Q3:TA mpterra*) that have large quantities // of ET_SPEAKERS in the PVS at any given time. OpenAL can't cope with mixing // large numbers of sounds, so this culls them by distance - if( DistanceSquared( origin, lastListenerOrigin ) > - s_alMaxSpeakerDistance->value * s_alMaxSpeakerDistance->value ) + if( DistanceSquared( origin, lastListenerOrigin ) > (s_alMaxDistance->value + s_alGraceDistance->value) * + (s_alMaxDistance->value + s_alGraceDistance->value) ) return; S_AL_SrcLoop(SRCPRI_AMBIENT, sfx, origin, velocity, entityNum); @@ -1882,7 +1883,6 @@ qboolean S_AL_Init( soundInterface_t *si ) s_alMaxDistance = Cvar_Get("s_alMaxDistance", "1024", CVAR_CHEAT); s_alRolloff = Cvar_Get( "s_alRolloff", "2", CVAR_CHEAT); s_alGraceDistance = Cvar_Get("s_alGraceDistance", "512", CVAR_CHEAT); - s_alMaxSpeakerDistance = Cvar_Get( "s_alMaxSpeakerDistance", "1024", CVAR_ARCHIVE ); s_alDriver = Cvar_Get( "s_alDriver", ALDRIVER_DEFAULT, CVAR_ARCHIVE ); |