diff options
Diffstat (limited to 'src/game/g_main.c')
-rw-r--r-- | src/game/g_main.c | 96 |
1 files changed, 70 insertions, 26 deletions
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; |