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