Merge remote branch 'origin/master' into tzork/gm_nexball
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index 9c10089..3bb2ad1 100644 (file)
@@ -84,68 +84,6 @@ void LogTeamchange(float player_id, float team_number, float type)
        GameLogEcho(strcat(":team:", ftos(player_id), ":", ftos(team_number), ":", ftos(type)));
 }
 
-void WriteGameCvars()
-{
-       cvar_set("g_dm", ftos(g_dm));
-       cvar_set("g_tdm", ftos(g_tdm));
-       cvar_set("g_domination", ftos(g_domination));
-       cvar_set("g_ctf", ftos(g_ctf));
-       cvar_set("g_runematch", ftos(g_runematch));
-       cvar_set("g_lms", ftos(g_lms));
-       cvar_set("g_arena", ftos(g_arena));
-       cvar_set("g_ca", ftos(g_ca));
-       cvar_set("g_keyhunt", ftos(g_keyhunt));
-       cvar_set("g_assault", ftos(g_assault));
-       cvar_set("g_onslaught", ftos(g_onslaught));
-       cvar_set("g_race", ftos(g_race));
-       cvar_set("g_nexball", ftos(g_nexball));
-       cvar_set("g_cts", ftos(g_cts));
-       cvar_set("g_freezetag", ftos(g_freezetag));
-       cvar_set("g_keepaway", ftos(g_keepaway));
-}
-
-void ReadGameCvars()
-{
-       float found;
-       float prev;
-       float i;
-
-       found = 0;
-       prev = autocvar_gamecfg;
-       for(i = 0; i < 2; ++i)
-       {
-//#NO AUTOCVARS START
-               found += (g_dm = (!found && (prev != GAME_DEATHMATCH) && cvar("g_dm")));
-               found += (g_tdm = (!found && (prev != GAME_TEAM_DEATHMATCH) && cvar("g_tdm")));
-               found += (g_domination = (!found && (prev != GAME_DOMINATION) && cvar("g_domination")));
-               found += (g_ctf = (!found && (prev != GAME_CTF) && cvar("g_ctf")));
-               found += (g_runematch = (!found && (prev != GAME_RUNEMATCH) && cvar("g_runematch")));
-               found += (g_lms = (!found && (prev != GAME_LMS) && cvar("g_lms")));
-               found += (g_arena = (!found && (prev != GAME_ARENA) && cvar("g_arena")));
-               found += (g_ca = (!found && (prev != GAME_CA) && cvar("g_ca")));
-               found += (g_keyhunt = (!found && (prev != GAME_KEYHUNT) && cvar("g_keyhunt")));
-               found += (g_assault = (!found && (prev != GAME_ASSAULT) && cvar("g_assault")));
-               found += (g_onslaught = (!found && (prev != GAME_ONSLAUGHT) && cvar("g_onslaught")));
-               found += (g_race = (!found && (prev != GAME_RACE) && cvar("g_race")));
-               found += (g_nexball = (!found && (prev != GAME_NEXBALL) && cvar("g_nexball")));
-               found += (g_cts = (!found && (prev != GAME_CTS) && cvar("g_cts")));
-               found += (g_freezetag = (!found && (prev != GAME_FREEZETAG) && cvar("g_freezetag")));
-               found += (g_keepaway = (!found && (prev != GAME_KEEPAWAY) && cvar("g_keepaway")));
-//#NO AUTOCVARS END
-
-               if(found)
-                       break;
-
-               prev = -1; // second attempt takes place WITHOUT prev set
-       }
-
-       if(!found)
-               g_dm = 1;
-
-       teamplay = 0;
-       serverflags &~= SERVERFLAG_TEAMPLAY;
-}
-
 void default_delayedinit()
 {
        if(!scores_initialized)
@@ -166,16 +104,14 @@ void InitGameplayMode()
 
        VoteReset();
 
-       // make sure only ONE type is selected
-       ReadGameCvars();
-       WriteGameCvars();
-
        // find out good world mins/maxs bounds, either the static bounds found by looking for solid, or the mapinfo specified bounds
        get_mi_min_max(1);
        world.mins = mi_min;
        world.maxs = mi_max;
 
        MapInfo_LoadMapSettings(mapname);
+       teamplay = 0;
+       serverflags &~= SERVERFLAG_TEAMPLAY;
 
        if not(cvar_value_issafe(world.fog))
        {
@@ -191,24 +127,18 @@ void InitGameplayMode()
 
        MapInfo_ClearTemps();
 
-       // in case mapinfo switched the type
-       ReadGameCvars();
-
        // set both here, gamemode can override it later
        timelimit_override = autocvar_timelimit_override;
        fraglimit_override = autocvar_fraglimit_override;
        leadlimit_override = autocvar_leadlimit_override;
+       gamemode_name = MapInfo_Type_ToText(MapInfo_LoadedGametype);
 
        if(g_dm)
        {
-               game = GAME_DEATHMATCH;
-               gamemode_name = "Deathmatch";
        }
 
        if(g_tdm)
        {
-               game = GAME_TEAM_DEATHMATCH;
-               gamemode_name = "Team Deathmatch";
                ActivateTeamplay();
                tdm_init();
                if(autocvar_g_tdm_team_spawns)
@@ -217,8 +147,6 @@ void InitGameplayMode()
 
        if(g_domination)
        {
-               game = GAME_DOMINATION;
-               gamemode_name = "Domination";
                ActivateTeamplay();
                fraglimit_override = autocvar_g_domination_point_limit;
                leadlimit_override = autocvar_g_domination_point_leadlimit;
@@ -228,28 +156,16 @@ void InitGameplayMode()
 
        if(g_ctf)
        {
-               game = GAME_CTF;
-               gamemode_name = "Capture the Flag";
                ActivateTeamplay();
                g_ctf_ignore_frags = autocvar_g_ctf_ignore_frags;
-               if(g_ctf_win_mode == 2)
-               {
-                       fraglimit_override = autocvar_g_ctf_capture_limit;
-                       leadlimit_override = autocvar_g_ctf_capture_leadlimit;
-               }
-               else
-               {
-                       fraglimit_override = autocvar_capturelimit_override;
-                       leadlimit_override = autocvar_captureleadlimit_override;
-               }
+               fraglimit_override = autocvar_capturelimit_override;
+               leadlimit_override = autocvar_captureleadlimit_override;
                ctf_init();
                have_team_spawns = -1; // request team spawns
        }
 
        if(g_runematch)
        {
-               game = GAME_RUNEMATCH;
-               gamemode_name = "Rune Match";
                // ActivateTeamplay();
                fraglimit_override = autocvar_g_runematch_point_limit;
                leadlimit_override = autocvar_g_runematch_point_leadlimit;
@@ -258,8 +174,6 @@ void InitGameplayMode()
 
        if(g_lms)
        {
-               game = GAME_LMS;
-               gamemode_name = "Last Man Standing";
                fraglimit_override = autocvar_g_lms_lives_override;
                leadlimit_override = 0; // not supported by LMS
                if(fraglimit_override == 0)
@@ -271,8 +185,6 @@ void InitGameplayMode()
 
        if(g_arena)
        {
-               game = GAME_ARENA;
-               gamemode_name = "Arena";
                fraglimit_override = autocvar_g_arena_point_limit;
                leadlimit_override = autocvar_g_arena_point_leadlimit;
                maxspawned = autocvar_g_arena_maxspawned;
@@ -283,8 +195,6 @@ void InitGameplayMode()
 
        if(g_ca)
        {
-               game = GAME_CA;
-               gamemode_name = "Clan Arena";
                ActivateTeamplay();
                fraglimit_override = autocvar_g_ca_point_limit;
                leadlimit_override = autocvar_g_ca_point_leadlimit;
@@ -293,8 +203,6 @@ void InitGameplayMode()
        }
        if(g_keyhunt)
        {
-               game = GAME_KEYHUNT;
-               gamemode_name = "Key Hunt";
                ActivateTeamplay();
                fraglimit_override = autocvar_g_keyhunt_point_limit;
                leadlimit_override = autocvar_g_keyhunt_point_leadlimit;
@@ -303,8 +211,6 @@ void InitGameplayMode()
 
        if(g_freezetag)
        {
-               game = GAME_FREEZETAG;
-               gamemode_name = "Freeze Tag";
                ActivateTeamplay();
                fraglimit_override = autocvar_g_freezetag_point_limit;
                leadlimit_override = autocvar_g_freezetag_point_leadlimit;
@@ -313,8 +219,6 @@ void InitGameplayMode()
 
        if(g_assault)
        {
-               game = GAME_ASSAULT;
-               gamemode_name = "Assault";
                ActivateTeamplay();
                ScoreRules_assault();
                have_team_spawns = -1; // request team spawns
@@ -322,16 +226,12 @@ void InitGameplayMode()
 
        if(g_onslaught)
        {
-               game = GAME_ONSLAUGHT;
-               gamemode_name = "Onslaught";
                ActivateTeamplay();
                have_team_spawns = -1; // request team spawns
        }
 
        if(g_race)
        {
-               game = GAME_RACE;
-               gamemode_name = "Race";
 
                if(autocvar_g_race_teams)
                {
@@ -349,8 +249,6 @@ void InitGameplayMode()
 
        if(g_cts)
        {
-               game = GAME_CTS;
-               gamemode_name = "CTS";
                g_race_qualifying = 1;
                fraglimit_override = 0;
                leadlimit_override = 0;
@@ -358,30 +256,22 @@ void InitGameplayMode()
 
        if(g_nexball)
        {
-        game = GAME_NEXBALL;
-        gamemode_name = "Nexball";
-        fraglimit_override = autocvar_g_nexball_goallimit;
-        leadlimit_override = autocvar_g_nexball_goalleadlimit;
-        ActivateTeamplay();
-        have_team_spawns = -1; // request team spawns
 
-           MUTATOR_ADD(gamemode_nexball);
+               fraglimit_override = autocvar_g_nexball_goallimit;
+               leadlimit_override = autocvar_g_nexball_goalleadlimit;
+               ActivateTeamplay();
+               have_team_spawns = -1; // request team spawns
+        MUTATOR_ADD(gamemode_nexball);
        }
         
-
        if(g_keepaway)
        {
-               game = GAME_KEEPAWAY;
-               gamemode_name = "Keepaway";
                MUTATOR_ADD(gamemode_keepaway);
        }
 
        if(teamplay)
                entcs_init();
 
-       // save it (for the next startup)
-       cvar_set("gamecfg", ftos(game));
-
        cache_mutatormsg = strzone("");
        cache_lastmutatormsg = strzone("");