]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc
Use gender-neutral pronouns when referring to the player
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / domination / sv_domination.qc
index d8e2bb3627d42ce3ef012ed950bccb9956ac0eed..a82be5a3c10df5df35c76ad37e7e152a4431c79c 100644 (file)
@@ -32,9 +32,9 @@ void set_dom_state(entity e)
        STAT(DOM_TOTAL_PPS, e) = total_pps;
        STAT(DOM_PPS_RED, e) = pps_red;
        STAT(DOM_PPS_BLUE, e) = pps_blue;
-       if(domination_teams >= 3)
+       if(domination_teams & BIT(2))
                STAT(DOM_PPS_YELLOW, e) = pps_yellow;
-       if(domination_teams >= 4)
+       if(domination_teams & BIT(3))
                STAT(DOM_PPS_PINK, e) = pps_pink;
 }
 
@@ -183,7 +183,7 @@ void dompointthink(entity this)
                TeamScore_AddToTeam(this.goalentity.team, ST_SCORE, fragamt);
                TeamScore_AddToTeam(this.goalentity.team, ST_DOM_TICKS, fragamt);
 
-               // give credit to the individual player, if he is still there
+               // give credit to the individual player, if they are still there
                if (this.enemy.playerid == this.enemy_playerid)
                {
                        GameRules_scoring_add(this.enemy, SCORE, fragamt);
@@ -311,7 +311,7 @@ void Domination_count_controlpoints()
        total_control_points = 0;
        for (int i = 1; i <= NUM_TEAMS; ++i)
        {
-               Team_SetNumberOfControlPoints(Team_GetTeamFromIndex(i), 0);
+               Team_SetNumberOfOwnedItems(Team_GetTeamFromIndex(i), 0);
        }
        IL_EACH(g_dompoints, true,
        {
@@ -321,39 +321,12 @@ void Domination_count_controlpoints()
                        continue;
                }
                entity team_ = Entity_GetTeam(it.goalentity);
-               int num_control_points = Team_GetNumberOfControlPoints(team_);
+               int num_control_points = Team_GetNumberOfOwnedItems(team_);
                ++num_control_points;
-               Team_SetNumberOfControlPoints(team_, num_control_points);
+               Team_SetNumberOfOwnedItems(team_, num_control_points);
        });
 }
 
-int Domination_GetWinnerTeam()
-{
-       int winner_team = 0;
-       if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(1)) ==
-               total_control_points)
-       {
-               winner_team = NUM_TEAM_1;
-       }
-       for (int i = 2; i <= NUM_TEAMS; ++i)
-       {
-               if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(i)) ==
-                       total_control_points)
-               {
-                       if (winner_team != 0)
-                       {
-                               return 0;
-                       }
-                       winner_team = Team_IndexToTeam(i);
-               }
-       }
-       if (winner_team)
-       {
-               return winner_team;
-       }
-       return -1; // no control points left?
-}
-
 bool Domination_CheckWinner()
 {
        if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
@@ -367,11 +340,9 @@ bool Domination_CheckWinner()
        }
 
        Domination_count_controlpoints();
-
-       float winner_team = Domination_GetWinnerTeam();
-
-       if(winner_team == -1)
-               return false;
+       int winner_team = Team_GetWinnerTeam_WithOwnedItems(total_control_points);
+       if (winner_team == -1)
+               return 0;
 
        if(winner_team > 0)
        {
@@ -379,11 +350,6 @@ bool Domination_CheckWinner()
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(winner_team, INFO_ROUND_TEAM_WIN));
                TeamScore_AddToTeam(winner_team, ST_DOM_CAPS, +1);
        }
-       else if(winner_team == -1)
-       {
-               Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_TIED);
-               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED);
-       }
 
        game_stopped = true;
        round_handler_Init(5, autocvar_g_domination_warmup, autocvar_g_domination_round_timelimit);
@@ -461,10 +427,13 @@ MUTATOR_HOOKFUNCTION(dom, TeamBalance_CheckAllowedTeams)
 MUTATOR_HOOKFUNCTION(dom, reset_map_players)
 {
        total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
-       FOREACH_CLIENT(IS_PLAYER(it), {
-               PutClientInServer(it);
-               if(domination_roundbased)
-                       it.player_blocked = 1;
+       FOREACH_CLIENT(true, {
+               if (IS_PLAYER(it))
+               {
+                       PutClientInServer(it);
+                       if(domination_roundbased)
+                               it.player_blocked = 1;
+               }
                if(IS_REAL_CLIENT(it))
                        set_dom_state(it);
        });
@@ -556,7 +525,6 @@ spawnfunc(dom_team)
                precache_sound(this.noise);
        if (this.noise1 != "")
                precache_sound(this.noise1);
-       this.classname = "dom_team";
        _setmodel(this, this.model); // precision not needed
        this.mdl = this.model;
        this.dmg = this.modelindex;
@@ -621,7 +589,6 @@ void dom_spawnteam(string teamname, float teamcolor, string pointmodel, float po
 void dom_spawnpoint(vector org)
 {
        entity e = spawn();
-       e.classname = "dom_controlpoint";
        setthink(e, spawnfunc_dom_controlpoint);
        e.nextthink = time;
        setorigin(e, org);
@@ -634,9 +601,9 @@ void dom_spawnteams(int teams)
        TC(int, teams);
        dom_spawnteam(Team_ColoredFullName(NUM_TEAM_1), NUM_TEAM_1-1, "models/domination/dom_red.md3", 0, SND_DOM_CLAIM, "", "Red team has captured a control point");
        dom_spawnteam(Team_ColoredFullName(NUM_TEAM_2), NUM_TEAM_2-1, "models/domination/dom_blue.md3", 0, SND_DOM_CLAIM, "", "Blue team has captured a control point");
-       if(teams >= 3)
+       if(teams & BIT(2))
                dom_spawnteam(Team_ColoredFullName(NUM_TEAM_3), NUM_TEAM_3-1, "models/domination/dom_yellow.md3", 0, SND_DOM_CLAIM, "", "Yellow team has captured a control point");
-       if(teams >= 4)
+       if(teams & BIT(3))
                dom_spawnteam(Team_ColoredFullName(NUM_TEAM_4), NUM_TEAM_4-1, "models/domination/dom_pink.md3", 0, SND_DOM_CLAIM, "", "Pink team has captured a control point");
        dom_spawnteam("", 0, "models/domination/dom_unclaimed.md3", 0, SND_Null, "", "");
 }
@@ -650,14 +617,15 @@ void dom_DelayedInit(entity this) // Do this check with a delay so we can wait f
                domination_teams = autocvar_g_domination_teams_override;
                if (domination_teams < 2)
                        domination_teams = autocvar_g_domination_default_teams;
-               domination_teams = bound(2, domination_teams, 4);
+               domination_teams = BITS(bound(2, domination_teams, 4));
                dom_spawnteams(domination_teams);
        }
-
-       entity balance = TeamBalance_CheckAllowedTeams(NULL);
-       int teams = TeamBalance_GetAllowedTeams(balance);
-       TeamBalance_Destroy(balance);
-       domination_teams = teams;
+       else
+       {
+               entity balance = TeamBalance_CheckAllowedTeams(NULL);
+               domination_teams = TeamBalance_GetAllowedTeams(balance);
+               TeamBalance_Destroy(balance);
+       }
 
        domination_roundbased = autocvar_g_domination_roundbased;
 
@@ -673,5 +641,7 @@ void dom_DelayedInit(entity this) // Do this check with a delay so we can wait f
 void dom_Initialize()
 {
        g_domination = true;
+       g_dompoints = IL_NEW();
+
        InitializeEntity(NULL, dom_DelayedInit, INITPRIO_GAMETYPE);
 }