summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cgame/cg_draw.c16
-rw-r--r--src/cgame/cg_servercmds.c27
-rw-r--r--src/game/bg_public.h6
-rw-r--r--src/game/g_local.h5
-rw-r--r--src/game/g_main.c44
-rw-r--r--src/game/g_spawn.c6
6 files changed, 61 insertions, 43 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 0617580b..0774476a 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -541,12 +541,12 @@ static void CG_DrawStatusBar( void ) {
#define PWR_Y 20
if( ps->stats[ STAT_PTEAM ] == PTE_HUMANS )
{
- int total = cgs.hBuildPointsTotal;
- int allocated = total - cgs.hBuildPoints;
- int powered = total - cgs.hBuildPointsPowered;
+ float total = cgs.hBuildPointsTotal;
+ float allocated = total - cgs.hBuildPoints;
+ float powered = total - cgs.hBuildPointsPowered;
- int awidth = (int)( (float)allocated / ( total / PWR_WIDTH ) );
- int pwidth = (int)( (float)powered / ( total / PWR_WIDTH ) );
+ int awidth = (int)( ( allocated / total ) * PWR_WIDTH );
+ int pwidth = (int)( ( powered / total ) * PWR_WIDTH );
vec4_t bcolor = { 0.5, 0.5, 0.5, 0.5 };
char *s;
@@ -579,10 +579,10 @@ static void CG_DrawStatusBar( void ) {
#define HV_Y 20
if( ps->stats[ STAT_PTEAM ] == PTE_DROIDS )
{
- int total = cgs.dBuildPointsTotal;
- int allocated = total - cgs.dBuildPoints;
+ float total = cgs.dBuildPointsTotal;
+ float allocated = total - cgs.dBuildPoints;
- int awidth = (int)( (float)allocated / ( total / HV_WIDTH ) );
+ int awidth = (int)( ( allocated / total ) * HV_WIDTH );
vec4_t bcolor = { 0.5, 0.5, 0.5, 0.5 };
trap_R_SetColor( bcolor ); // white
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 65e09cd5..4236cafd 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -189,11 +189,12 @@ void CG_SetConfigValues( void ) {
cgs.scores1 = atoi( CG_ConfigString( CS_SCORES1 ) );
cgs.scores2 = atoi( CG_ConfigString( CS_SCORES2 ) );
- cgs.dBuildPoints = atoi( CG_ConfigString( CS_DBPOINTS ) );
- cgs.dBuildPointsTotal = atoi( CG_ConfigString( CS_DTBPOINTS ) );
- cgs.hBuildPoints = atoi( CG_ConfigString( CS_HBPOINTS ) );
- cgs.hBuildPointsTotal = atoi( CG_ConfigString( CS_HTBPOINTS ) );
- cgs.hBuildPointsPowered = atoi( CG_ConfigString( CS_HPBPOINTS ) );
+ sscanf( CG_ConfigString( CS_BUILDPOINTS ),
+ "%d %d %d %d %d", &cgs.dBuildPoints,
+ &cgs.dBuildPointsTotal,
+ &cgs.hBuildPoints,
+ &cgs.hBuildPointsTotal,
+ &cgs.hBuildPointsPowered );
cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) );
if( cgs.gametype == GT_CTF ) {
@@ -276,16 +277,12 @@ static void CG_ConfigStringModified( void ) {
cgs.scores1 = atoi( str );
} else if ( num == CS_SCORES2 ) {
cgs.scores2 = atoi( str );
- } else if ( num == CS_DBPOINTS ) {
- cgs.dBuildPoints = atoi( str );
- } else if ( num == CS_DTBPOINTS ) {
- cgs.dBuildPointsTotal = atoi( str );
- } else if ( num == CS_HBPOINTS ) {
- cgs.hBuildPoints = atoi( str );
- } else if ( num == CS_HTBPOINTS ) {
- cgs.hBuildPointsTotal = atoi( str );
- } else if ( num == CS_HPBPOINTS ) {
- cgs.hBuildPointsPowered = atoi( str );
+ } else if( num == CS_BUILDPOINTS ) {
+ sscanf( str, "%d %d %d %d %d", &cgs.dBuildPoints,
+ &cgs.dBuildPointsTotal,
+ &cgs.hBuildPoints,
+ &cgs.hBuildPointsTotal,
+ &cgs.hBuildPointsPowered );
} else if ( num == CS_LEVEL_START_TIME ) {
cgs.levelStartTime = atoi( str );
} else if ( num == CS_VOTE_TIME ) {
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 01ea379e..f5e5cef1 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -90,11 +90,7 @@
#define CS_ITEMS 27 // string of 0's and 1's that tell which items are present
//TA: extra stuff:
-#define CS_DBPOINTS 28
-#define CS_DTBPOINTS 29
-#define CS_HBPOINTS 30
-#define CS_HTBPOINTS 31
-#define CS_HPBPOINTS 32
+#define CS_BUILDPOINTS 28
#define CS_MODELS 33
#define CS_SOUNDS (CS_MODELS+MAX_MODELS)
diff --git a/src/game/g_local.h b/src/game/g_local.h
index a176e444..bd77686e 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -471,9 +471,7 @@ typedef struct {
int numLiveHumanClients;
int droidBuildPoints;
- int droidBuildPointsTotal;
int humanBuildPoints;
- int humanBuildPointsTotal;
int humanBuildPointsPowered;
} level_locals_t;
@@ -844,6 +842,9 @@ extern vmCvar_t g_enableDust;
extern vmCvar_t g_enableBreath;
extern vmCvar_t g_singlePlayer;
+extern vmCvar_t g_humanBuildPoints;
+extern vmCvar_t g_droidBuildPoints;
+
void trap_Printf( const char *fmt );
void trap_Error( const char *fmt );
int trap_Milliseconds( void );
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 06505ce5..f1877acf 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -86,6 +86,9 @@ vmCvar_t pmove_msec;
vmCvar_t g_rankings;
vmCvar_t g_listEntity;
+//TA
+vmCvar_t g_humanBuildPoints;
+vmCvar_t g_droidBuildPoints;
static cvarTable_t gameCvarTable[] = {
// don't override the cheat state set by the system
@@ -154,6 +157,9 @@ static cvarTable_t gameCvarTable[] = {
{ &g_smoothClients, "g_smoothClients", "1", 0, 0, qfalse},
{ &pmove_fixed, "pmove_fixed", "0", CVAR_SYSTEMINFO, 0, qfalse},
{ &pmove_msec, "pmove_msec", "8", CVAR_SYSTEMINFO, 0, qfalse},
+
+ { &g_humanBuildPoints, "g_humanBuildPoints", "1000", 0, 0, qtrue },
+ { &g_droidBuildPoints, "g_droidBuildPoints", "1000", 0, 0, qtrue },
{ &g_rankings, "g_rankings", "0", 0, 0, qfalse}
};
@@ -500,10 +506,6 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) {
//TA: so the server counts the spawns without a client attached
countSpawns( );
-
- //TA: FIXME: grab these values from a worldspawn variable
- level.humanBuildPoints = level.humanBuildPointsTotal = 1000;
- level.droidBuildPoints = level.droidBuildPointsTotal = 1000;
}
@@ -793,12 +795,14 @@ Recalculate the quantity of building points available to the teams
*/
void calculateBuildPoints( void )
{
- int i;
- int bclass;
+ int i;
+ int bclass;
gentity_t *ent;
+ int localHTP = g_humanBuildPoints.integer,
+ localDTP = g_droidBuildPoints.integer;
- level.humanBuildPoints = level.humanBuildPointsPowered = level.humanBuildPointsTotal;
- level.droidBuildPoints = level.droidBuildPointsTotal;
+ level.humanBuildPoints = level.humanBuildPointsPowered = localHTP;
+ level.droidBuildPoints = localDTP;
for ( i = 1, ent = g_entities + i ; i < level.num_entities ; i++, ent++ )
{
@@ -822,12 +826,26 @@ void calculateBuildPoints( void )
}
}
}
+
+ if( level.humanBuildPoints < 0 )
+ {
+ localHTP -= level.humanBuildPoints;
+ level.humanBuildPointsPowered -= level.humanBuildPoints;
+ level.humanBuildPoints = 0;
+ }
+
+ if( level.humanBuildPoints < 0 )
+ {
+ localDTP -= level.droidBuildPoints;
+ level.droidBuildPoints = 0;
+ }
- trap_SetConfigstring( CS_DBPOINTS, va("%i", level.droidBuildPoints ) );
- trap_SetConfigstring( CS_DTBPOINTS, va("%i", level.droidBuildPointsTotal ) );
- trap_SetConfigstring( CS_HBPOINTS, va("%i", level.humanBuildPoints ) );
- trap_SetConfigstring( CS_HTBPOINTS, va("%i", level.humanBuildPointsTotal ) );
- trap_SetConfigstring( CS_HPBPOINTS, va("%i", level.humanBuildPointsPowered ) );
+ trap_SetConfigstring( CS_BUILDPOINTS,
+ va( "%d %d %d %d %d", level.droidBuildPoints,
+ localDTP,
+ level.humanBuildPoints,
+ localHTP,
+ level.humanBuildPointsPowered ) );
}
diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c
index 7655e442..101a1acb 100644
--- a/src/game/g_spawn.c
+++ b/src/game/g_spawn.c
@@ -619,6 +619,12 @@ void SP_worldspawn( void ) {
G_SpawnString( "gravity", "800", &s );
trap_Cvar_Set( "g_gravity", s );
+ G_SpawnString( "humanBuildPoints", "1000", &s );
+ trap_Cvar_Set( "g_humanBuildPoints", s );
+
+ G_SpawnString( "droidBuildPoints", "1000", &s );
+ trap_Cvar_Set( "g_droidBuildPoints", s );
+
G_SpawnString( "enableDust", "0", &s );
trap_Cvar_Set( "g_enableDust", s );