From 868c953a2bff5ddb11700a7d160e66014d9704de Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 20 Aug 2016 16:48:37 +1000 Subject: [PATCH] Cleanup server mutators: remove IMPLEMENTATION macro --- qcsrc/common/mutators/mutator/nades/nades.qh | 2 +- qcsrc/server/mutators/gamemode.qh | 14 ++-- qcsrc/server/mutators/mutator/_all.inc | 2 - qcsrc/server/mutators/mutator/_all.qh | 3 +- .../mutators/mutator/gamemode_assault.qc | 67 ---------------- .../mutators/mutator/gamemode_assault.qh | 61 +++++++++++++++ qcsrc/server/mutators/mutator/gamemode_ca.qc | 76 ------------------- qcsrc/server/mutators/mutator/gamemode_ca.qh | 70 +++++++++++++++++ qcsrc/server/mutators/mutator/gamemode_ctf.qc | 3 - qcsrc/server/mutators/mutator/gamemode_cts.qc | 43 ----------- qcsrc/server/mutators/mutator/gamemode_cts.qh | 36 +++++++++ .../mutators/mutator/gamemode_deathmatch.qc | 30 -------- .../mutators/mutator/gamemode_deathmatch.qh | 24 ++++++ .../mutators/mutator/gamemode_domination.qc | 65 ---------------- .../mutators/mutator/gamemode_domination.qh | 58 ++++++++++++++ .../mutators/mutator/gamemode_freezetag.qc | 59 +------------- .../mutators/mutator/gamemode_freezetag.qh | 49 ++++++++++++ .../mutators/mutator/gamemode_invasion.qc | 64 ---------------- .../mutators/mutator/gamemode_invasion.qh | 57 ++++++++++++++ .../mutators/mutator/gamemode_keepaway.qc | 43 +---------- .../mutators/mutator/gamemode_keepaway.qh | 35 +++++++++ .../mutators/mutator/gamemode_keyhunt.qc | 58 +------------- .../mutators/mutator/gamemode_keyhunt.qh | 48 ++++++++++++ qcsrc/server/mutators/mutator/gamemode_lms.qc | 44 ----------- qcsrc/server/mutators/mutator/gamemode_lms.qh | 35 +++++++++ .../server/mutators/mutator/gamemode_race.qc | 39 ---------- .../server/mutators/mutator/gamemode_race.qh | 30 ++++++++ qcsrc/server/mutators/mutator/gamemode_tdm.qc | 42 ---------- qcsrc/server/mutators/mutator/gamemode_tdm.qh | 35 +++++++++ 29 files changed, 552 insertions(+), 640 deletions(-) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qh b/qcsrc/common/mutators/mutator/nades/nades.qh index a7eed65d3..d4f6f7e36 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qh +++ b/qcsrc/common/mutators/mutator/nades/nades.qh @@ -86,7 +86,7 @@ bool orb_send(entity this, entity to, int sf); void nades_Clear(entity player); // Give a bonus grenade to a player -void(entity player, float score) nades_GiveBonus; +void nades_GiveBonus(entity player, float score); /** * called to adjust nade damage and force on hit diff --git a/qcsrc/server/mutators/gamemode.qh b/qcsrc/server/mutators/gamemode.qh index 81cb382b7..abd29740a 100644 --- a/qcsrc/server/mutators/gamemode.qh +++ b/qcsrc/server/mutators/gamemode.qh @@ -1,5 +1,11 @@ #pragma once +#include +#include +#include +#include +#include + #include "mutator.qh" // TODO: trim @@ -56,14 +62,11 @@ #include #include #include -#include #include #include #include -#include #include #include -#include #include #include #include @@ -73,11 +76,6 @@ #include #include #include -#include -#include -#include -#include -#include #include diff --git a/qcsrc/server/mutators/mutator/_all.inc b/qcsrc/server/mutators/mutator/_all.inc index f72fb7539..8bc63f720 100644 --- a/qcsrc/server/mutators/mutator/_all.inc +++ b/qcsrc/server/mutators/mutator/_all.inc @@ -1,4 +1,2 @@ #include "_all.qh" -#define IMPLEMENTATION #include "_mod.inc" -#undef IMPLEMENTATION diff --git a/qcsrc/server/mutators/mutator/_all.qh b/qcsrc/server/mutators/mutator/_all.qh index d720bcf41..947026dd5 100644 --- a/qcsrc/server/mutators/mutator/_all.qh +++ b/qcsrc/server/mutators/mutator/_all.qh @@ -1,3 +1,2 @@ #pragma once -// TODO: _mod.qh -#include "_mod.inc" +#include "_mod.qh" diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 092e07b79..5814e7cb7 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -1,70 +1,5 @@ #include "gamemode_assault.qh" -#ifndef GAMEMODE_ASSAULT_H -#define GAMEMODE_ASSAULT_H -void assault_ScoreRules(); -void ActivateTeamplay(); - -REGISTER_MUTATOR(as, false) -{ - ActivateTeamplay(); - have_team_spawns = -1; // request team spawns - - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - assault_ScoreRules(); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back assault_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -// sprites -.entity assault_decreaser; -.entity assault_sprite; - -// legacy bot defs -const int HAVOCBOT_AST_ROLE_NONE = 0; -const int HAVOCBOT_AST_ROLE_DEFENSE = 2; -const int HAVOCBOT_AST_ROLE_OFFENSE = 4; - -.int havocbot_role_flags; -.float havocbot_attack_time; - -.void(entity this) havocbot_role; -.void(entity this) havocbot_previous_role; - -void(entity this) havocbot_role_ast_defense; -void(entity this) havocbot_role_ast_offense; -.entity havocbot_ast_target; - -void(entity bot) havocbot_ast_reset_role; - -void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items; -void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers; - -// scoreboard stuff -const float ST_ASSAULT_OBJECTIVES = 1; - -// predefined spawnfuncs -void target_objective_decrease_activate(entity this); -#endif - -#ifdef IMPLEMENTATION .entity sprite; // random functions @@ -676,5 +611,3 @@ void assault_ScoreRules() ScoreInfo_SetLabel_PlayerScore(SP_ASSAULT_OBJECTIVES, "objectives", SFL_SORT_PRIO_PRIMARY); ScoreRules_basics_end(); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qh b/qcsrc/server/mutators/mutator/gamemode_assault.qh index 399830dad..1d53fcc68 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qh +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qh @@ -1,3 +1,64 @@ #pragma once #include "../gamemode.qh" + +void assault_ScoreRules(); +void ActivateTeamplay(); + +REGISTER_MUTATOR(as, false) +{ + ActivateTeamplay(); + have_team_spawns = -1; // request team spawns + + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + assault_ScoreRules(); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back assault_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +// sprites +.entity assault_decreaser; +.entity assault_sprite; + +// legacy bot defs +const int HAVOCBOT_AST_ROLE_NONE = 0; +const int HAVOCBOT_AST_ROLE_DEFENSE = 2; +const int HAVOCBOT_AST_ROLE_OFFENSE = 4; + +.int havocbot_role_flags; +.float havocbot_attack_time; + +.void(entity this) havocbot_role; +.void(entity this) havocbot_previous_role; + +void(entity this) havocbot_role_ast_defense; +void(entity this) havocbot_role_ast_offense; +.entity havocbot_ast_target; + +void(entity bot) havocbot_ast_reset_role; + +void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items; +void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers; + +// scoreboard stuff +const float ST_ASSAULT_OBJECTIVES = 1; + +// predefined spawnfuncs +void target_objective_decrease_activate(entity this); diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 209c8b856..75c9d6008 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -1,79 +1,5 @@ #include "gamemode_ca.qh" -#ifndef GAMEMODE_CA_H -#define GAMEMODE_CA_H -int autocvar_g_ca_point_limit; -int autocvar_g_ca_point_leadlimit; -float autocvar_g_ca_round_timelimit; -bool autocvar_g_ca_team_spawns; -int autocvar_g_ca_teams; -int autocvar_g_ca_teams_override; -float autocvar_g_ca_warmup; - - -int ca_teams; -bool allowed_to_spawn; - -const int ST_CA_ROUNDS = 1; - -bool CA_CheckTeams(); -bool CA_CheckWinner(); -void CA_RoundStart(); -bool ca_isEliminated(entity e); - -void SetLimits(int fraglimit_override, int leadlimit_override, float timelimit_override, float qualifying_override); - -REGISTER_MUTATOR(ca, false) -{ - MUTATOR_ONADD - { - // game loads at time 1 - if (time > 1) error("This is a game type and it cannot be added at runtime."); - - allowed_to_spawn = true; - - ca_teams = autocvar_g_ca_teams_override; - if (ca_teams < 2) ca_teams = autocvar_g_ca_teams; - ca_teams = bound(2, ca_teams, 4); - - int teams = 0; - if(ca_teams >= 1) teams |= BIT(0); - if(ca_teams >= 2) teams |= BIT(1); - if(ca_teams >= 3) teams |= BIT(2); - if(ca_teams >= 4) teams |= BIT(3); - - ca_teams = teams; // now set it? - - ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true); - ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY); - ScoreRules_basics_end(); - - round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart); - round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit); - - EliminatedPlayers_Init(ca_isEliminated); - - ActivateTeamplay(); - SetLimits(autocvar_g_ca_point_limit, autocvar_g_ca_point_leadlimit, autocvar_timelimit_override, -1); - - if (autocvar_g_ca_team_spawns) - have_team_spawns = -1; // request team spawns - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -// should be removed in the future, as other code should not have to care -.float caplayer; // 0.5 if scheduled to join the next round -#endif - -#ifdef IMPLEMENTATION float autocvar_g_ca_damage2score_multiplier; bool autocvar_g_ca_spectate_enemies; @@ -531,5 +457,3 @@ MUTATOR_HOOKFUNCTION(ca, SetWeaponArena) // most weapons arena if (M_ARGV(0, string) == "0" || M_ARGV(0, string) == "") M_ARGV(0, string) = "most"; } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qh b/qcsrc/server/mutators/mutator/gamemode_ca.qh index 399830dad..8009feb8a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qh +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qh @@ -1,3 +1,73 @@ #pragma once #include "../gamemode.qh" + +int autocvar_g_ca_point_limit; +int autocvar_g_ca_point_leadlimit; +float autocvar_g_ca_round_timelimit; +bool autocvar_g_ca_team_spawns; +int autocvar_g_ca_teams; +int autocvar_g_ca_teams_override; +float autocvar_g_ca_warmup; + + +int ca_teams; +bool allowed_to_spawn; + +const int ST_CA_ROUNDS = 1; + +bool CA_CheckTeams(); +bool CA_CheckWinner(); +void CA_RoundStart(); +bool ca_isEliminated(entity e); + +void SetLimits(int fraglimit_override, int leadlimit_override, float timelimit_override, float qualifying_override); + +REGISTER_MUTATOR(ca, false) +{ + MUTATOR_ONADD + { + // game loads at time 1 + if (time > 1) error("This is a game type and it cannot be added at runtime."); + + allowed_to_spawn = true; + + ca_teams = autocvar_g_ca_teams_override; + if (ca_teams < 2) ca_teams = autocvar_g_ca_teams; + ca_teams = bound(2, ca_teams, 4); + + int teams = 0; + if(ca_teams >= 1) teams |= BIT(0); + if(ca_teams >= 2) teams |= BIT(1); + if(ca_teams >= 3) teams |= BIT(2); + if(ca_teams >= 4) teams |= BIT(3); + + ca_teams = teams; // now set it? + + ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, 0, true); + ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY); + ScoreRules_basics_end(); + + round_handler_Spawn(CA_CheckTeams, CA_CheckWinner, CA_RoundStart); + round_handler_Init(5, autocvar_g_ca_warmup, autocvar_g_ca_round_timelimit); + + EliminatedPlayers_Init(ca_isEliminated); + + ActivateTeamplay(); + SetLimits(autocvar_g_ca_point_limit, autocvar_g_ca_point_leadlimit, autocvar_timelimit_override, -1); + + if (autocvar_g_ca_team_spawns) + have_team_spawns = -1; // request team spawns + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +// should be removed in the future, as other code should not have to care +.float caplayer; // 0.5 if scheduled to join the next round diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 9b16e4e96..017fb265b 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -1,6 +1,5 @@ #include "gamemode_ctf.qh" -#ifdef IMPLEMENTATION #ifndef CSQC void ctf_Initialize(); @@ -2658,5 +2657,3 @@ void ctf_Initialize() InitializeEntity(NULL, ctf_DelayedInit, INITPRIO_GAMETYPE); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index a712e033d..33030f2f9 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -1,47 +1,6 @@ #include "gamemode_cts.qh" #include -#ifndef GAMEMODE_CTS_H -#define GAMEMODE_CTS_H - -void cts_Initialize(); - -REGISTER_MUTATOR(cts, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - - g_race_qualifying = true; - independent_players = 1; - SetLimits(0, 0, autocvar_timelimit_override, -1); - - cts_Initialize(); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back cts_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -// scores -const float ST_CTS_LAPS = 1; -#endif - -#ifdef IMPLEMENTATION - #include float autocvar_g_cts_finish_kill_delay; @@ -438,5 +397,3 @@ void cts_Initialize() { cts_ScoreRules(); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qh b/qcsrc/server/mutators/mutator/gamemode_cts.qh index 399830dad..2a18fe915 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qh +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qh @@ -1,3 +1,39 @@ #pragma once #include "../gamemode.qh" +#include + +void cts_Initialize(); + +REGISTER_MUTATOR(cts, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + + g_race_qualifying = true; + independent_players = 1; + SetLimits(0, 0, autocvar_timelimit_override, -1); + + cts_Initialize(); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back cts_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +// scores +const float ST_CTS_LAPS = 1; diff --git a/qcsrc/server/mutators/mutator/gamemode_deathmatch.qc b/qcsrc/server/mutators/mutator/gamemode_deathmatch.qc index 866370351..9590027d3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_deathmatch.qc +++ b/qcsrc/server/mutators/mutator/gamemode_deathmatch.qc @@ -1,37 +1,7 @@ #include "gamemode_deathmatch.qh" -#ifndef GAMEMODE_DEATHMATCH_H -#define GAMEMODE_DEATHMATCH_H -REGISTER_MUTATOR(dm, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back dm_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - error("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -#endif - -#ifdef IMPLEMENTATION MUTATOR_HOOKFUNCTION(dm, Scores_CountFragsRemaining) { // announce remaining frags return true; } -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_deathmatch.qh b/qcsrc/server/mutators/mutator/gamemode_deathmatch.qh index 399830dad..d3cc197ea 100644 --- a/qcsrc/server/mutators/mutator/gamemode_deathmatch.qh +++ b/qcsrc/server/mutators/mutator/gamemode_deathmatch.qh @@ -1,3 +1,27 @@ #pragma once #include "../gamemode.qh" + +REGISTER_MUTATOR(dm, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back dm_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + error("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 7c1e81184..6ad5d4849 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -1,67 +1,4 @@ #include "gamemode_domination.qh" -#ifndef GAMEMODE_DOMINATION_H -#define GAMEMODE_DOMINATION_H - -#define autocvar_g_domination_point_limit cvar("g_domination_point_limit") -bool autocvar_g_domination_roundbased; -int autocvar_g_domination_roundbased_point_limit; -int autocvar_g_domination_point_leadlimit; - -void dom_Initialize(); - -REGISTER_MUTATOR(dom, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - dom_Initialize(); - - int fraglimit_override = autocvar_g_domination_point_limit; - if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) - fraglimit_override = autocvar_g_domination_roundbased_point_limit; - - ActivateTeamplay(); - SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, autocvar_timelimit_override, -1); - have_team_spawns = -1; // request team spawns - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -// score rule declarations -const float ST_DOM_TICKS = 1; -const float ST_DOM_CAPS = 1; - -// pps: points per second -.float dom_total_pps = _STAT(DOM_TOTAL_PPS); -.float dom_pps_red = _STAT(DOM_PPS_RED); -.float dom_pps_blue = _STAT(DOM_PPS_BLUE); -.float dom_pps_yellow = _STAT(DOM_PPS_YELLOW); -.float dom_pps_pink = _STAT(DOM_PPS_PINK); -float total_pps; -float pps_red; -float pps_blue; -float pps_yellow; -float pps_pink; - -// capture declarations -.float enemy_playerid; -.entity sprite; -.float captime; - -// misc globals -float domination_roundbased; -float domination_teams; -#endif - -#ifdef IMPLEMENTATION #include @@ -706,5 +643,3 @@ void dom_Initialize() g_domination = true; InitializeEntity(NULL, dom_DelayedInit, INITPRIO_GAMETYPE); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qh b/qcsrc/server/mutators/mutator/gamemode_domination.qh index 399830dad..eb2379ca2 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qh +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qh @@ -1,3 +1,61 @@ #pragma once #include "../gamemode.qh" + +#define autocvar_g_domination_point_limit cvar("g_domination_point_limit") +bool autocvar_g_domination_roundbased; +int autocvar_g_domination_roundbased_point_limit; +int autocvar_g_domination_point_leadlimit; + +void dom_Initialize(); + +REGISTER_MUTATOR(dom, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + dom_Initialize(); + + int fraglimit_override = autocvar_g_domination_point_limit; + if (autocvar_g_domination_roundbased && autocvar_g_domination_roundbased_point_limit) + fraglimit_override = autocvar_g_domination_roundbased_point_limit; + + ActivateTeamplay(); + SetLimits(fraglimit_override, autocvar_g_domination_point_leadlimit, autocvar_timelimit_override, -1); + have_team_spawns = -1; // request team spawns + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +// score rule declarations +const float ST_DOM_TICKS = 1; +const float ST_DOM_CAPS = 1; + +// pps: points per second +.float dom_total_pps = _STAT(DOM_TOTAL_PPS); +.float dom_pps_red = _STAT(DOM_PPS_RED); +.float dom_pps_blue = _STAT(DOM_PPS_BLUE); +.float dom_pps_yellow = _STAT(DOM_PPS_YELLOW); +.float dom_pps_pink = _STAT(DOM_PPS_PINK); +float total_pps; +float pps_red; +float pps_blue; +float pps_yellow; +float pps_pink; + +// capture declarations +.float enemy_playerid; +.entity sprite; +.float captime; + +// misc globals +float domination_roundbased; +float domination_teams; diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index a875e19ab..602a55b6b 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -1,58 +1,4 @@ #include "gamemode_freezetag.qh" -#ifndef GAMEMODE_FREEZETAG_H -#define GAMEMODE_FREEZETAG_H - -int autocvar_g_freezetag_point_limit; -int autocvar_g_freezetag_point_leadlimit; -bool autocvar_g_freezetag_team_spawns; -void freezetag_Initialize(); - -REGISTER_MUTATOR(ft, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - freezetag_Initialize(); - - ActivateTeamplay(); - SetLimits(autocvar_g_freezetag_point_limit, autocvar_g_freezetag_point_leadlimit, autocvar_timelimit_override, -1); - - if (autocvar_g_freezetag_team_spawns) - have_team_spawns = -1; // request team spawns - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back freezetag_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -.float freezetag_frozen_time; -.float freezetag_frozen_timeout; -const float ICE_MAX_ALPHA = 1; -const float ICE_MIN_ALPHA = 0.1; -float freezetag_teams; - -.float reviving; // temp var - -float autocvar_g_freezetag_revive_extra_size; -float autocvar_g_freezetag_revive_speed; -bool autocvar_g_freezetag_revive_nade; -float autocvar_g_freezetag_revive_nade_health; - -#endif -#ifdef IMPLEMENTATION float autocvar_g_freezetag_frozen_maxtime; float autocvar_g_freezetag_revive_clearspeed; @@ -151,6 +97,9 @@ float freezetag_getWinnerTeam() return -1; // no player left } +void nades_Clear(entity); +void nades_GiveBonus(entity player, float score); + float freezetag_CheckWinner() { if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0) @@ -637,5 +586,3 @@ void freezetag_Initialize() EliminatedPlayers_Init(freezetag_isEliminated); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qh b/qcsrc/server/mutators/mutator/gamemode_freezetag.qh index 399830dad..fda0737dd 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qh +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qh @@ -1,3 +1,52 @@ #pragma once #include "../gamemode.qh" + +int autocvar_g_freezetag_point_limit; +int autocvar_g_freezetag_point_leadlimit; +bool autocvar_g_freezetag_team_spawns; +void freezetag_Initialize(); + +REGISTER_MUTATOR(ft, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + freezetag_Initialize(); + + ActivateTeamplay(); + SetLimits(autocvar_g_freezetag_point_limit, autocvar_g_freezetag_point_leadlimit, autocvar_timelimit_override, -1); + + if (autocvar_g_freezetag_team_spawns) + have_team_spawns = -1; // request team spawns + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back freezetag_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +.float freezetag_frozen_time; +.float freezetag_frozen_timeout; +const float ICE_MAX_ALPHA = 1; +const float ICE_MIN_ALPHA = 0.1; +float freezetag_teams; + +.float reviving; // temp var + +float autocvar_g_freezetag_revive_extra_size; +float autocvar_g_freezetag_revive_speed; +bool autocvar_g_freezetag_revive_nade; +float autocvar_g_freezetag_revive_nade_health; diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index 184cf3330..1d9dc6620 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -1,66 +1,4 @@ #include "gamemode_invasion.qh" -#ifndef GAMEMODE_INVASION_H -#define GAMEMODE_INVASION_H - -#define autocvar_g_invasion_point_limit cvar("g_invasion_point_limit") -int autocvar_g_invasion_teams; -bool autocvar_g_invasion_team_spawns; -bool g_invasion; -void invasion_Initialize(); - -REGISTER_MUTATOR(inv, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - g_invasion = true; - invasion_Initialize(); - - cvar_settemp("g_monsters", "1"); - - SetLimits(autocvar_g_invasion_point_limit, autocvar_leadlimit_override, autocvar_timelimit_override, -1); - if (autocvar_g_invasion_teams >= 2) - { - ActivateTeamplay(); - if (autocvar_g_invasion_team_spawns) - have_team_spawns = -1; // request team spawns - } - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back invasion_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -float inv_numspawned; -float inv_maxspawned; -float inv_roundcnt; -float inv_maxrounds; -float inv_numkilled; -float inv_lastcheck; -float inv_maxcurrent; - -float invasion_teams; -float inv_monsters_perteam[17]; - -float inv_monsterskill; - -const float ST_INV_KILLS = 1; -#endif - -#ifdef IMPLEMENTATION #include #include @@ -544,5 +482,3 @@ void invasion_Initialize() InitializeEntity(NULL, invasion_DelayedInit, INITPRIO_GAMETYPE); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qh b/qcsrc/server/mutators/mutator/gamemode_invasion.qh index 399830dad..e934f8745 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qh +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qh @@ -1,3 +1,60 @@ #pragma once #include "../gamemode.qh" + +#define autocvar_g_invasion_point_limit cvar("g_invasion_point_limit") +int autocvar_g_invasion_teams; +bool autocvar_g_invasion_team_spawns; +bool g_invasion; +void invasion_Initialize(); + +REGISTER_MUTATOR(inv, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + g_invasion = true; + invasion_Initialize(); + + cvar_settemp("g_monsters", "1"); + + SetLimits(autocvar_g_invasion_point_limit, autocvar_leadlimit_override, autocvar_timelimit_override, -1); + if (autocvar_g_invasion_teams >= 2) + { + ActivateTeamplay(); + if (autocvar_g_invasion_team_spawns) + have_team_spawns = -1; // request team spawns + } + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back invasion_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +float inv_numspawned; +float inv_maxspawned; +float inv_roundcnt; +float inv_maxrounds; +float inv_numkilled; +float inv_lastcheck; +float inv_maxcurrent; + +float invasion_teams; +float inv_monsters_perteam[17]; + +float inv_monsterskill; + +const float ST_INV_KILLS = 1; diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index da43b84de..a430ab536 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -1,44 +1,4 @@ #include "gamemode_keepaway.qh" -#ifndef GAMEMODE_KEEPAWAY_H -#define GAMEMODE_KEEPAWAY_H - -void ka_Initialize(); - -REGISTER_MUTATOR(ka, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - ka_Initialize(); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back ka_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return false; -} - - -entity ka_ball; - -void(entity this) havocbot_role_ka_carrier; -void(entity this) havocbot_role_ka_collector; - -void ka_DropEvent(entity plyr); -#endif - -#ifdef IMPLEMENTATION int autocvar_g_keepaway_ballcarrier_effects; float autocvar_g_keepaway_ballcarrier_damage; @@ -471,6 +431,7 @@ MUTATOR_HOOKFUNCTION(ka, DropSpecialItems) ka_DropEvent(frag_target); } +.bool pushable; // ============== // Initialization @@ -513,5 +474,3 @@ void ka_Initialize() // run at the start of a match, initiates game mode ka_ScoreRules(); ka_SpawnBall(); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qh b/qcsrc/server/mutators/mutator/gamemode_keepaway.qh index 399830dad..a13ab83a5 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qh +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qh @@ -1,3 +1,38 @@ #pragma once #include "../gamemode.qh" + +void ka_Initialize(); + +REGISTER_MUTATOR(ka, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + ka_Initialize(); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back ka_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return false; +} + + +entity ka_ball; + +void(entity this) havocbot_role_ka_carrier; +void(entity this) havocbot_role_ka_collector; + +void ka_DropEvent(entity plyr); diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index 5f6b5226d..86d76e431 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -1,58 +1,4 @@ #include "gamemode_keyhunt.qh" -#ifndef GAMEMODE_KEYHUNT_H -#define GAMEMODE_KEYHUNT_H - -#define autocvar_g_keyhunt_point_limit cvar("g_keyhunt_point_limit") -int autocvar_g_keyhunt_point_leadlimit; -bool autocvar_g_keyhunt_team_spawns; -void kh_Initialize(); - -REGISTER_MUTATOR(kh, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - kh_Initialize(); - - ActivateTeamplay(); - SetLimits(autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_point_leadlimit, autocvar_timelimit_override, -1); - if (autocvar_g_keyhunt_team_spawns) - have_team_spawns = -1; // request team spawns - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back kh_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -#define FOR_EACH_KH_KEY(v) for(v = kh_worldkeylist; v; v = v.kh_worldkeynext ) - -// ALL OF THESE should be removed in the future, as other code should not have to care - -// used by bots: -float kh_tracking_enabled; -.entity kh_next; -float kh_Key_AllOwnedByWhichTeam(); - -USING(kh_Think_t, void()); -void kh_StartRound(); -void kh_Controller_SetThink(float t, kh_Think_t func); - -#endif - -#ifdef IMPLEMENTATION float autocvar_g_balance_keyhunt_damageforcescale; float autocvar_g_balance_keyhunt_delay_collect; @@ -570,6 +516,8 @@ void kh_FinishRound() // runs when a team captures the keys kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, kh_StartRound); } +void nades_GiveBonus(entity player, float score); + void kh_WinnerTeam(float teem) // runs when a team wins // Samual: Teem?.... TEEM?!?! what the fuck is wrong with you people { // all key carriers get some points @@ -1392,5 +1340,3 @@ MUTATOR_HOOKFUNCTION(kh, reset_map_global) { kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round + (game_starttime - time), kh_StartRound); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qh b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qh index 399830dad..9a98df98f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qh +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qh @@ -1,3 +1,51 @@ #pragma once #include "../gamemode.qh" + +#define autocvar_g_keyhunt_point_limit cvar("g_keyhunt_point_limit") +int autocvar_g_keyhunt_point_leadlimit; +bool autocvar_g_keyhunt_team_spawns; +void kh_Initialize(); + +REGISTER_MUTATOR(kh, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + kh_Initialize(); + + ActivateTeamplay(); + SetLimits(autocvar_g_keyhunt_point_limit, autocvar_g_keyhunt_point_leadlimit, autocvar_timelimit_override, -1); + if (autocvar_g_keyhunt_team_spawns) + have_team_spawns = -1; // request team spawns + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back kh_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +#define FOR_EACH_KH_KEY(v) for(v = kh_worldkeylist; v; v = v.kh_worldkeynext ) + +// ALL OF THESE should be removed in the future, as other code should not have to care + +// used by bots: +float kh_tracking_enabled; +.entity kh_next; +float kh_Key_AllOwnedByWhichTeam(); + +USING(kh_Think_t, void()); +void kh_StartRound(); +void kh_Controller_SetThink(float t, kh_Think_t func); diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index a66a8c536..0807ea445 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -1,45 +1,4 @@ #include "gamemode_lms.qh" -#ifndef GAMEMODE_LMS_H -#define GAMEMODE_LMS_H - -#define autocvar_g_lms_lives_override cvar("g_lms_lives_override") -void lms_Initialize(); - -REGISTER_MUTATOR(lms, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - lms_Initialize(); - - SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, autocvar_timelimit_override, -1); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back lms_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -// lives related defs -float lms_lowest_lives; -float lms_next_place; -float LMS_NewPlayerLives(); - -#endif - -#ifdef IMPLEMENTATION #include #include @@ -408,6 +367,3 @@ void lms_Initialize() lms_ScoreRules(); } - - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qh b/qcsrc/server/mutators/mutator/gamemode_lms.qh index 399830dad..7bf012668 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qh +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qh @@ -1,3 +1,38 @@ #pragma once #include "../gamemode.qh" + +#define autocvar_g_lms_lives_override cvar("g_lms_lives_override") +void lms_Initialize(); + +REGISTER_MUTATOR(lms, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + lms_Initialize(); + + SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, autocvar_timelimit_override, -1); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back lms_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} + +// lives related defs +float lms_lowest_lives; +float lms_next_place; +float LMS_NewPlayerLives(); diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 04561db36..756d975b1 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -1,42 +1,5 @@ #include "gamemode_race.qh" -#ifndef GAMEMODE_RACE_H -#define GAMEMODE_RACE_H - -void rc_SetLimits(); -void race_Initialize(); - -REGISTER_MUTATOR(rc, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - - rc_SetLimits(); - race_Initialize(); - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back race_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -#endif - -#ifdef IMPLEMENTATION - #include #define autocvar_g_race_laps_limit cvar("g_race_laps_limit") @@ -505,5 +468,3 @@ void rc_SetLimits() g_race_qualifying = 0; SetLimits(fraglimit_override, leadlimit_override, timelimit_override, qualifying_override); } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qh b/qcsrc/server/mutators/mutator/gamemode_race.qh index 399830dad..ec71a62d1 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qh +++ b/qcsrc/server/mutators/mutator/gamemode_race.qh @@ -1,3 +1,33 @@ #pragma once #include "../gamemode.qh" + +void rc_SetLimits(); +void race_Initialize(); + +REGISTER_MUTATOR(rc, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + + rc_SetLimits(); + race_Initialize(); + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back race_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} diff --git a/qcsrc/server/mutators/mutator/gamemode_tdm.qc b/qcsrc/server/mutators/mutator/gamemode_tdm.qc index 8fdfc8343..d906c1988 100644 --- a/qcsrc/server/mutators/mutator/gamemode_tdm.qc +++ b/qcsrc/server/mutators/mutator/gamemode_tdm.qc @@ -1,45 +1,5 @@ #include "gamemode_tdm.qh" -#ifndef GAMEMODE_TDM_H -#define GAMEMODE_TDM_H -int autocvar_g_tdm_point_limit; -int autocvar_g_tdm_point_leadlimit; -bool autocvar_g_tdm_team_spawns; -void tdm_DelayedInit(entity this); - -REGISTER_MUTATOR(tdm, false) -{ - MUTATOR_ONADD - { - if (time > 1) // game loads at time 1 - error("This is a game type and it cannot be added at runtime."); - InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE); - - ActivateTeamplay(); - SetLimits(autocvar_g_tdm_point_limit, autocvar_g_tdm_point_leadlimit, autocvar_timelimit_override, -1); - if (autocvar_g_tdm_team_spawns) - have_team_spawns = -1; // request team spawns - } - - MUTATOR_ONROLLBACK_OR_REMOVE - { - // we actually cannot roll back tdm_Initialize here - // BUT: we don't need to! If this gets called, adding always - // succeeds. - } - - MUTATOR_ONREMOVE - { - LOG_INFO("This is a game type and it cannot be removed at runtime."); - return -1; - } - - return 0; -} - -#endif - -#ifdef IMPLEMENTATION int autocvar_g_tdm_teams; int autocvar_g_tdm_teams_override; @@ -108,5 +68,3 @@ MUTATOR_HOOKFUNCTION(tdm, Scores_CountFragsRemaining) // announce remaining frags return true; } - -#endif diff --git a/qcsrc/server/mutators/mutator/gamemode_tdm.qh b/qcsrc/server/mutators/mutator/gamemode_tdm.qh index 399830dad..e7efbae7f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_tdm.qh +++ b/qcsrc/server/mutators/mutator/gamemode_tdm.qh @@ -1,3 +1,38 @@ #pragma once #include "../gamemode.qh" + +int autocvar_g_tdm_point_limit; +int autocvar_g_tdm_point_leadlimit; +bool autocvar_g_tdm_team_spawns; +void tdm_DelayedInit(entity this); + +REGISTER_MUTATOR(tdm, false) +{ + MUTATOR_ONADD + { + if (time > 1) // game loads at time 1 + error("This is a game type and it cannot be added at runtime."); + InitializeEntity(NULL, tdm_DelayedInit, INITPRIO_GAMETYPE); + + ActivateTeamplay(); + SetLimits(autocvar_g_tdm_point_limit, autocvar_g_tdm_point_leadlimit, autocvar_timelimit_override, -1); + if (autocvar_g_tdm_team_spawns) + have_team_spawns = -1; // request team spawns + } + + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back tdm_Initialize here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + LOG_INFO("This is a game type and it cannot be removed at runtime."); + return -1; + } + + return 0; +} -- 2.39.2