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