diff options
Diffstat (limited to 'src/qcommon')
| -rw-r--r-- | src/qcommon/cm_local.h | 2 | ||||
| -rw-r--r-- | src/qcommon/cm_patch.c | 2 | ||||
| -rw-r--r-- | src/qcommon/cm_test.c | 41 | ||||
| -rw-r--r-- | src/qcommon/cm_trace.c | 2 | ||||
| -rw-r--r-- | src/qcommon/common.c | 128 | ||||
| -rw-r--r-- | src/qcommon/cvar.c | 14 | ||||
| -rw-r--r-- | src/qcommon/q_platform.h | 29 | ||||
| -rw-r--r-- | src/qcommon/qcommon.h | 3 | 
8 files changed, 170 insertions, 51 deletions
diff --git a/src/qcommon/cm_local.h b/src/qcommon/cm_local.h index cc69482b..4b30052d 100644 --- a/src/qcommon/cm_local.h +++ b/src/qcommon/cm_local.h @@ -205,6 +205,8 @@ void CM_StoreBrushes( leafList_t *ll, int nodenum );  void CM_BoxLeafnums_r( leafList_t *ll, int nodenum );  cmodel_t	*CM_ClipHandleToModel( clipHandle_t handle ); +qboolean CM_BoundsIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 ); +qboolean CM_BoundsIntersectPoint( const vec3_t mins, const vec3_t maxs, const vec3_t point );  // cm_patch.c diff --git a/src/qcommon/cm_patch.c b/src/qcommon/cm_patch.c index 38b7d5cc..98724644 100644 --- a/src/qcommon/cm_patch.c +++ b/src/qcommon/cm_patch.c @@ -1387,7 +1387,7 @@ void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *  	static cvar_t *cv;  #endif //BSPC -	if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1], +	if ( !CM_BoundsIntersect( tw->bounds[0], tw->bounds[1],  				pc->bounds[0], pc->bounds[1] ) ) {  		return;  	} diff --git a/src/qcommon/cm_test.c b/src/qcommon/cm_test.c index 485facc2..420a91f2 100644 --- a/src/qcommon/cm_test.c +++ b/src/qcommon/cm_test.c @@ -251,7 +251,7 @@ int CM_PointContents( const vec3_t p, clipHandle_t model ) {  		brushnum = cm.leafbrushes[leaf->firstLeafBrush+k];  		b = &cm.brushes[brushnum]; -		if ( !BoundsIntersectPoint( b->bounds[0], b->bounds[1], p ) ) { +		if ( !CM_BoundsIntersectPoint( b->bounds[0], b->bounds[1], p ) ) {  			continue;  		} @@ -481,3 +481,42 @@ int CM_WriteAreaBits (byte *buffer, int area)  	return bytes;  } +/* +==================== +CM_BoundsIntersect +==================== +*/ +qboolean CM_BoundsIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 ) +{ +	if (maxs[0] < mins2[0] - SURFACE_CLIP_EPSILON || +		maxs[1] < mins2[1] - SURFACE_CLIP_EPSILON || +		maxs[2] < mins2[2] - SURFACE_CLIP_EPSILON || +		mins[0] > maxs2[0] + SURFACE_CLIP_EPSILON || +		mins[1] > maxs2[1] + SURFACE_CLIP_EPSILON || +		mins[2] > maxs2[2] + SURFACE_CLIP_EPSILON) +	{ +		return qfalse; +	} + +	return qtrue; +} + +/* +==================== +CM_BoundsIntersectPoint +==================== +*/ +qboolean CM_BoundsIntersectPoint( const vec3_t mins, const vec3_t maxs, const vec3_t point ) +{ +	if (maxs[0] < point[0] - SURFACE_CLIP_EPSILON || +		maxs[1] < point[1] - SURFACE_CLIP_EPSILON || +		maxs[2] < point[2] - SURFACE_CLIP_EPSILON || +		mins[0] > point[0] + SURFACE_CLIP_EPSILON || +		mins[1] > point[1] + SURFACE_CLIP_EPSILON || +		mins[2] > point[2] + SURFACE_CLIP_EPSILON) +	{ +		return qfalse; +	} + +	return qtrue; +} diff --git a/src/qcommon/cm_trace.c b/src/qcommon/cm_trace.c index bd8d4bd5..3be22d43 100644 --- a/src/qcommon/cm_trace.c +++ b/src/qcommon/cm_trace.c @@ -847,7 +847,7 @@ void CM_TraceThroughLeaf( traceWork_t *tw, cLeaf_t *leaf ) {  		b->collided = qfalse; -		if ( !BoundsIntersect( tw->bounds[0], tw->bounds[1], +		if ( !CM_BoundsIntersect( tw->bounds[0], tw->bounds[1],  					b->bounds[0], b->bounds[1] ) ) {  			continue;  		} diff --git a/src/qcommon/common.c b/src/qcommon/common.c index 083a7d18..ff742803 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -2947,6 +2947,40 @@ static char *Field_FindFirstSeparator( char *s )  	return NULL;  } +#ifndef DEDICATED +/* +=============== +Field_CompleteKeyname +=============== +*/ +static void Field_CompleteKeyname( void ) +{ +	matchCount = 0; +	shortestMatch[ 0 ] = 0; + +	Key_KeynameCompletion( FindMatches ); + +	if( matchCount == 0 ) +		return; + +	Q_strncpyz( &completionField->buffer[ strlen( completionField->buffer ) - +		strlen( completionString ) ], shortestMatch, +		sizeof( completionField->buffer ) ); +	completionField->cursor = strlen( completionField->buffer ); + +	if( matchCount == 1 ) +	{ +		Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " ); +		completionField->cursor++; +		return; +	} + +	Com_Printf( "]%s\n", completionField->buffer ); +	 +	Key_KeynameCompletion( PrintMatches ); +} +#endif +  /*  ===============  Field_CompleteFilename @@ -2963,8 +2997,9 @@ static void Field_CompleteFilename( const char *dir,  	if( matchCount == 0 )  		return; -	Q_strcat( completionField->buffer, sizeof( completionField->buffer ), -			shortestMatch + strlen( completionString ) ); +	Q_strncpyz( &completionField->buffer[ strlen( completionField->buffer ) - +		strlen( completionString ) ], shortestMatch, +		sizeof( completionField->buffer ) );  	completionField->cursor = strlen( completionField->buffer );  	if( matchCount == 1 ) @@ -3005,20 +3040,36 @@ static void Field_CompleteCommand( char *cmd,  	else  		completionString = Cmd_Argv( completionArgument - 1 ); +#ifndef DEDICATED +	// Unconditionally add a '\' to the start of the buffer +	if( completionField->buffer[ 0 ] && +			completionField->buffer[ 0 ] != '\\' ) +	{ +		if( completionField->buffer[ 0 ] != '/' ) +		{ +			// Buffer is full, refuse to complete +			if( strlen( completionField->buffer ) + 1 >= +				sizeof( completionField->buffer ) ) +				return; + +			memmove( &completionField->buffer[ 1 ], +				&completionField->buffer[ 0 ], +				strlen( completionField->buffer ) + 1 ); +			completionField->cursor++; +		} + +		completionField->buffer[ 0 ] = '\\'; +	} +#endif +  	if( completionArgument > 1 )  	{  		const char *baseCmd = Cmd_Argv( 0 );  #ifndef DEDICATED -		// If the very first token does not have a leading \ or /, -		// refuse to autocomplete -		if( cmd == completionField->buffer ) -		{ -			if( baseCmd[ 0 ] != '\\' && baseCmd[ 0 ] != '/' ) -				return; - +		// This should always be true +		if( baseCmd[ 0 ] == '\\' || baseCmd[ 0 ] == '/' )  			baseCmd++; -		}  #endif  		if( ( p = Field_FindFirstSeparator( cmd ) ) ) @@ -3049,13 +3100,6 @@ static void Field_CompleteCommand( char *cmd,  			{  				Field_CompleteFilename( "", "txt", qfalse );  			} -			else if( !Q_stricmp( baseCmd, "demo" ) && completionArgument == 2 ) -			{ -				char demoExt[ 16 ]; - -				Com_sprintf( demoExt, sizeof( demoExt ), ".dm_%d", PROTOCOL_VERSION ); -				Field_CompleteFilename( "demos", demoExt, qtrue ); -			}  			else if( ( !Q_stricmp( baseCmd, "toggle" ) ||  						!Q_stricmp( baseCmd, "vstr" ) ||  						!Q_stricmp( baseCmd, "set" ) || @@ -3070,6 +3114,14 @@ static void Field_CompleteCommand( char *cmd,  				if( p > cmd )  					Field_CompleteCommand( p, qfalse, qtrue );  			} +#ifndef DEDICATED +			else if( !Q_stricmp( baseCmd, "demo" ) && completionArgument == 2 ) +			{ +				char demoExt[ 16 ]; + +				Com_sprintf( demoExt, sizeof( demoExt ), ".dm_%d", PROTOCOL_VERSION ); +				Field_CompleteFilename( "demos", demoExt, qtrue ); +			}  			else if( !Q_stricmp( baseCmd, "rcon" ) && completionArgument == 2 )  			{  				// Skip "rcon " @@ -3078,14 +3130,26 @@ static void Field_CompleteCommand( char *cmd,  				if( p > cmd )  					Field_CompleteCommand( p, qtrue, qtrue );  			} -			else if( !Q_stricmp( baseCmd, "bind" ) && completionArgument >= 3 ) +			else if( !Q_stricmp( baseCmd, "bind" ) )  			{ -				// Skip "bind <key> " -				p = Com_SkipTokens( cmd, 2, " " ); +				if( completionArgument == 2 ) +				{ +					// Skip "bind " +					p = Com_SkipTokens( cmd, 1, " " ); -				if( p > cmd ) -					Field_CompleteCommand( p, qtrue, qtrue ); +					if( p > cmd ) +						Field_CompleteKeyname( ); +				} +				else if( completionArgument >= 3 ) +				{ +					// Skip "bind <key> " +					p = Com_SkipTokens( cmd, 2, " " ); + +					if( p > cmd ) +						Field_CompleteCommand( p, qtrue, qtrue ); +				}  			} +#endif  		}  	}  	else @@ -3106,23 +3170,11 @@ static void Field_CompleteCommand( char *cmd,  			Cvar_CommandCompletion( FindMatches );  		if( matchCount == 0 ) -			return;	// no matches +			return; // no matches -		if( cmd == completionField->buffer ) -		{ -#ifndef DEDICATED -			Com_sprintf( completionField->buffer, -					sizeof( completionField->buffer ), "\\%s", shortestMatch ); -#else -			Com_sprintf( completionField->buffer, -					sizeof( completionField->buffer ), "%s", shortestMatch ); -#endif -		} -		else -		{ -			Q_strcat( completionField->buffer, sizeof( completionField->buffer ), -					shortestMatch + strlen( completionString ) ); -		} +		Q_strncpyz( &completionField->buffer[ strlen( completionField->buffer ) - +			strlen( completionString ) ], shortestMatch, +			sizeof( completionField->buffer ) );  		completionField->cursor = strlen( completionField->buffer ); diff --git a/src/qcommon/cvar.c b/src/qcommon/cvar.c index d39f134e..5503bcc1 100644 --- a/src/qcommon/cvar.c +++ b/src/qcommon/cvar.c @@ -498,9 +498,6 @@ Handles variable inspection and changing from the console  */  qboolean Cvar_Command( void ) {  	cvar_t	*v; -	char		string[ TRUNCATE_LENGTH ]; -	char		resetString[ TRUNCATE_LENGTH ]; -	char		latchedString[ TRUNCATE_LENGTH ];  	// check variables  	v = Cvar_FindVar (Cmd_Argv(0)); @@ -510,25 +507,22 @@ qboolean Cvar_Command( void ) {  	// perform a variable print or set  	if ( Cmd_Argc() == 1 ) { -		Com_TruncateLongString( string, v->string ); -		Com_TruncateLongString( resetString, v->resetString );  		Com_Printf ("\"%s\" is:\"%s" S_COLOR_WHITE "\"", -				v->name, string ); +				v->name, v->string );  		if ( !( v->flags & CVAR_ROM ) ) { -			if ( !Q_stricmp( string, resetString ) ) { +			if ( !Q_stricmp( v->string, v->resetString ) ) {  				Com_Printf (", the default" );  			} else {  				Com_Printf (" default:\"%s" S_COLOR_WHITE "\"", -						resetString ); +						v->resetString );  			}  		}  		Com_Printf ("\n");  		if ( v->latchedString ) { -			Com_TruncateLongString( latchedString, v->latchedString ); -			Com_Printf( "latched: \"%s\"\n", latchedString ); +			Com_Printf( "latched: \"%s\"\n", v->latchedString );  		}  		return qtrue;  	} diff --git a/src/qcommon/q_platform.h b/src/qcommon/q_platform.h index 361526dc..9d0d6dd3 100644 --- a/src/qcommon/q_platform.h +++ b/src/qcommon/q_platform.h @@ -123,6 +123,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  #ifdef __linux__ +#include <endian.h> +  #define OS_STRING "linux"  #define ID_INLINE inline  #define PATH_SEP '/' @@ -171,6 +173,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  #ifdef __FreeBSD__ +#include <sys/types.h>  #include <machine/endian.h>  #define OS_STRING "freebsd" @@ -193,11 +196,37 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  #endif +//=============================================================== OpenBSD === + +#ifdef __OpenBSD__ + +#include <sys/types.h> +#include <machine/endian.h> + +#define OS_STRING "openbsd" +#define ID_INLINE inline +#define PATH_SEP '/' + +#ifdef __i386__ +#define ARCH_STRING "i386" +#endif + +#if BYTE_ORDER == BIG_ENDIAN +#define Q3_BIG_ENDIAN +#else +#define Q3_LITTLE_ENDIAN +#endif + +#define DLL_EXT ".so" + +#endif +  //================================================================ NetBSD ===  // This is very much like the FreeBSD one and can probably be merged  #ifdef __NetBSD__ +#include <sys/types.h>  #include <machine/endian.h>  #define OS_STRING "netbsd" diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index 59332068..d6273d8a 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -916,6 +916,9 @@ void CL_FlushMemory( void );  void CL_StartHunkUsers( qboolean rendererOnly );  // start all the client stuff using the hunk +void Key_KeynameCompletion( void(*callback)(const char *s) ); +// for keyname autocompletion +  void Key_WriteBindings( fileHandle_t f );  // for writing the config files  | 
