]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Merge branch 'master' into terencehill/bot_waypoints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index 92cd8ebccedede1cfabe53bbb3211cb31df71890..24e9a5221e1e62ac7ebb30e4d3bc52f8760f54a5 100644 (file)
@@ -37,21 +37,20 @@ void default_delayedinit(entity this)
                ScoreRules_generic();
 }
 
-void ActivateTeamplay()
-{
-       serverflags |= SERVERFLAG_TEAMPLAY;
-       teamplay = 1;
-       cvar_set("teamplay", "2");  // DP needs this for sending proper getstatus replies.
-}
-
 void InitGameplayMode()
 {
        VoteReset();
 
        // 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;
+       // assign reflectively to avoid "assignment to world" warning
+       int done = 0; for (int i = 0, n = numentityfields(); i < n; ++i) {
+           string k = entityfieldname(i); vector v = (k == "mins") ? mi_min : (k == "maxs") ? mi_max : '0 0 0';
+           if (v) {
+            putentityfieldstring(i, world, sprintf("%d %d %d", v));
+            if (++done == 2) break;
+        }
+       }
        // currently, NetRadiant's limit is 131072 qu for each side
        // distance from one corner of a 131072qu cube to the opposite corner is approx. 227023 qu
        // set the distance according to map size but don't go over the limit to avoid issues with float precision
@@ -59,13 +58,11 @@ void InitGameplayMode()
        max_shot_distance = min(230000, vlen(world.maxs - world.mins));
 
        MapInfo_LoadMapSettings(mapname);
-       serverflags &= ~SERVERFLAG_TEAMPLAY;
-       teamplay = 0;
-       cvar_set("teamplay", "0");  // DP needs this for sending proper getstatus replies.
+       GameRules_teams(false);
 
        if (!cvar_value_issafe(world.fog))
        {
-               LOG_INFO("The current map contains a potentially harmful fog setting, ignored\n");
+               LOG_INFO("The current map contains a potentially harmful fog setting, ignored");
                world.fog = string_null;
        }
        if(MapInfo_Map_fog != "")
@@ -851,12 +848,11 @@ int JoinBestTeam(entity this, bool only_return_best, bool force_best_team)
        // find out what teams are available
        CheckAllowedTeams(this);
 
-       int selected_team;
-
        // if we don't care what team he ends up on, put him on whatever team he entered as.
        // if he's not on a valid team, then let other code put him on the smallest team
        if (!force_best_team)
        {
+               int selected_team;
                if(     c1 >= 0 && this.team == NUM_TEAM_1)
                        selected_team = this.team;
                else if(c2 >= 0 && this.team == NUM_TEAM_2)