diff options
author | Tim Angus <tim@ngus.net> | 2009-10-04 22:40:52 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:39 +0000 |
commit | aede0859509b743e8a76c2ad055ae94d0545af88 (patch) | |
tree | 16942dbb3df86891aad9b89e88a7fd427f607680 | |
parent | ea0ff0071ed313c479693f1d2e1b9a2da167a891 (diff) |
* Reduce generic1 to 10 bits
* Remove buildable health scaling/masking stuff; 10 bits is plenty now
* Potentially fix bug where many PVS entering buildables would inappropriately
make damaged sounds
-rw-r--r-- | src/cgame/cg_buildable.c | 16 | ||||
-rw-r--r-- | src/cgame/cg_ents.c | 4 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 2 | ||||
-rw-r--r-- | src/cgame/cg_tutorial.c | 4 | ||||
-rw-r--r-- | src/game/bg_public.h | 3 | ||||
-rw-r--r-- | src/game/g_buildable.c | 38 | ||||
-rw-r--r-- | src/qcommon/msg.c | 4 |
7 files changed, 33 insertions, 38 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 1f882a3a..db6eb539 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -633,8 +633,8 @@ static void CG_BuildableParticleEffects( centity_t *cent ) { entityState_t *es = ¢->currentState; team_t team = BG_Buildable( es->modelindex )->team; - int health = es->generic1 & B_HEALTH_MASK; - float healthFrac = (float)health / B_HEALTH_MASK; + int health = es->generic1; + float healthFrac = (float)health / BG_Buildable( es->modelindex )->health; if( !( es->eFlags & EF_B_SPAWNED ) ) return; @@ -955,8 +955,8 @@ static void CG_BuildableStatusDisplay( centity_t *cent ) return; } - health = es->generic1 & B_HEALTH_MASK; - healthScale = (float)health / B_HEALTH_MASK; + health = es->generic1; + healthScale = (float)health / BG_Buildable( es->modelindex )->health; if( health > 0 && healthScale < 0.01f ) healthScale = 0.01f; @@ -1412,10 +1412,10 @@ void CG_Buildable( centity_t *cent ) trap_S_AddLoopingSound( es->number, cent->lerpOrigin, vec3_origin, weapon->readySound ); } - health = es->generic1 & B_HEALTH_MASK; - healthScale = (float)health / B_HEALTH_MASK; + health = es->generic1; + healthScale = (float)health / BG_Buildable( es->modelindex )->health; - if( healthScale < cent->lastBuildableHealthScale && + if( health < cent->lastBuildableHealth && ( es->eFlags & EF_B_SPAWNED ) ) { if( cent->lastBuildableDamageSoundTime + BUILDABLE_SOUND_PERIOD < cg.time ) @@ -1432,7 +1432,7 @@ void CG_Buildable( centity_t *cent ) } } - cent->lastBuildableHealthScale = healthScale; + cent->lastBuildableHealth = health; //smoke etc for damaged buildables CG_BuildableParticleEffects( cent ); diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index eed57686..96e5faf6 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -1015,6 +1015,10 @@ static void CG_CEntityPVSEnter( centity_t *cent ) case ET_MISSILE: CG_LaunchMissile( cent ); break; + + case ET_BUILDABLE: + cent->lastBuildableHealth = es->generic1; + break; } //clear any particle systems from previous uses of this centity_t diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 68895d72..6b87f7c2 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -650,7 +650,7 @@ typedef struct centity_s particleSystem_t *buildablePS; buildableStatus_t buildableStatus; buildableCache_t buildableCache; // so we don't recalculate things - float lastBuildableHealthScale; + float lastBuildableHealth; int lastBuildableDamageSoundTime; lightFlareStatus_t lfs; diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c index 8db27d23..75bca690 100644 --- a/src/cgame/cg_tutorial.c +++ b/src/cgame/cg_tutorial.c @@ -156,8 +156,8 @@ static entityState_t *CG_BuildableInRange( playerState_t *ps, float *healthFract if( healthFraction ) { - health = es->generic1 & B_HEALTH_MASK; - *healthFraction = (float)health / B_HEALTH_MASK; + health = es->generic1; + *healthFraction = (float)health / BG_Buildable( es->modelindex )->health; } if( es->eType == ET_BUILDABLE && diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 2e382247..22391537 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -420,9 +420,6 @@ typedef enum BA_NUM_BUILDABLES } buildable_t; -#define B_HEALTH_BITS 12 -#define B_HEALTH_MASK ((1<<B_HEALTH_BITS)-1) - // reward sounds (stored in ps->persistant[PERS_PLAYEREVENTS]) #define PLAYEREVENT_DENIEDREWARD 0x0001 #define PLAYEREVENT_GAUNTLETREWARD 0x0002 diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index ab9d9afd..a29997e1 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -2737,14 +2737,14 @@ General think function for buildables */ void G_BuildableThink( gentity_t *ent, int msec ) { - int bHealth = BG_Buildable( ent->s.modelindex )->health; - int bRegen = BG_Buildable( ent->s.modelindex )->regenRate; - int bTime = BG_Buildable( ent->s.modelindex )->buildTime; + int maxHealth = BG_Buildable( ent->s.modelindex )->health; + int regenRate = BG_Buildable( ent->s.modelindex )->regenRate; + int buildTime = BG_Buildable( ent->s.modelindex )->buildTime; //toggle spawned flag for buildables if( !ent->spawned && ent->health > 0 ) { - if( ent->buildTime + bTime < level.time ) + if( ent->buildTime + buildTime < level.time ) ent->spawned = qtrue; } @@ -2755,13 +2755,13 @@ void G_BuildableThink( gentity_t *ent, int msec ) ent->time1000 -= 1000; if( !ent->spawned && ent->health > 0 ) - ent->health += (int)( ceil( (float)bHealth / (float)( bTime * 0.001 ) ) ); - else if( ent->health > 0 && ent->health < bHealth ) + ent->health += (int)( ceil( (float)maxHealth / (float)( buildTime * 0.001f ) ) ); + else if( ent->health > 0 && ent->health < maxHealth ) { - if( ent->buildableTeam == TEAM_ALIENS && bRegen && + if( ent->buildableTeam == TEAM_ALIENS && regenRate && ( ent->lastDamageTime + ALIEN_REGEN_DAMAGE_TIME ) < level.time ) { - ent->health += bRegen; + ent->health += regenRate; } else if( ent->buildableTeam == TEAM_HUMANS && ent->dcc && ( ent->lastDamageTime + HUMAN_REGEN_DAMAGE_TIME ) < level.time ) @@ -2770,10 +2770,10 @@ void G_BuildableThink( gentity_t *ent, int msec ) } } - if( ent->health >= bHealth ) + if( ent->health >= maxHealth ) { int i; - ent->health = bHealth; + ent->health = maxHealth; for( i = 0; i < MAX_CLIENTS; i++ ) ent->credits[ i ] = 0; } @@ -2786,15 +2786,10 @@ void G_BuildableThink( gentity_t *ent, int msec ) if( ent->clientSpawnTime < 0 ) ent->clientSpawnTime = 0; - // Pack health ent->dcc = ( ent->buildableTeam != TEAM_HUMANS ) ? 0 : G_FindDCC( ent ); - if( ent->health > 0 ) - { - ent->s.generic1 = (int)( ( ent->health + bHealth / B_HEALTH_MASK - 1 ) * - B_HEALTH_MASK / bHealth ); - } - else - ent->s.generic1 = 0; + + // Set health + ent->s.generic1 = ent->health; // Set flags ent->s.eFlags &= ~( EF_B_POWERED | EF_B_SPAWNED | EF_B_MARKED ); @@ -2807,10 +2802,10 @@ void G_BuildableThink( gentity_t *ent, int msec ) if( ent->deconstruct ) ent->s.eFlags |= EF_B_MARKED; - //check if this buildable is touching any triggers + // Check if this buildable is touching any triggers G_BuildableTouchTriggers( ent ); - //fall back on normal physics routines + // Fall back on normal physics routines G_Physics( ent, msec ); } @@ -3646,8 +3641,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori built->physicsBounce = BG_Buildable( buildable )->bounce; built->s.groundEntityNum = -1; - built->s.generic1 = (int)( ( (float)built->health / - (float)BG_Buildable( buildable )->health ) * B_HEALTH_MASK ); + built->s.generic1 = built->health; if( built->s.generic1 < 0 ) built->s.generic1 = 0; diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c index 34434d15..3d3355ec 100644 --- a/src/qcommon/msg.c +++ b/src/qcommon/msg.c @@ -823,7 +823,7 @@ netField_t entityStateFields[] = { NETF(modelindex), 8 }, { NETF(otherEntityNum2), GENTITYNUM_BITS }, { NETF(loopSound), 8 }, -{ NETF(generic1), 16 }, +{ NETF(generic1), 10 }, { NETF(origin2[2]), 0 }, { NETF(origin2[0]), 0 }, { NETF(origin2[1]), 0 }, @@ -1140,7 +1140,7 @@ netField_t playerStateFields[] = { PSF(damageCount), 8 }, { PSF(ammo), 12 }, { PSF(clips), 4 }, -{ PSF(generic1), 16 }, +{ PSF(generic1), 10 }, { PSF(pm_type), 8 }, { PSF(delta_angles[0]), 16 }, { PSF(delta_angles[2]), 16 }, |