diff options
-rw-r--r-- | src/cgame/cg_ents.c | 105 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 3 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 25 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 10 | ||||
-rw-r--r-- | src/game/g_main.c | 2 | ||||
-rw-r--r-- | src/game/g_misc.c | 44 |
6 files changed, 177 insertions, 12 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index b9041eff..6b9eb60c 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -17,6 +17,95 @@ #include "cg_local.h" +/* +====================== +CG_DrawBoxFace + +Draws a bounding box face +====================== +*/ +static void CG_DrawBoxFace( vec3_t a, vec3_t b, vec3_t c, vec3_t d ) +{ + polyVert_t verts[ 4 ]; + vec4_t color = { 255.0f, 0.0f, 0.0f, 128.0f }; + + VectorCopy( d, verts[ 0 ].xyz ); + verts[ 0 ].st[ 0 ] = 1; + verts[ 0 ].st[ 1 ] = 1; + Vector4Copy( color, verts[ 0 ].modulate ); + + VectorCopy( c, verts[ 1 ].xyz ); + verts[ 1 ].st[ 0 ] = 1; + verts[ 1 ].st[ 1 ] = 0; + Vector4Copy( color, verts[ 1 ].modulate ); + + VectorCopy( b, verts[ 2 ].xyz ); + verts[ 2 ].st[ 0 ] = 0; + verts[ 2 ].st[ 1 ] = 0; + Vector4Copy( color, verts[ 2 ].modulate ); + + VectorCopy( a, verts[ 3 ].xyz ); + verts[ 3 ].st[ 0 ] = 0; + verts[ 3 ].st[ 1 ] = 1; + Vector4Copy( color, verts[ 3 ].modulate ); + + trap_R_AddPolyToScene( cgs.media.outlineShader, 4, verts ); +} + +/* +====================== +CG_DrawBoundingBox + +Draws a bounding box +====================== +*/ +void CG_DrawBoundingBox( vec3_t origin, vec3_t mins, vec3_t maxs ) +{ + vec3_t ppp, mpp, mmp, pmp; + vec3_t mmm, pmm, ppm, mpm; + + ppp[ 0 ] = origin[ 0 ] + maxs[ 0 ]; + ppp[ 1 ] = origin[ 1 ] + maxs[ 1 ]; + ppp[ 2 ] = origin[ 2 ] + maxs[ 2 ]; + + mpp[ 0 ] = origin[ 0 ] + mins[ 0 ]; + mpp[ 1 ] = origin[ 1 ] + maxs[ 1 ]; + mpp[ 2 ] = origin[ 2 ] + maxs[ 2 ]; + + mmp[ 0 ] = origin[ 0 ] + mins[ 0 ]; + mmp[ 1 ] = origin[ 1 ] + mins[ 1 ]; + mmp[ 2 ] = origin[ 2 ] + maxs[ 2 ]; + + pmp[ 0 ] = origin[ 0 ] + maxs[ 0 ]; + pmp[ 1 ] = origin[ 1 ] + mins[ 1 ]; + pmp[ 2 ] = origin[ 2 ] + maxs[ 2 ]; + + ppm[ 0 ] = origin[ 0 ] + maxs[ 0 ]; + ppm[ 1 ] = origin[ 1 ] + maxs[ 1 ]; + ppm[ 2 ] = origin[ 2 ] + mins[ 2 ]; + + mpm[ 0 ] = origin[ 0 ] + mins[ 0 ]; + mpm[ 1 ] = origin[ 1 ] + maxs[ 1 ]; + mpm[ 2 ] = origin[ 2 ] + mins[ 2 ]; + + mmm[ 0 ] = origin[ 0 ] + mins[ 0 ]; + mmm[ 1 ] = origin[ 1 ] + mins[ 1 ]; + mmm[ 2 ] = origin[ 2 ] + mins[ 2 ]; + + pmm[ 0 ] = origin[ 0 ] + maxs[ 0 ]; + pmm[ 1 ] = origin[ 1 ] + mins[ 1 ]; + pmm[ 2 ] = origin[ 2 ] + mins[ 2 ]; + + //phew! + + CG_DrawBoxFace( ppp, mpp, mmp, pmp ); + CG_DrawBoxFace( ppp, pmp, pmm, ppm ); + CG_DrawBoxFace( mpp, ppp, ppm, mpm ); + CG_DrawBoxFace( mmp, mpp, mpm, mmm ); + CG_DrawBoxFace( pmp, mmp, mmm, pmm ); + CG_DrawBoxFace( mmm, mpm, ppm, pmm ); +} + /* ====================== @@ -465,7 +554,15 @@ static void CG_LightFlare( centity_t *cent ) //flare is "off" if( es->eFlags & EF_NODRAW ) return; + + CG_Trace( &tr, cg.refdef.vieworg, NULL, NULL, es->angles2, + cg.predictedPlayerState.clientNum, MASK_SHOT ); + //if there is no los between the view and the flare source + //it definately cannot be seen + if( tr.fraction < 1.0f || tr.allsolid ) + return; + memset( &flare, 0, sizeof( flare ) ); //bunch of geometry @@ -512,7 +609,9 @@ static void CG_LightFlare( centity_t *cent ) VectorSubtract( cg.refdef.vieworg, flare.origin, dir ); VectorNormalize( dir ); VectorMA( flare.origin, flare.radius, dir, end ); - VectorCopy( cg.refdef.vieworg, start ); + /*VectorCopy( flare.origin, end );*/ + VectorMA( cg.refdef.vieworg, -flare.radius, dir, start ); + /*VectorCopy( cg.refdef.vieworg, start );*/ if( cg_lightFlare.integer == FLARE_REALFADE ) { @@ -548,7 +647,7 @@ static void CG_LightFlare( centity_t *cent ) else if( cg_lightFlare.integer == FLARE_TIMEFADE ) { //draw timed flares - SETBOUNDS( mins, maxs, srcRadius / 2.0f ); + SETBOUNDS( mins, maxs, srcRadius ); CG_Trace( &tr, start, mins, maxs, end, cg.predictedPlayerState.clientNum, MASK_SHOT ); @@ -585,7 +684,7 @@ static void CG_LightFlare( centity_t *cent ) else if( cg_lightFlare.integer == FLARE_NOFADE ) { //draw nofade flares - SETBOUNDS( mins, maxs, srcRadius / 2.0f ); + SETBOUNDS( mins, maxs, srcRadius ); CG_Trace( &tr, start, mins, maxs, end, cg.predictedPlayerState.clientNum, MASK_SHOT ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 87416b2f..f571f0bf 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -758,6 +758,7 @@ typedef struct { qhandle_t charsetShader; qhandle_t whiteShader; + qhandle_t outlineShader; qhandle_t deferShader; @@ -1141,6 +1142,7 @@ extern vmCvar_t ui_loading; const char *CG_ConfigString( int index ); const char *CG_Argv( int arg ); +void TAUIConsole( const char *text ); void QDECL CG_Printf( const char *msg, ... ); void QDECL CG_Error( const char *msg, ... ); @@ -1284,6 +1286,7 @@ void CG_PainEvent( centity_t *cent, int health ); // // cg_ents.c // +void CG_DrawBoundingBox( vec3_t origin, vec3_t mins, vec3_t maxs ); void CG_SetEntitySoundPosition( centity_t *cent ); void CG_AddPacketEntities( void ); void CG_Beam( centity_t *cent ); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index ab50ac9b..cc7ec184 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -445,16 +445,9 @@ void CG_RemoveConsoleLine( void ) cg.numConsoleLines--; } -void QDECL CG_Printf( const char *msg, ... ) +//TA: team arena UI based console +void TAUIConsole( const char *text ) { - va_list argptr; - char text[ 1024 ]; - - va_start( argptr, msg ); - vsprintf( text, msg, argptr ); - va_end( argptr ); - - //TA: team arena UI based console if( cg.numConsoleLines == MAX_CONSOLE_LINES ) CG_RemoveConsoleLine( ); @@ -466,6 +459,19 @@ void QDECL CG_Printf( const char *msg, ... ) cg.numConsoleLines++; } +} + +void QDECL CG_Printf( const char *msg, ... ) +{ + va_list argptr; + char text[ 1024 ]; + + va_start( argptr, msg ); + vsprintf( text, msg, argptr ); + va_end( argptr ); + + TAUIConsole( text ); + trap_Print( text ); } @@ -1613,6 +1619,7 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) // load a few needed things before we do any screen updates cgs.media.whiteShader = trap_R_RegisterShader( "white" ); cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" ); + cgs.media.outlineShader = trap_R_RegisterShader( "outline" ); //inform UI to repress cursor whilst loading trap_Cvar_Set( "ui_loading", "1" ); diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 3af04eda..04c591cb 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -600,6 +600,16 @@ static void CG_ServerCommand( void ) return; } + //enable G_Printfs from the server to appear in the TA console + if( !strcmp( cmd, "gprintf" ) ) + { + if( trap_Argc( ) == 2 ) + { + TAUIConsole( CG_Argv( 1 ) ); + return; + } + } + CG_Printf( "Unknown client game command: %s\n", cmd ); } diff --git a/src/game/g_main.c b/src/game/g_main.c index edefb98d..d77abc86 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -241,6 +241,8 @@ void QDECL G_Printf( const char *fmt, ... ) vsprintf( text, fmt, argptr ); va_end( argptr ); + trap_SendServerCommand( -1, va( "gprintf \"%s\"", text ) ); + trap_Printf( text ); } diff --git a/src/game/g_misc.c b/src/game/g_misc.c index 2d35e73c..7004d041 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -458,12 +458,56 @@ void SP_use_light_flare( gentity_t *self, gentity_t *other, gentity_t *activator self->s.eFlags ^= EF_NODRAW; } +//TA: finds an empty spot radius units from origin +static void findEmptySpot( vec3_t origin, float radius, vec3_t spot ) +{ + int i, j, k; + vec3_t delta, test, total; + trace_t tr; + + VectorClear( total ); + + //54(!) traces to test for empty spots + for( i = -1; i <= 1; i++ ) + { + for( j = -1; j <= 1; j++ ) + { + for( k = -1; k <= 1; k++ ) + { + VectorSet( delta, ( i * radius ), + ( j * radius ), + ( k * radius ) ); + + VectorAdd( origin, delta, test ); + + trap_Trace( &tr, test, NULL, NULL, test, -1, MASK_SOLID ); + + if( !tr.allsolid ) + { + trap_Trace( &tr, test, NULL, NULL, origin, -1, MASK_SOLID ); + VectorScale( delta, tr.fraction, delta ); + VectorAdd( total, delta, total ); + } + } + } + } + + VectorNormalize( total ); + VectorScale( total, radius, total ); + VectorAdd( origin, total, spot ); +} + //TA: spawn function for light flares void SP_misc_light_flare( gentity_t *self ) { self->s.eType = ET_LIGHTFLARE; self->s.modelindex = G_ShaderIndex( self->targetShaderName ); VectorCopy( self->pos2, self->s.origin2 ); + + //try to find a spot near to the flare which is empty. This + //is used to facilitate visibility testing + findEmptySpot( self->s.origin, 8.0f, self->s.angles2 ); + self->use = SP_use_light_flare; G_SpawnFloat( "speed", "200", &self->speed ); |