]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores_rules.qc
Merged master.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / scores_rules.qc
1 #include "scores_rules.qh"
2
3 #include "client.qh"
4 #include "scores.qh"
5 #include "teamplay.qh"
6
7 int ScoreRules_teams;
8
9 void CheckAllowedTeams (entity for_whom);
10
11 int NumTeams(int teams)
12 {
13         return boolean(teams & BIT(0)) + boolean(teams & BIT(1)) + boolean(teams & BIT(2)) + boolean(teams & BIT(3));
14 }
15
16 int AvailableTeams()
17 {
18         return NumTeams(ScoreRules_teams);
19         // NOTE: this method is unreliable, as forced teams set the c* globals to weird values
20         //return boolean(c1 >= 0) + boolean(c2 >= 0) + boolean(c3 >= 0) + boolean(c4 >= 0);
21 }
22
23 // NOTE: ST_constants may not be >= MAX_TEAMSCORE
24 // scores that should be in all modes:
25 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
26 {
27         FOREACH(Scores, true, {
28                 ScoreInfo_SetLabel_PlayerScore(it, "", 0);
29     });
30         for(int i = 0; i < MAX_TEAMSCORE; ++i)
31                 ScoreInfo_SetLabel_TeamScore(i, "", 0);
32
33         ScoreRules_teams = teams;
34
35         if(score_enabled)
36                 ScoreInfo_SetLabel_TeamScore  (ST_SCORE,        "score",     stprio);
37
38         if (!INDEPENDENT_PLAYERS)
39                 ScoreInfo_SetLabel_PlayerScore(SP_KILLS,        "kills",     0);
40
41         ScoreInfo_SetLabel_PlayerScore(SP_DEATHS,       "deaths",    SFL_LOWER_IS_BETTER);
42
43         if (!INDEPENDENT_PLAYERS)
44                 ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES,     "suicides",  SFL_LOWER_IS_BETTER);
45
46         if(score_enabled)
47                 ScoreInfo_SetLabel_PlayerScore(SP_SCORE,        "score",     sprio);
48
49         ScoreInfo_SetLabel_PlayerScore(SP_DMG, "dmg", 0);
50         ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "dmgtaken", SFL_LOWER_IS_BETTER);
51         ScoreInfo_SetLabel_PlayerScore(SP_ELO, "elo", 0);
52 }
53 void ScoreRules_basics_end()
54 {
55         ScoreInfo_Init(ScoreRules_teams);
56 }
57 void ScoreRules_generic()
58 {
59         if(teamplay)
60         {
61                 CheckAllowedTeams(NULL);
62                 int teams = 0;
63                 if(c1 >= 0) teams |= BIT(0);
64                 if(c2 >= 0) teams |= BIT(1);
65                 if(c3 >= 0) teams |= BIT(2);
66                 if(c4 >= 0) teams |= BIT(3);
67                 ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true);
68         }
69         else
70                 ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true);
71         ScoreRules_basics_end();
72 }