From e385cb197162269da855bba6c9fdce1b418b35bf Mon Sep 17 00:00:00 2001 From: Ben Millwood Date: Sat, 3 Oct 2009 13:00:00 +0000 Subject: Make next queue time calculation more consistent --- src/game/g_buildable.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'src/game/g_buildable.c') 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; } @@ -2664,6 +2676,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 -- cgit