diff options
author | Tim Angus <tim@ngus.net> | 2009-10-03 12:31:59 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:03 +0000 |
commit | 304d4258d3a49488f570b8ad71931faa7e5d40ba (patch) | |
tree | bf9ec15bd9154305ff9fab2943b3daf25024f8a5 /src/client | |
parent | 6e90e4e7861f5cb354487d1fe0f1fd06c385308e (diff) |
* Merge ioq3-r1498, by popular demand
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/cl_cgame.c | 8 | ||||
-rw-r--r-- | src/client/cl_cin.c | 81 | ||||
-rw-r--r-- | src/client/cl_console.c | 20 | ||||
-rw-r--r-- | src/client/cl_curl.c | 2 | ||||
-rw-r--r-- | src/client/cl_input.c | 2 | ||||
-rw-r--r-- | src/client/cl_keys.c | 71 | ||||
-rw-r--r-- | src/client/cl_main.c | 74 | ||||
-rw-r--r-- | src/client/cl_ui.c | 8 | ||||
-rw-r--r-- | src/client/snd_openal.c | 2 |
9 files changed, 185 insertions, 83 deletions
diff --git a/src/client/cl_cgame.c b/src/client/cl_cgame.c index 6e436316..9a16d3bf 100644 --- a/src/client/cl_cgame.c +++ b/src/client/cl_cgame.c @@ -397,11 +397,9 @@ void CL_ShutdownCGame( void ) { } static int FloatAsInt( float f ) { - int temp; - - *(float *)&temp = f; - - return temp; + floatint_t fi; + fi.f = f; + return fi.i; } /* diff --git a/src/client/cl_cin.c b/src/client/cl_cin.c index 1443937c..7690d627 100644 --- a/src/client/cl_cin.c +++ b/src/client/cl_cin.c @@ -621,7 +621,10 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags ) unsigned short *aptr, *bptr, *cptr, *dptr; long y0,y1,y2,y3,cr,cb; byte *bbptr, *baptr, *bcptr, *bdptr; - unsigned int *iaptr, *ibptr, *icptr, *idptr; + union { + unsigned int *i; + unsigned short *s; + } iaptr, ibptr, icptr, idptr; if (!roq_flags) { two = four = 256; @@ -664,7 +667,7 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags ) VQ2TO4(aptr,bptr,cptr,dptr); } } else if (cinTable[currentHandle].samplesPerPixel==4) { - ibptr = (unsigned int *)bptr; + ibptr.s = bptr; for(i=0;i<two;i++) { y0 = (long)*input++; y1 = (long)*input++; @@ -672,20 +675,22 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags ) y3 = (long)*input++; cr = (long)*input++; cb = (long)*input++; - *ibptr++ = yuv_to_rgb24( y0, cr, cb ); - *ibptr++ = yuv_to_rgb24( y1, cr, cb ); - *ibptr++ = yuv_to_rgb24( y2, cr, cb ); - *ibptr++ = yuv_to_rgb24( y3, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y0, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y1, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y2, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y3, cr, cb ); } - icptr = (unsigned int *)vq4; - idptr = (unsigned int *)vq8; + icptr.s = vq4; + idptr.s = vq8; for(i=0;i<four;i++) { - iaptr = (unsigned int *)vq2 + (*input++)*4; - ibptr = (unsigned int *)vq2 + (*input++)*4; + iaptr.s = vq2; + iaptr.i += (*input++)*4; + ibptr.s = vq2; + ibptr.i += (*input++)*4; for(j=0;j<2;j++) - VQ2TO4(iaptr, ibptr, icptr, idptr); + VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i); } } else if (cinTable[currentHandle].samplesPerPixel==1) { bbptr = (byte *)bptr; @@ -740,7 +745,7 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags ) } } } else if (cinTable[currentHandle].samplesPerPixel==4) { - ibptr = (unsigned int *)bptr; + ibptr.s = bptr; for(i=0;i<two;i++) { y0 = (long)*input++; y1 = (long)*input++; @@ -748,25 +753,27 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags ) y3 = (long)*input++; cr = (long)*input++; cb = (long)*input++; - *ibptr++ = yuv_to_rgb24( y0, cr, cb ); - *ibptr++ = yuv_to_rgb24( y1, cr, cb ); - *ibptr++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb ); - *ibptr++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb ); - *ibptr++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb ); - *ibptr++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb ); - *ibptr++ = yuv_to_rgb24( y2, cr, cb ); - *ibptr++ = yuv_to_rgb24( y3, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y0, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y1, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y2, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y3, cr, cb ); } - icptr = (unsigned int *)vq4; - idptr = (unsigned int *)vq8; + icptr.s = vq4; + idptr.s = vq8; for(i=0;i<four;i++) { - iaptr = (unsigned int *)vq2 + (*input++)*8; - ibptr = (unsigned int *)vq2 + (*input++)*8; + iaptr.s = vq2; + iaptr.i += (*input++)*8; + ibptr.s = vq2; + ibptr.i += (*input++)*8; for(j=0;j<2;j++) { - VQ2TO4(iaptr, ibptr, icptr, idptr); - VQ2TO4(iaptr, ibptr, icptr, idptr); + VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i); + VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i); } } } else if (cinTable[currentHandle].samplesPerPixel==1) { @@ -842,24 +849,26 @@ static void decodeCodeBook( byte *input, unsigned short roq_flags ) } } } else if (cinTable[currentHandle].samplesPerPixel == 4) { - ibptr = (unsigned int *) bptr; + ibptr.s = bptr; for(i=0;i<two;i++) { y0 = (long)*input; input+=2; y2 = (long)*input; input+=2; cr = (long)*input++; cb = (long)*input++; - *ibptr++ = yuv_to_rgb24( y0, cr, cb ); - *ibptr++ = yuv_to_rgb24( y2, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y0, cr, cb ); + *ibptr.i++ = yuv_to_rgb24( y2, cr, cb ); } - icptr = (unsigned int *)vq4; - idptr = (unsigned int *)vq8; + icptr.s = vq4; + idptr.s = vq8; for(i=0;i<four;i++) { - iaptr = (unsigned int *)vq2 + (*input++)*2; - ibptr = (unsigned int *)vq2 + (*input++)*2; + iaptr.s = vq2; + iaptr.i += (*input++)*2; + ibptr.s = vq2 + (*input++)*2; + ibptr.i += (*input++)*2; for(j=0;j<2;j++) { - VQ2TO2(iaptr,ibptr,icptr,idptr); + VQ2TO2(iaptr.i,ibptr.i,icptr.i,idptr.i); } } } @@ -1194,8 +1203,8 @@ redump: cinTable[currentHandle].roq_id = framedata[0] + framedata[1]*256; cinTable[currentHandle].RoQFrameSize = framedata[2] + framedata[3]*256 + framedata[4]*65536; cinTable[currentHandle].roq_flags = framedata[6] + framedata[7]*256; - cinTable[currentHandle].roqF0 = (char)framedata[7]; - cinTable[currentHandle].roqF1 = (char)framedata[6]; + cinTable[currentHandle].roqF0 = (signed char)framedata[7]; + cinTable[currentHandle].roqF1 = (signed char)framedata[6]; if (cinTable[currentHandle].RoQFrameSize>65536||cinTable[currentHandle].roq_id==0x1084) { Com_DPrintf("roq_size>65536||roq_id==0x1084\n"); diff --git a/src/client/cl_console.c b/src/client/cl_console.c index 0ad397b9..39f13028 100644 --- a/src/client/cl_console.c +++ b/src/client/cl_console.c @@ -233,6 +233,17 @@ void Con_CheckResize (void) con.display = con.current; } +/* +================== +Cmd_CompleteTxtName +================== +*/ +void Cmd_CompleteTxtName( char *args, int argNum ) { + if( argNum == 2 ) { + Field_CompleteFilename( "", "txt", qfalse ); + } +} + /* ================ @@ -255,6 +266,7 @@ void Con_Init (void) { Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f); Cmd_AddCommand ("clear", Con_Clear_f); Cmd_AddCommand ("condump", Con_Dump_f); + Cmd_SetCommandCompletionFunc( "condump", Cmd_CompleteTxtName ); } @@ -431,7 +443,7 @@ void Con_DrawSolidConsole( float frac ) { SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL ); // draw the background - y = frac * SCREEN_HEIGHT - 2; + y = frac * SCREEN_HEIGHT; if ( y < 1 ) { y = 0; } @@ -453,10 +465,8 @@ void Con_DrawSolidConsole( float frac ) { i = strlen( Q3_VERSION ); for (x=0 ; x<i ; x++) { - - SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x ) * SMALLCHAR_WIDTH, - (lines-(SMALLCHAR_HEIGHT+SMALLCHAR_HEIGHT/2)), Q3_VERSION[x] ); - + SCR_DrawSmallChar( cls.glconfig.vidWidth - ( i - x + 1 ) * SMALLCHAR_WIDTH, + lines - SMALLCHAR_HEIGHT, Q3_VERSION[x] ); } diff --git a/src/client/cl_curl.c b/src/client/cl_curl.c index fb93aa2f..4c34667c 100644 --- a/src/client/cl_curl.c +++ b/src/client/cl_curl.c @@ -218,7 +218,7 @@ static int CL_cURL_CallbackProgress( void *dummy, double dltotal, double dlnow, return 0; } -static int CL_cURL_CallbackWrite(void *buffer, size_t size, size_t nmemb, +static size_t CL_cURL_CallbackWrite(void *buffer, size_t size, size_t nmemb, void *stream) { FS_Write( buffer, size*nmemb, ((fileHandle_t*)stream)[0] ); diff --git a/src/client/cl_input.c b/src/client/cl_input.c index cb95ce8c..dae244bb 100644 --- a/src/client/cl_input.c +++ b/src/client/cl_input.c @@ -782,8 +782,8 @@ void CL_WritePacket( void ) { } else if (Q_stricmp(target, "none") == 0) { clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0; } else { - clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0; const char *ptr = target; + clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0; do { if ((*ptr == ',') || (*ptr == '\0')) { const int val = atoi(target); diff --git a/src/client/cl_keys.c b/src/client/cl_keys.c index ee075ce5..10abefc2 100644 --- a/src/client/cl_keys.c +++ b/src/client/cl_keys.c @@ -728,7 +728,6 @@ qboolean Key_IsDown( int keynum ) { return keys[keynum].down; } - /* =================== Key_StringToKeynum @@ -753,28 +752,12 @@ int Key_StringToKeynum( char *str ) { } // check for hex code - if ( str[0] == '0' && str[1] == 'x' && strlen( str ) == 4) { - int n1, n2; - - n1 = str[2]; - if ( n1 >= '0' && n1 <= '9' ) { - n1 -= '0'; - } else if ( n1 >= 'a' && n1 <= 'f' ) { - n1 = n1 - 'a' + 10; - } else { - n1 = 0; - } + if ( strlen( str ) == 4 ) { + int n = Com_HexStrToInt( str ); - n2 = str[3]; - if ( n2 >= '0' && n2 <= '9' ) { - n2 -= '0'; - } else if ( n2 >= 'a' && n2 <= 'f' ) { - n2 = n2 - 'a' + 10; - } else { - n2 = 0; + if ( n >= 0 ) { + return n; } - - return n1 * 16 + n2; } // scan for a text match @@ -1027,6 +1010,50 @@ void Key_KeynameCompletion( void(*callback)(const char *s) ) { } /* +==================== +Key_CompleteUnbind +==================== +*/ +static void Key_CompleteUnbind( char *args, int argNum ) +{ + if( argNum == 2 ) + { + // Skip "unbind " + char *p = Com_SkipTokens( args, 1, " " ); + + if( p > args ) + Field_CompleteKeyname( ); + } +} + +/* +==================== +Key_CompleteBind +==================== +*/ +static void Key_CompleteBind( char *args, int argNum ) +{ + char *p; + + if( argNum == 2 ) + { + // Skip "bind " + p = Com_SkipTokens( args, 1, " " ); + + if( p > args ) + Field_CompleteKeyname( ); + } + else if( argNum >= 3 ) + { + // Skip "bind <key> " + p = Com_SkipTokens( args, 2, " " ); + + if( p > args ) + Field_CompleteCommand( p, qtrue, qtrue ); + } +} + +/* =================== CL_InitKeyCommands =================== @@ -1034,7 +1061,9 @@ CL_InitKeyCommands void CL_InitKeyCommands( void ) { // register our functions Cmd_AddCommand ("bind",Key_Bind_f); + Cmd_SetCommandCompletionFunc( "bind", Key_CompleteBind ); Cmd_AddCommand ("unbind",Key_Unbind_f); + Cmd_SetCommandCompletionFunc( "unbind", Key_CompleteUnbind ); Cmd_AddCommand ("unbindall",Key_Unbindall_f); Cmd_AddCommand ("bindlist",Key_Bindlist_f); } diff --git a/src/client/cl_main.c b/src/client/cl_main.c index f91c80b2..3551682f 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -868,6 +868,22 @@ static void CL_WalkDemoExt(char *arg, char *name, int *demofile) /* ==================== +CL_CompleteDemoName +==================== +*/ +static void CL_CompleteDemoName( char *args, int argNum ) +{ + if( argNum == 2 ) + { + char demoExt[ 16 ]; + + Com_sprintf( demoExt, sizeof( demoExt ), ".dm_%d", PROTOCOL_VERSION ); + Field_CompleteFilename( "demos", demoExt, qtrue ); + } +} + +/* +==================== CL_PlayDemo_f demo <demoname> @@ -1524,6 +1540,23 @@ void CL_Connect_f( void ) { #define MAX_RCON_MESSAGE 1024 /* +================== +CL_CompleteRcon +================== +*/ +static void CL_CompleteRcon( char *args, int argNum ) +{ + if( argNum == 2 ) + { + // Skip "rcon " + char *p = Com_SkipTokens( args, 1, " " ); + + if( p > args ) + Field_CompleteCommand( p, qtrue, qtrue ); + } +} + +/* ===================== CL_Rcon_f @@ -2126,7 +2159,7 @@ void CL_InitServerInfo( serverInfo_t *server, netadr_t *address ) { CL_ServersResponsePacket =================== */ -void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) { +void CL_ServersResponsePacket( const netadr_t* from, msg_t *msg, qboolean extended ) { int i, count, total; netadr_t addresses[MAX_SERVERSPERPACKET]; int numservers; @@ -2149,7 +2182,7 @@ void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) { // advance to initial token do { - if(*buffptr == '\\' || *buffptr == '/') + if(*buffptr == '\\' || (extended && *buffptr == '/')) break; buffptr++; @@ -2157,6 +2190,7 @@ void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) { while (buffptr + 1 < buffend) { + // IPv4 address if (*buffptr == '\\') { buffptr++; @@ -2169,7 +2203,8 @@ void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) { addresses[numservers].type = NA_IP; } - else + // IPv6 address, if it's an extended response + else if (extended && *buffptr == '/') { buffptr++; @@ -2180,7 +2215,11 @@ void CL_ServersResponsePacket( netadr_t from, msg_t *msg ) { addresses[numservers].ip6[i] = *buffptr++; addresses[numservers].type = NA_IP6; + addresses[numservers].scope_id = from->scope_id; } + else + // syntax error! + break; // parse out port addresses[numservers].port = (*buffptr++) << 8; @@ -2333,9 +2372,15 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) { return; } - // echo request from server + // list of servers sent back by a master server (classic) if ( !Q_strncmp(c, "getserversResponse", 18) ) { - CL_ServersResponsePacket( from, msg ); + CL_ServersResponsePacket( &from, msg, qfalse ); + return; + } + + // list of servers sent back by a master server (extended) + if ( !Q_strncmp(c, "getserversExtResponse", 21) ) { + CL_ServersResponsePacket( &from, msg, qtrue ); return; } @@ -3018,8 +3063,8 @@ void CL_Init( void ) { cl_guidServerUniq = Cvar_Get ("cl_guidServerUniq", "1", CVAR_ARCHIVE); - // 0x7e = ~ and 0x60 = ` - cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "0x7e 0x60", CVAR_ARCHIVE); + // ~ and `, as keys and characters + cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE); // userinfo Cvar_Get ("name", Sys_GetCurrentUser( ), CVAR_USERINFO | CVAR_ARCHIVE ); @@ -3081,6 +3126,7 @@ void CL_Init( void ) { Cmd_AddCommand ("disconnect", CL_Disconnect_f); Cmd_AddCommand ("record", CL_Record_f); Cmd_AddCommand ("demo", CL_PlayDemo_f); + Cmd_SetCommandCompletionFunc( "demo", CL_CompleteDemoName ); Cmd_AddCommand ("cinematic", CL_PlayCinematic_f); Cmd_AddCommand ("stoprecord", CL_StopRecord_f); Cmd_AddCommand ("connect", CL_Connect_f); @@ -3088,6 +3134,7 @@ void CL_Init( void ) { Cmd_AddCommand ("localservers", CL_LocalServers_f); Cmd_AddCommand ("globalservers", CL_GlobalServers_f); Cmd_AddCommand ("rcon", CL_Rcon_f); + Cmd_SetCommandCompletionFunc( "rcon", CL_CompleteRcon ); Cmd_AddCommand ("setenv", CL_Setenv_f ); Cmd_AddCommand ("ping", CL_Ping_f ); Cmd_AddCommand ("serverstatus", CL_ServerStatus_f ); @@ -3557,6 +3604,7 @@ void CL_GlobalServers_f( void ) { netadr_t to; int count, i, masterNum; char command[1024], *masteraddress; + char *cmdname; if ((count = Cmd_Argc()) < 3 || (masterNum = atoi(Cmd_Argv(1))) < 0 || masterNum > 4) { @@ -3591,7 +3639,17 @@ void CL_GlobalServers_f( void ) { cls.numglobalservers = -1; cls.pingUpdateSource = AS_GLOBAL; - Com_sprintf( command, sizeof(command), "getservers %s", Cmd_Argv(2) ); + // Use the extended query for IPv6 masters + if (to.type == NA_IP6 || to.type == NA_MULTICAST6) + { + cmdname = "getserversExt " GAMENAME_FOR_MASTER; + + // TODO: test if we only have an IPv6 connection. If it's the case, + // request IPv6 servers only by appending " ipv6" to the command + } + else + cmdname = "getservers"; + Com_sprintf( command, sizeof(command), "%s %s", cmdname, Cmd_Argv(2) ); for (i=3; i < count; i++) { diff --git a/src/client/cl_ui.c b/src/client/cl_ui.c index c0d4e729..49719824 100644 --- a/src/client/cl_ui.c +++ b/src/client/cl_ui.c @@ -631,11 +631,9 @@ FloatAsInt ==================== */ static int FloatAsInt( float f ) { - int temp; - - *(float *)&temp = f; - - return temp; + floatint_t fi; + fi.f = f; + return fi.i; } /* diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c index 5421a7a0..912006d8 100644 --- a/src/client/snd_openal.c +++ b/src/client/snd_openal.c @@ -1921,7 +1921,7 @@ void S_AL_SoundInfo( void ) Com_Printf( " Version: %s\n", qalGetString( AL_VERSION ) ); Com_Printf( " Renderer: %s\n", qalGetString( AL_RENDERER ) ); Com_Printf( " AL Extensions: %s\n", qalGetString( AL_EXTENSIONS ) ); - Com_Printf( " ALC Extensions: %s\n", qalcGetString( NULL, ALC_EXTENSIONS ) ); + Com_Printf( " ALC Extensions: %s\n", qalcGetString( alDevice, ALC_EXTENSIONS ) ); if(qalcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { Com_Printf(" Device: %s\n", qalcGetString(alDevice, ALC_DEVICE_SPECIFIER)); |