summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_buildable.c20
-rw-r--r--src/game/g_local.h25
-rw-r--r--src/game/g_main.c42
3 files changed, 50 insertions, 37 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 11ed8db4..dd81c992 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -23,8 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "g_local.h"
-zone_t zones[ MAX_ZONES ];
-
/*
================
G_SetBuildableAnim
@@ -322,9 +320,9 @@ int G_GetBuildPoints( const vec3_t pos, team_t team, int dist )
}
else if( ent->s.modelindex == BA_H_REPEATER && distance <= REPEATER_BASESIZE + dist )
{
- if( ent->usesZone && zones[ent->zone].active )
+ if( ent->usesZone && level.powerZones[ent->zone].active )
{
- zone_t *zone = &zones[ent->zone];
+ zone_t *zone = &level.powerZones[ent->zone];
buildPoints += zone->totalBuildPoints - zone->queuedBuildPoints;
}
@@ -1684,7 +1682,7 @@ static void HRepeater_Die( gentity_t *self, gentity_t *inflictor, gentity_t *att
if( self->usesZone )
{
- zone_t *zone = &zones[self->zone];
+ zone_t *zone = &level.powerZones[self->zone];
zone->active = qfalse;
self->usesZone = qfalse;
@@ -1732,12 +1730,12 @@ void HRepeater_Think( gentity_t *self )
self->powered = reactor;
// Initialise the zone once the repeater has spawned
- if( self->spawned && ( !self->usesZone || !zones[ self->zone ].active ) )
+ if( self->spawned && ( !self->usesZone || !level.powerZones[ self->zone ].active ) )
{
// See if a free zone exists
- for( i = 0; i < MIN( g_humanRepeaterMaxZones.integer, MAX_ZONES ); i++ )
+ for( i = 0; i < g_humanRepeaterMaxZones.integer; i++ )
{
- zone = &zones[ i ];
+ zone = &level.powerZones[ i ];
if( !zone->active )
{
@@ -1746,7 +1744,7 @@ void HRepeater_Think( gentity_t *self )
zone->nextQueueTime = level.time;
zone->active = qtrue;
- self->zone = zone - zones;
+ self->zone = zone - level.powerZones;
self->usesZone = qtrue;
break;
@@ -2532,9 +2530,9 @@ void G_QueueBuildPoints( gentity_t *self )
break;
case BA_H_REPEATER:
- if( powerEntity->usesZone && zones[powerEntity->zone].active )
+ if( powerEntity->usesZone && level.powerZones[powerEntity->zone].active )
{
- zone_t *zone = &zones[powerEntity->zone];
+ zone_t *zone = &level.powerZones[powerEntity->zone];
if( !zone->queuedBuildPoints )
zone->nextQueueTime = level.time + g_humanRepeaterBuildQueueTime.integer;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index e757653d..9b44d4c4 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -471,6 +471,16 @@ void G_PrintSpawnQueue( spawnQueue_t *sq );
#define MAX_DAMAGE_REGION_TEXT 8192
#define MAX_DAMAGE_REGIONS 16
+// power zone
+typedef struct
+{
+ int active;
+
+ int totalBuildPoints;
+ int queuedBuildPoints;
+ int nextQueueTime;
+} zone_t;
+
// store locational damage regions
typedef struct damageRegion_s
{
@@ -595,6 +605,8 @@ typedef struct
int humanBuildPointQueue;
int humanNextQueueTime;
+ zone_t *powerZones;
+
gentity_t *markedBuildables[ MAX_GENTITIES ];
int numBuildablesForRemoval;
@@ -701,8 +713,6 @@ void G_Physics( gentity_t *ent, int msec );
#define MAX_ALIEN_BBOX 25
-#define MAX_ZONES 1024
-
typedef enum
{
IBE_NONE,
@@ -731,17 +741,6 @@ typedef enum
IBE_MAXERRORS
} itemBuildError_t;
-typedef struct
-{
- int active;
-
- int totalBuildPoints;
- int queuedBuildPoints;
- int nextQueueTime;
-} zone_t;
-
-extern zone_t zones[MAX_ZONES];
-
qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideExit );
gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal,
buildable_t spawn, vec3_t spawnOrigin );
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 02448be4..16a4093d 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1151,14 +1151,14 @@ void G_CalculateBuildPoints( void )
level.numAlienSpawns = 0;
level.numHumanSpawns = 0;
- // Deactivate any unowned zones
- for( i = 0; i < MIN( g_humanRepeaterMaxZones.integer, MAX_ZONES ); i++ )
+ // Deactivate any unused zones
+ for( i = 0; i < g_humanRepeaterMaxZones.integer; i++ )
{
qboolean inUse = qfalse;
- zone_t *zone = &zones[ i ];
+ zone_t *zone = &level.powerZones[ i ];
if( zone->active )
- {
+ {
for( j = MAX_CLIENTS, ent = g_entities + j ; j < level.num_entities ; j++, ent++ )
{
if( ent->s.eType != ET_BUILDABLE )
@@ -1191,9 +1191,9 @@ void G_CalculateBuildPoints( void )
if( ent->s.modelindex != BA_H_REPEATER )
continue;
- if( ent->usesZone && zones[ ent->zone ].active )
+ if( ent->usesZone && level.powerZones[ ent->zone ].active )
{
- zone_t *zone = &zones[ ent->zone ];
+ zone_t *zone = &level.powerZones[ ent->zone ];
zone->totalBuildPoints = g_humanRepeaterBuildPoints.integer;
}
@@ -1240,9 +1240,9 @@ void G_CalculateBuildPoints( void )
break;
case BA_H_REPEATER:
- if( powerEntity->usesZone && zones[powerEntity->zone].active )
+ if( powerEntity->usesZone && level.powerZones[powerEntity->zone].active )
{
- zone_t *zone = &zones[powerEntity->zone];
+ zone_t *zone = &level.powerZones[powerEntity->zone];
zone->totalBuildPoints -= BG_Buildable( buildable )->buildPoints;
powerEntity->s.misc = zone->totalBuildPoints - zone->queuedBuildPoints;
@@ -1261,9 +1261,9 @@ void G_CalculateBuildPoints( void )
if( buildable == BA_H_REPEATER )
{
- if( ent->usesZone && zones[ ent->zone ].active )
+ if( ent->usesZone && level.powerZones[ ent->zone ].active )
{
- zone = &zones[ ent->zone ];
+ zone = &level.powerZones[ ent->zone ];
if( !level.suddenDeath )
{
@@ -2375,6 +2375,7 @@ void CheckCvars( void )
static int lastPasswordModCount = -1;
static int lastMarkDeconModCount = -1;
static int lastSDTimeModCount = -1;
+ static int lastNumZones = 0;
if( g_password.modificationCount != lastPasswordModCount )
{
@@ -2415,6 +2416,23 @@ void CheckCvars( void )
level.suddenDeathBeginTime = g_suddenDeathTime.integer * 60000;
}
+ // If the number of zones changes, we need a new array
+ if( g_humanRepeaterMaxZones.modificationCount != lastNumZones )
+ {
+ zone_t *newZones;
+ size_t newsize = g_humanRepeaterMaxZones.integer * sizeof( zone_t );
+ size_t oldsize = lastNumZones * sizeof( zone_t );
+ newZones = BG_Alloc( newsize );
+ Com_Memset( &newZones[ lastNumZones ], 0, newsize - oldsize );
+ if( level.powerZones )
+ {
+ Com_Memcpy( newZones, level.powerZones, oldsize );
+ BG_Free( level.powerZones );
+ }
+ level.powerZones = newZones;
+ lastNumZones = g_humanRepeaterMaxZones.integer;
+ }
+
level.frameMsec = trap_Milliseconds( );
}
@@ -2489,6 +2507,7 @@ void G_RunFrame( int levelTime )
// get any cvar changes
G_UpdateCvars( );
+ CheckCvars( );
//
// go through all allocated objects
@@ -2604,9 +2623,6 @@ void G_RunFrame( int levelTime )
CheckTeamVote( TEAM_HUMANS );
CheckTeamVote( TEAM_ALIENS );
- // for tracking changes
- CheckCvars( );
-
level.frameMsec = trap_Milliseconds();
}