diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2018-02-16 15:02:55 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2018-02-16 15:07:26 +0100 |
commit | f6a4036b2beedf57f2f94b63ee0212adfc0c1e2d (patch) | |
tree | c426b5ce9d44ac9dfdbdc3091faa2fba6064d2a9 /src | |
parent | e4946ae07a3b28b6f9b31d3846a7a1fd2ce612c8 (diff) |
Rewrite G_CalculateStages to fix bugs with trigger_stage.
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_main.c | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/src/game/g_main.c b/src/game/g_main.c index 7e72b87..741f61a 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1690,8 +1690,6 @@ void G_CalculateStages( void ) { float alienPlayerCountMod = level.averageNumAlienClients / PLAYER_COUNT_MOD; float humanPlayerCountMod = level.averageNumHumanClients / PLAYER_COUNT_MOD; - static int lastAlienStageModCount = 1; - static int lastHumanStageModCount = 1; static int alienTriggerStage = 0; static int humanTriggerStage = 0; @@ -1706,9 +1704,7 @@ void G_CalculateStages( void ) g_alienStage.integer == S1 && g_alienMaxStage.integer > S1 ) { trap_Cvar_Set( "g_alienStage", va( "%d", S2 ) ); - level.alienStage2Time = level.time; - lastAlienStageModCount = g_alienStage.modificationCount; - G_LogPrintf("Stage: A 2: Aliens reached Stage 2\n"); + g_alienStage.integer = S2; // update immediately } if( g_alienKills.integer >= @@ -1716,9 +1712,7 @@ void G_CalculateStages( void ) g_alienStage.integer == S2 && g_alienMaxStage.integer > S2 ) { trap_Cvar_Set( "g_alienStage", va( "%d", S3 ) ); - level.alienStage3Time = level.time; - lastAlienStageModCount = g_alienStage.modificationCount; - G_LogPrintf("Stage: A 3: Aliens reached Stage 3\n"); + g_alienStage.integer = S3; } if( g_humanKills.integer >= @@ -1726,9 +1720,7 @@ void G_CalculateStages( void ) g_humanStage.integer == S1 && g_humanMaxStage.integer > S1 ) { trap_Cvar_Set( "g_humanStage", va( "%d", S2 ) ); - level.humanStage2Time = level.time; - lastHumanStageModCount = g_humanStage.modificationCount; - G_LogPrintf("Stage: H 2: Humans reached Stage 2\n"); + g_humanStage.integer = S2; } if( g_humanKills.integer >= @@ -1736,36 +1728,45 @@ void G_CalculateStages( void ) g_humanStage.integer == S2 && g_humanMaxStage.integer > S2 ) { trap_Cvar_Set( "g_humanStage", va( "%d", S3 ) ); - level.humanStage3Time = level.time; - G_LogPrintf("Stage: H 3: Humans reached Stage 3\n"); - lastHumanStageModCount = g_humanStage.modificationCount; + g_humanStage.integer = S3; } - - if( g_alienStage.modificationCount > lastAlienStageModCount ) + + while( alienTriggerStage < MIN( g_alienStage.integer, S3 ) ) { - G_Checktrigger_stages( PTE_ALIENS, g_alienStage.integer ); - while( alienTriggerStage < MIN( g_alienStage.integer, S3 ) ) - G_Checktrigger_stages( PTE_ALIENS, ++alienTriggerStage ); + alienTriggerStage++; + + switch( alienTriggerStage ) + { + case S2: + level.alienStage2Time = level.time; + G_LogPrintf( "Stage: A 2: Aliens reached Stage 2\n" ); + break; + case S3: + level.alienStage3Time = level.time; + G_LogPrintf( "Stage: A 3: Aliens reached Stage 3\n" ); + break; + } - if( g_alienStage.integer == S2 ) - level.alienStage2Time = level.time; - else if( g_alienStage.integer == S3 ) - level.alienStage3Time = level.time; - - lastAlienStageModCount = g_alienStage.modificationCount; + G_Checktrigger_stages( PTE_ALIENS, alienTriggerStage ); } - - if( g_humanStage.modificationCount > lastHumanStageModCount ) + + while( humanTriggerStage < MIN( g_humanStage.integer, S3 ) ) { - while( humanTriggerStage < MIN( g_humanStage.integer, S3 ) ) - G_Checktrigger_stages( PTE_HUMANS, ++humanTriggerStage ); + humanTriggerStage++; - if( g_humanStage.integer == S2 ) - level.humanStage2Time = level.time; - else if( g_humanStage.integer == S3 ) - level.humanStage3Time = level.time; + switch( humanTriggerStage ) + { + case S2: + level.humanStage2Time = level.time; + G_LogPrintf( "Stage: H 2: Humans reached Stage 2\n" ); + break; + case S3: + level.humanStage3Time = level.time; + G_LogPrintf( "Stage: H 3: Humans reached Stage 3\n" ); + break; + } - lastHumanStageModCount = g_humanStage.modificationCount; + G_Checktrigger_stages( PTE_HUMANS, humanTriggerStage ); } } |