diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2011-08-07 22:56:21 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:18:12 +0000 |
commit | f8bd44281b3369f667923305768ac7424a960eed (patch) | |
tree | 7082068f558cda75428d6db9bacbcee11fd253b9 /src/game | |
parent | 463ba1cf2b8a458d946bc853038728b12543a09a (diff) |
* (bug 5039) Fix buildables to initialize with the correct normal vector, which should improve falsely self-destructing eggs (/dev/humancontroller)
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/g_active.c | 4 | ||||
-rw-r--r-- | src/game/g_buildable.c | 46 | ||||
-rw-r--r-- | src/game/g_cmds.c | 4 | ||||
-rw-r--r-- | src/game/g_local.h | 2 |
4 files changed, 20 insertions, 36 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index 58034a46..87cb7e94 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -634,10 +634,10 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( ( client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) > BA_NONE ) { int dist = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->buildDist; - vec3_t dummy; + vec3_t dummy, dummy2; if( G_CanBuild( ent, client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, - dist, dummy ) == IBE_NONE ) + dist, dummy, dummy2 ) == IBE_NONE ) client->ps.stats[ STAT_BUILDABLE ] |= SB_VALID_TOGGLEBIT; else client->ps.stats[ STAT_BUILDABLE ] &= ~SB_VALID_TOGGLEBIT; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 7a27e806..0955dd19 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -3358,10 +3358,10 @@ G_CanBuild Checks to see if a buildable can be built ================ */ -itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin ) +itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin, vec3_t normal ) { vec3_t angles; - vec3_t entity_origin, normal; + vec3_t entity_origin; vec3_t mins, maxs; trace_t tr1, tr2, tr3; itemBuildError_t reason = IBE_NONE, tempReason; @@ -3514,10 +3514,9 @@ Spawns a buildable ================ */ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, - const vec3_t origin, const vec3_t angles ) + const vec3_t origin, const vec3_t normal, const vec3_t angles ) { gentity_t *built; - vec3_t normal; vec3_t localOrigin; char readable[ MAX_STRING_CHARS ]; char buildnums[ MAX_STRING_CHARS ]; @@ -3543,28 +3542,6 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, built->buildableTeam = built->s.modelindex2 = BG_Buildable( buildable )->team; BG_BuildableBoundingBox( buildable, built->r.mins, built->r.maxs ); - // detect the buildable's normal vector - if( !builder->client ) - { - // initial base layout created by server - - if( builder->s.origin2[ 0 ] || - builder->s.origin2[ 1 ] || - builder->s.origin2[ 2 ] ) - { - VectorCopy( builder->s.origin2, normal ); - } - else if( BG_Buildable( buildable )->traj == TR_BUOYANCY ) - VectorSet( normal, 0.0f, 0.0f, -1.0f ); - else - VectorSet( normal, 0.0f, 0.0f, 1.0f ); - } - else - { - // in-game building by a player - BG_GetClientNormal( &builder->client->ps, normal ); - } - // when building the initial layout, spawn the entity slightly off its // target surface so that it can be "dropped" onto it if( !builder->client ) @@ -3774,14 +3751,14 @@ G_BuildIfValid qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable ) { float dist; - vec3_t origin; + vec3_t origin, normal; dist = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->buildDist; - switch( G_CanBuild( ent, buildable, dist, origin ) ) + switch( G_CanBuild( ent, buildable, dist, origin, normal ) ) { case IBE_NONE: - G_Build( ent, buildable, origin, ent->s.apos.trBase ); + G_Build( ent, buildable, origin, normal, ent->s.apos.trBase ); return qtrue; case IBE_NOALIENBP: @@ -3854,11 +3831,18 @@ free fall from their spawn points static gentity_t *G_FinishSpawningBuildable( gentity_t *ent, qboolean force ) { trace_t tr; - vec3_t dest; + vec3_t normal, dest; gentity_t *built; buildable_t buildable = ent->s.modelindex; - built = G_Build( ent, buildable, ent->s.pos.trBase, ent->s.angles ); + if( ent->s.origin2[ 0 ] || ent->s.origin2[ 1 ] || ent->s.origin2[ 2 ] ) + VectorCopy( ent->s.origin2, normal ); + else if( BG_Buildable( buildable )->traj == TR_BUOYANCY ) + VectorSet( normal, 0.0f, 0.0f, -1.0f ); + else + VectorSet( normal, 0.0f, 0.0f, 1.0f ); + + built = G_Build( ent, buildable, ent->s.pos.trBase, normal, ent->s.angles ); built->takedamage = qtrue; built->spawned = qtrue; //map entities are already spawned diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 08824996..57cba07a 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -2436,7 +2436,7 @@ void Cmd_Build_f( gentity_t *ent ) char s[ MAX_TOKEN_CHARS ]; buildable_t buildable; float dist; - vec3_t origin; + vec3_t origin, normal; team_t team; if( ent->client->pers.namelog->denyBuild ) @@ -2475,7 +2475,7 @@ void Cmd_Build_f( gentity_t *ent ) ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; //these are the errors displayed when the builder first selects something to use - switch( G_CanBuild( ent, buildable, dist, origin ) ) + switch( G_CanBuild( ent, buildable, dist, origin, normal ) ) { // can place right away, set the blueprint and the valid togglebit case IBE_NONE: diff --git a/src/game/g_local.h b/src/game/g_local.h index 7ea873cd..214f4f25 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -788,7 +788,7 @@ qboolean G_FindCreep( gentity_t *self ); void G_BuildableThink( gentity_t *ent, int msec ); qboolean G_BuildableRange( vec3_t origin, float r, buildable_t buildable ); void G_ClearDeconMarks( void ); -itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin ); +itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin, vec3_t normal ); qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable ); void G_SetBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim, qboolean force ); void G_SetIdleBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ); |