diff options
author | Ben Millwood <thebenmachine@gmail.com> | 2009-10-03 13:00:00 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:23 +0000 |
commit | e385cb197162269da855bba6c9fdce1b418b35bf (patch) | |
tree | 154ad5530b1d256071a0069328055730a7f8fffb /src/game/g_buildable.c | |
parent | 69b6bfc354c10e26debec2a6c468ab7cc41f886f (diff) |
Make next queue time calculation more consistent
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r-- | src/game/g_buildable.c | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 5d40cd15..99f27960 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -2627,23 +2627,35 @@ void G_QueueBuildPoints( gentity_t *self ) if( powerEntity ) { + int nqt; switch( powerEntity->s.modelindex ) { case BA_H_REACTOR: - if( !level.humanBuildPointQueue ) - level.humanNextQueueTime = level.time + g_humanBuildQueueTime.integer; + nqt = G_NextQueueTime( level.humanBuildPointQueue, + g_humanBuildPoints.integer, + g_humanBuildQueueTime.integer ); + if( !level.humanBuildPointQueue || + level.time + nqt < level.humanNextQueueTime ) + level.humanNextQueueTime = level.time + nqt; level.humanBuildPointQueue += BG_Buildable( self->s.modelindex )->buildPoints; break; case BA_H_REPEATER: - if( powerEntity->usesZone && level.powerZones[powerEntity->zone].active ) + if( powerEntity->usesZone && + level.powerZones[ powerEntity->zone ].active ) { - zone_t *zone = &level.powerZones[powerEntity->zone]; + zone_t *zone = &level.powerZones[ powerEntity->zone ]; + + nqt = G_NextQueueTime( zone->queuedBuildPoints, + zone->totalBuildPoints, + g_humanRepeaterBuildQueueTime.integer ); + + if( !zone->queuedBuildPoints || + level.time + nqt < zone->nextQueueTime ) + zone->nextQueueTime = level.time + nqt; - if( !zone->queuedBuildPoints ) - zone->nextQueueTime = level.time + g_humanRepeaterBuildQueueTime.integer; zone->queuedBuildPoints += BG_Buildable( self->s.modelindex )->buildPoints; } @@ -2666,6 +2678,22 @@ void G_QueueBuildPoints( gentity_t *self ) /* ============ +G_NextQueueTime +============ +*/ +int G_NextQueueTime( int queuedBP, int totalBP, int queueBaseRate ) +{ + float fractionQueued; + + if( totalBP == 0 ) + return 0; + + fractionQueued = queuedBP / (float)totalBP; + return ( 1.0f - fractionQueued ) * queueBaseRate; +} + +/* +============ G_BuildableTouchTriggers Find all trigger entities that a buildable touches. |