summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM. Kristall <mkpdev@gmail.com>2011-01-10 21:37:03 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:17:50 +0000
commitbb4db330cb3f223ee786a57cfd2b603c1bfa053e (patch)
tree68079fe3dc0abc170bc70d48d191f077d2cd2958
parentc84830d8405dbd2fd262a302d8ec8af2579ad5cc (diff)
* g_disabled* cvars are used by ui but were not communicated to the client
* Don't let maps set {alien,human}BuildPoints since that's probably not good * Let maps set temporary variables instead of cvars (for e.g., gravity)
-rw-r--r--src/game/g_active.c2
-rw-r--r--src/game/g_local.h9
-rw-r--r--src/game/g_main.c96
-rw-r--r--src/game/g_mover.c2
-rw-r--r--src/game/g_spawn.c38
-rw-r--r--src/game/g_trigger.c2
6 files changed, 94 insertions, 55 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 521d6765..697800f6 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -1347,7 +1347,7 @@ void ClientThink_real( gentity_t *ent )
client->lastPoisonTime + ALIEN_POISON_TIME < level.time )
client->ps.stats[ STAT_STATE ] &= ~SS_POISONED;
- client->ps.gravity = g_gravity.value;
+ client->ps.gravity = level.gravity;
if( BG_InventoryContainsUpgrade( UP_MEDKIT, client->ps.stats ) &&
BG_UpgradeIsActive( UP_MEDKIT, client->ps.stats ) )
diff --git a/src/game/g_local.h b/src/game/g_local.h
index bd6ac4ba..8f1a6502 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -624,6 +624,15 @@ typedef struct
gentity_t *markedBuildables[ MAX_GENTITIES ];
int numBuildablesForRemoval;
+ // map/cvar-set values
+ float gravity;
+ int humanMaxStage;
+ int humanStage2Threshold;
+ int humanStage3Threshold;
+ int alienMaxStage;
+ int alienStage2Threshold;
+ int alienStage3Threshold;
+
int alienKills;
int humanKills;
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 4cb83552..01292c66 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -33,6 +33,7 @@ typedef struct
int cvarFlags;
int modificationCount; // for tracking changes
qboolean trackChange; // track this variable, and announce if changed
+ void (*update)( const char *, vmCvar_t * );
} cvarTable_t;
gentity_t g_entities[ MAX_GENTITIES ];
@@ -138,6 +139,14 @@ vmCvar_t g_censorship;
vmCvar_t g_tag;
+static void G_cvgravity( const char *name, vmCvar_t *cvar );
+static void G_cvhumanMaxStage( const char *name, vmCvar_t *cvar );
+static void G_cvhumanStage2Threshold( const char *name, vmCvar_t *cvar );
+static void G_cvhumanStage3Threshold( const char *name, vmCvar_t *cvar );
+static void G_cvalienMaxStage( const char *name, vmCvar_t *cvar );
+static void G_cvalienStage2Threshold( const char *name, vmCvar_t *cvar );
+static void G_cvalienStage3Threshold( const char *name, vmCvar_t *cvar );
+
static cvarTable_t gameCvarTable[ ] =
{
// don't override the cheat state set by the system
@@ -181,7 +190,7 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_dedicated, "dedicated", "0", 0, 0, qfalse },
{ &g_speed, "g_speed", "320", 0, 0, qtrue },
- { &g_gravity, "g_gravity", "800", 0, 0, qtrue },
+ { &g_gravity, "g_gravity", "800", 0, 0, qtrue, G_cvgravity },
{ &g_knockback, "g_knockback", "1000", 0, 0, qtrue },
{ &g_inactivity, "g_inactivity", "0", 0, 0, qtrue },
{ &g_debugMove, "g_debugMove", "0", 0, 0, qfalse },
@@ -208,22 +217,22 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_humanRepeaterBuildQueueTime, "g_humanRepeaterBuildQueueTime", DEFAULT_HUMAN_REPEATER_QUEUE_TIME, CVAR_ARCHIVE, 0, qfalse },
{ &g_humanStage, "g_humanStage", "0", 0, 0, qfalse },
{ &g_humanCredits, "g_humanCredits", "0", 0, 0, qfalse },
- { &g_humanMaxStage, "g_humanMaxStage", DEFAULT_HUMAN_MAX_STAGE, 0, 0, qfalse },
- { &g_humanStage2Threshold, "g_humanStage2Threshold", DEFAULT_HUMAN_STAGE2_THRESH, 0, 0, qfalse },
- { &g_humanStage3Threshold, "g_humanStage3Threshold", DEFAULT_HUMAN_STAGE3_THRESH, 0, 0, qfalse },
+ { &g_humanMaxStage, "g_humanMaxStage", DEFAULT_HUMAN_MAX_STAGE, 0, 0, qfalse, G_cvhumanMaxStage },
+ { &g_humanStage2Threshold, "g_humanStage2Threshold", DEFAULT_HUMAN_STAGE2_THRESH, 0, 0, qfalse, G_cvhumanStage2Threshold },
+ { &g_humanStage3Threshold, "g_humanStage3Threshold", DEFAULT_HUMAN_STAGE3_THRESH, 0, 0, qfalse, G_cvhumanStage3Threshold },
{ &g_alienStage, "g_alienStage", "0", 0, 0, qfalse },
{ &g_alienCredits, "g_alienCredits", "0", 0, 0, qfalse },
- { &g_alienMaxStage, "g_alienMaxStage", DEFAULT_ALIEN_MAX_STAGE, 0, 0, qfalse },
- { &g_alienStage2Threshold, "g_alienStage2Threshold", DEFAULT_ALIEN_STAGE2_THRESH, 0, 0, qfalse },
- { &g_alienStage3Threshold, "g_alienStage3Threshold", DEFAULT_ALIEN_STAGE3_THRESH, 0, 0, qfalse },
+ { &g_alienMaxStage, "g_alienMaxStage", DEFAULT_ALIEN_MAX_STAGE, 0, 0, qfalse, G_cvalienMaxStage },
+ { &g_alienStage2Threshold, "g_alienStage2Threshold", DEFAULT_ALIEN_STAGE2_THRESH, 0, 0, qfalse, G_cvalienStage2Threshold },
+ { &g_alienStage3Threshold, "g_alienStage3Threshold", DEFAULT_ALIEN_STAGE3_THRESH, 0, 0, qfalse, G_cvalienStage3Threshold },
{ &g_teamImbalanceWarnings, "g_teamImbalanceWarnings", "30", CVAR_ARCHIVE, 0, qfalse },
{ &g_freeFundPeriod, "g_freeFundPeriod", DEFAULT_FREEKILL_PERIOD, CVAR_ARCHIVE, 0, qtrue },
{ &g_unlagged, "g_unlagged", "1", CVAR_SERVERINFO | CVAR_ARCHIVE, 0, qtrue },
- { &g_disabledEquipment, "g_disabledEquipment", "", CVAR_ROM, 0, qfalse },
- { &g_disabledClasses, "g_disabledClasses", "", CVAR_ROM, 0, qfalse },
- { &g_disabledBuildables, "g_disabledBuildables", "", CVAR_ROM, 0, qfalse },
+ { &g_disabledEquipment, "g_disabledEquipment", "", CVAR_ROM | CVAR_SYSTEMINFO, 0, qfalse },
+ { &g_disabledClasses, "g_disabledClasses", "", CVAR_ROM | CVAR_SYSTEMINFO, 0, qfalse },
+ { &g_disabledBuildables, "g_disabledBuildables", "", CVAR_ROM | CVAR_SYSTEMINFO, 0, qfalse },
{ &g_sayAreaRange, "g_sayAreaRange", "1000", CVAR_ARCHIVE, 0, qtrue },
@@ -330,6 +339,35 @@ Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, i
return -1;
}
+static void G_cvgravity( const char *name, vmCvar_t *cvar )
+{
+ level.gravity = cvar->value;
+}
+static void G_cvhumanMaxStage( const char *name, vmCvar_t *cvar )
+{
+ level.humanMaxStage = cvar->integer;
+}
+static void G_cvhumanStage2Threshold( const char *name, vmCvar_t *cvar )
+{
+ level.humanStage2Threshold = cvar->integer;
+}
+static void G_cvhumanStage3Threshold( const char *name, vmCvar_t *cvar )
+{
+ level.humanStage3Threshold = cvar->integer;
+}
+static void G_cvalienMaxStage( const char *name, vmCvar_t *cvar )
+{
+ level.alienMaxStage = cvar->integer;
+}
+static void G_cvalienStage2Threshold( const char *name, vmCvar_t *cvar )
+{
+ level.alienStage2Threshold = cvar->integer;
+}
+static void G_cvalienStage3Threshold( const char *name, vmCvar_t *cvar )
+{
+ level.alienStage3Threshold = cvar->integer;
+}
+
void QDECL G_Printf( const char *fmt, ... )
{
@@ -440,6 +478,9 @@ void G_RegisterCvars( void )
if( cv->vmCvar )
cv->modificationCount = cv->vmCvar->modificationCount;
+
+ if( cv->update )
+ cv->update( cv->cvarName, cv->vmCvar );
}
}
@@ -466,6 +507,9 @@ void G_UpdateCvars( void )
if( cv->trackChange )
trap_SendServerCommand( -1, va( "print \"Server: %s changed to %s\n\"",
cv->cvarName, cv->vmCvar->string ) );
+
+ if( cv->update )
+ cv->update( cv->cvarName, cv->vmCvar );
}
}
}
@@ -1232,8 +1276,8 @@ void G_CalculateStages( void )
humanPlayerCountMod = 0.1f;
if( g_alienCredits.integer >=
- (int)( ceil( (float)g_alienStage2Threshold.integer * alienPlayerCountMod ) ) &&
- g_alienStage.integer == S1 && g_alienMaxStage.integer > S1 )
+ (int)( ceil( (float)level.alienStage2Threshold * alienPlayerCountMod ) ) &&
+ g_alienStage.integer == S1 && level.alienMaxStage > S1 )
{
trap_Cvar_Set( "g_alienStage", va( "%d", S2 ) );
level.alienStage2Time = level.time;
@@ -1242,8 +1286,8 @@ void G_CalculateStages( void )
}
if( g_alienCredits.integer >=
- (int)( ceil( (float)g_alienStage3Threshold.integer * alienPlayerCountMod ) ) &&
- g_alienStage.integer == S2 && g_alienMaxStage.integer > S2 )
+ (int)( ceil( (float)level.alienStage3Threshold * alienPlayerCountMod ) ) &&
+ g_alienStage.integer == S2 && level.alienMaxStage > S2 )
{
trap_Cvar_Set( "g_alienStage", va( "%d", S3 ) );
level.alienStage3Time = level.time;
@@ -1252,8 +1296,8 @@ void G_CalculateStages( void )
}
if( g_humanCredits.integer >=
- (int)( ceil( (float)g_humanStage2Threshold.integer * humanPlayerCountMod ) ) &&
- g_humanStage.integer == S1 && g_humanMaxStage.integer > S1 )
+ (int)( ceil( (float)level.humanStage2Threshold * humanPlayerCountMod ) ) &&
+ g_humanStage.integer == S1 && level.humanMaxStage > S1 )
{
trap_Cvar_Set( "g_humanStage", va( "%d", S2 ) );
level.humanStage2Time = level.time;
@@ -1262,8 +1306,8 @@ void G_CalculateStages( void )
}
if( g_humanCredits.integer >=
- (int)( ceil( (float)g_humanStage3Threshold.integer * humanPlayerCountMod ) ) &&
- g_humanStage.integer == S2 && g_humanMaxStage.integer > S2 )
+ (int)( ceil( (float)level.humanStage3Threshold * humanPlayerCountMod ) ) &&
+ g_humanStage.integer == S2 && level.humanMaxStage > S2 )
{
trap_Cvar_Set( "g_humanStage", va( "%d", S3 ) );
level.humanStage3Time = level.time;
@@ -1295,17 +1339,17 @@ void G_CalculateStages( void )
lastHumanStageModCount = g_humanStage.modificationCount;
}
- if( g_alienStage.integer == S1 && g_alienMaxStage.integer > S1 )
- alienNextStageThreshold = (int)( ceil( (float)g_alienStage2Threshold.integer * alienPlayerCountMod ) );
- else if( g_alienStage.integer == S2 && g_alienMaxStage.integer > S2 )
- alienNextStageThreshold = (int)( ceil( (float)g_alienStage3Threshold.integer * alienPlayerCountMod ) );
+ if( g_alienStage.integer == S1 && level.alienMaxStage > S1 )
+ alienNextStageThreshold = (int)( ceil( (float)level.alienStage2Threshold * alienPlayerCountMod ) );
+ else if( g_alienStage.integer == S2 && level.alienMaxStage > S2 )
+ alienNextStageThreshold = (int)( ceil( (float)level.alienStage3Threshold * alienPlayerCountMod ) );
else
alienNextStageThreshold = -1;
- if( g_humanStage.integer == S1 && g_humanMaxStage.integer > S1 )
- humanNextStageThreshold = (int)( ceil( (float)g_humanStage2Threshold.integer * humanPlayerCountMod ) );
- else if( g_humanStage.integer == S2 && g_humanMaxStage.integer > S2 )
- humanNextStageThreshold = (int)( ceil( (float)g_humanStage3Threshold.integer * humanPlayerCountMod ) );
+ if( g_humanStage.integer == S1 && level.humanMaxStage > S1 )
+ humanNextStageThreshold = (int)( ceil( (float)level.humanStage2Threshold * humanPlayerCountMod ) );
+ else if( g_humanStage.integer == S2 && level.humanMaxStage > S2 )
+ humanNextStageThreshold = (int)( ceil( (float)level.humanStage3Threshold * humanPlayerCountMod ) );
else
humanNextStageThreshold = -1;
diff --git a/src/game/g_mover.c b/src/game/g_mover.c
index ad660d0a..48f3c37b 100644
--- a/src/game/g_mover.c
+++ b/src/game/g_mover.c
@@ -2456,7 +2456,7 @@ void SP_func_pendulum( gentity_t *ent )
if( length < 8 )
length = 8;
- freq = 1 / ( M_PI * 2 ) * sqrt( g_gravity.value / ( 3 * length ) );
+ freq = 1 / ( M_PI * 2 ) * sqrt( level.gravity / ( 3 * length ) );
ent->s.pos.trDuration = ( 1000 / freq );
diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c
index e84ddb08..43e2c34b 100644
--- a/src/game/g_spawn.c
+++ b/src/game/g_spawn.c
@@ -602,38 +602,24 @@ void SP_worldspawn( void )
trap_SetConfigstring( CS_MOTD, g_motd.string ); // message of the day
- G_SpawnString( "gravity", "800", &s );
- trap_Cvar_Set( "g_gravity", s );
+ G_SpawnFloat( "gravity", "800", &level.gravity );
- G_SpawnString( "humanBuildPoints", DEFAULT_HUMAN_BUILDPOINTS, &s );
- trap_Cvar_Set( "g_humanBuildPoints", s );
+ G_SpawnInt( "humanMaxStage", DEFAULT_HUMAN_MAX_STAGE, &level.humanMaxStage );
- G_SpawnString( "humanMaxStage", DEFAULT_HUMAN_MAX_STAGE, &s );
- trap_Cvar_Set( "g_humanMaxStage", s );
+ G_SpawnInt( "humanStage2Threshold", DEFAULT_HUMAN_STAGE2_THRESH,
+ &level.humanStage2Threshold );
- G_SpawnString( "humanStage2Threshold", DEFAULT_HUMAN_STAGE2_THRESH, &s );
- trap_Cvar_Set( "g_humanStage2Threshold", s );
+ G_SpawnInt( "humanStage3Threshold", DEFAULT_HUMAN_STAGE3_THRESH,
+ &level.humanStage3Threshold );
- G_SpawnString( "humanStage3Threshold", DEFAULT_HUMAN_STAGE3_THRESH, &s );
- trap_Cvar_Set( "g_humanStage3Threshold", s );
+ G_SpawnInt( "alienMaxStage", DEFAULT_ALIEN_MAX_STAGE,
+ &level.alienMaxStage );
- G_SpawnString( "alienBuildPoints", DEFAULT_ALIEN_BUILDPOINTS, &s );
- trap_Cvar_Set( "g_alienBuildPoints", s );
+ G_SpawnInt( "alienStage2Threshold", DEFAULT_ALIEN_STAGE2_THRESH,
+ &level.alienStage2Threshold );
- G_SpawnString( "alienMaxStage", DEFAULT_ALIEN_MAX_STAGE, &s );
- trap_Cvar_Set( "g_alienMaxStage", s );
-
- G_SpawnString( "alienStage2Threshold", DEFAULT_ALIEN_STAGE2_THRESH, &s );
- trap_Cvar_Set( "g_alienStage2Threshold", s );
-
- G_SpawnString( "alienStage3Threshold", DEFAULT_ALIEN_STAGE3_THRESH, &s );
- trap_Cvar_Set( "g_alienStage3Threshold", s );
-
- G_SpawnString( "enableDust", "0", &s );
- trap_Cvar_Set( "g_enableDust", s );
-
- G_SpawnString( "enableBreath", "0", &s );
- trap_Cvar_Set( "g_enableBreath", s );
+ G_SpawnInt( "alienStage3Threshold", DEFAULT_ALIEN_STAGE3_THRESH,
+ &level.alienStage3Threshold );
G_SpawnString( "disabledEquipment", "", &s );
trap_Cvar_Set( "g_disabledEquipment", s );
diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c
index 65bf1bd1..0985b0f1 100644
--- a/src/game/g_trigger.c
+++ b/src/game/g_trigger.c
@@ -185,7 +185,7 @@ void AimAtTarget( gentity_t *self )
}
height = ent->s.origin[ 2 ] - origin[ 2 ];
- gravity = g_gravity.value;
+ gravity = level.gravity;
time = sqrt( height / ( 0.5 * gravity ) );
if( !time )