diff options
author | Tim Angus <tim@ngus.net> | 2009-10-03 12:48:20 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:15 +0000 |
commit | 57d89982f823aaf869d3cbb68cf7715df9c14624 (patch) | |
tree | c09d9d6bd3687256fa72289f7c700a100b32ba45 /src/game | |
parent | 9593f89546da90d2d4d9ed80da767b6a5dd442ef (diff) |
* Restructure G_WideTrace a bit
* Fix a load of 1.f style floats to 1.0f
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_pmove.c | 4 | ||||
-rw-r--r-- | src/game/g_buildable.c | 4 | ||||
-rw-r--r-- | src/game/g_cmds.c | 2 | ||||
-rw-r--r-- | src/game/g_combat.c | 2 | ||||
-rw-r--r-- | src/game/g_weapon.c | 58 | ||||
-rw-r--r-- | src/game/tremulous.h | 6 |
6 files changed, 34 insertions, 42 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 0a6f1923..59269469 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -291,8 +291,8 @@ static void PM_Friction( void ) // when landing a dodge, extra friction if( pm->ps->pm_flags & PMF_TIME_LAND ) - friction *= 1.f + HUMAN_LAND_FRICTION * - pm->ps->pm_time / HUMAN_DODGE_TIMEOUT; + friction *= 1.0f + HUMAN_LAND_FRICTION * + pm->ps->pm_time / HUMAN_DODGE_TIMEOUT; control = speed < stopSpeed ? stopSpeed : speed; drop += control * friction * pml.frametime; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 889836cc..8d77267a 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -940,7 +940,7 @@ void ABarricade_Shrink( gentity_t *self, qboolean shrink ) trap_Trace( &tr, self->s.origin, self->r.mins, self->r.maxs, self->s.origin, self->s.number, MASK_PLAYERSOLID ); - if ( tr.startsolid || tr.fraction < 1.f ) + if ( tr.startsolid || tr.fraction < 1.0f ) { self->r.maxs[ 2 ] = (int)( self->r.maxs[ 2 ] * BARRICADE_SHRINKPROP ); return; @@ -3178,7 +3178,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance } //this item does not fit here - if( reason == IBE_NONE && ( tr2.fraction < 1.0 || tr3.fraction < 1.0 ) ) + if( reason == IBE_NONE && ( tr2.fraction < 1.0f || tr3.fraction < 1.0f ) ) reason = IBE_NOROOM; if( reason != IBE_NONE ) diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index ec00c8a4..812f5a83 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -3045,7 +3045,7 @@ void Cmd_Damage_f( gentity_t *ent ) { vec3_t point; char arg[ 16 ]; - float dx = 0.f, dy = 0.f, dz = 100.f; + float dx = 0.0f, dy = 0.0f, dz = 100.0f; int damage = 100; qboolean nonloc = qtrue; diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 2e359ab7..ff1af0bf 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -685,7 +685,7 @@ Returns the damage region given an angle and a height proportion static float GetPointDamageModifier( gentity_t *targ, damageRegion_t *regions, int len, float angle, float height ) { - float modifier = 1.f; + float modifier = 1.0f; int i; for( i = 0; i < len; i++ ) diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 123679da..a7c30d02 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -144,54 +144,46 @@ static void G_WideTrace( trace_t *tr, gentity_t *ent, float range, vec3_t mins, maxs; vec3_t end; - VectorSet( mins, -width, -width, -width ); + VectorSet( mins, -width, -width, -height ); VectorSet( maxs, width, width, width ); - mins[ 2 ] -= height - width; *target = NULL; if( !ent->client ) return; - // Set aiming directions - VectorMA( muzzle, range, forward, end ); + // Try a linear trace first + VectorMA( muzzle, range + width, forward, end ); - G_UnlaggedOn( ent, muzzle, range ); + G_UnlaggedOn( ent, muzzle, range + width ); - //prefer the target in the crosshairs - trap_Trace( tr, muzzle, NULL, NULL, end, ent->s.number, CONTENTS_BODY ); - - // Trace against entities - if( tr->entityNum == ENTITYNUM_NONE ) - trap_Trace( tr, muzzle, mins, maxs, end, ent->s.number, CONTENTS_BODY ); + trap_Trace( tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT ); + if( tr->entityNum != ENTITYNUM_NONE ) + { + // We hit something with the linear trace + *target = &g_entities[ tr->entityNum ]; + } else - //if the first trace hit, we need to set width to 0 to avoid - //"missing" in some rare cases - width = 0; - - // If we started in a solid that means someone is within our muzzle box, - // the trace didn't give us the entity number though so do a trace - // from the entity origin to the muzzle - if( tr->startsolid ) { - trap_Trace( tr, ent->client->ps.origin, mins, maxs, muzzle, - ent->s.number, CONTENTS_BODY ); + // The linear trace didn't hit anything, so retry with a wide trace + VectorMA( muzzle, range, forward, end ); + + // Trace against entities + trap_Trace( tr, muzzle, mins, maxs, end, ent->s.number, CONTENTS_BODY ); if( tr->entityNum != ENTITYNUM_NONE ) + { *target = &g_entities[ tr->entityNum ]; - } - else if( tr->entityNum != ENTITYNUM_NONE ) - { - *target = &g_entities[ tr->entityNum ]; - // Set range to the trace length plus the width, so that the end of the - // LOS trace is close to the exterior of the target's bounding box - range = Distance( muzzle, tr->endpos ) + width; - VectorMA( muzzle, range, forward, end ); + // Set range to the trace length plus the width, so that the end of the + // LOS trace is close to the exterior of the target's bounding box + range = Distance( muzzle, tr->endpos ) + width; + VectorMA( muzzle, range, forward, end ); - // Trace for line of sight against the world - trap_Trace( tr, muzzle, NULL, NULL, end, 0, CONTENTS_SOLID ); - if( tr->fraction < 1.0f ) - *target = NULL; + // Trace for line of sight against the world + trap_Trace( tr, muzzle, NULL, NULL, end, 0, CONTENTS_SOLID ); + if( tr->fraction < 1.0f ) + *target = NULL; + } } G_UnlaggedOff( ); diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 45a64979..7859173e 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -389,8 +389,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define PAINSAW_K_SCALE 1.0f #define PAINSAW_DAMAGE HDM(11) #define PAINSAW_RANGE 64.0f -#define PAINSAW_WIDTH 0.f -#define PAINSAW_HEIGHT 8.f +#define PAINSAW_WIDTH 0.0f +#define PAINSAW_HEIGHT 8.0f #define GRENADE_PRICE 200 #define GRENADE_REPEAT 0 @@ -628,7 +628,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define HUMAN_DODGE_SIDE_MODIFIER 2.9f #define HUMAN_DODGE_UP_MODIFIER 0.5f #define HUMAN_DODGE_TIMEOUT 500 -#define HUMAN_LAND_FRICTION 3.f +#define HUMAN_LAND_FRICTION 3.0f #define STAMINA_STOP_RESTORE 25 #define STAMINA_WALK_RESTORE 15 |