]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores_rules.qc
Use a bitflag to count how many teams are available (allows support for some strange...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / scores_rules.qc
1 #include "scores_rules.qh"
2
3 #include "cl_client.qh"
4 #include "scores.qh"
5
6 void CheckAllowedTeams (entity for_whom);
7
8 int NumTeams(int teams)
9 {
10         return (teams & BIT(0)) + (teams & BIT(1)) + (teams & BIT(2)) + (teams & BIT(3));
11 }
12
13 // NOTE: SP_ constants may not be >= MAX_SCORE; ST_constants may not be >= MAX_TEAMSCORE
14 // scores that should be in all modes:
15 int ScoreRules_teams;
16 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
17 {
18         float i;
19         for(i = 0; i < MAX_SCORE; ++i)
20                 ScoreInfo_SetLabel_PlayerScore(i, "", 0);
21         for(i = 0; i < MAX_TEAMSCORE; ++i)
22                 ScoreInfo_SetLabel_TeamScore(i, "", 0);
23
24         ScoreRules_teams = teams;
25
26         if(score_enabled)
27                 ScoreInfo_SetLabel_TeamScore  (ST_SCORE,        "score",     stprio);
28
29         if (!INDEPENDENT_PLAYERS)
30                 ScoreInfo_SetLabel_PlayerScore(SP_KILLS,        "kills",     0);
31
32         ScoreInfo_SetLabel_PlayerScore(SP_DEATHS,       "deaths",    SFL_LOWER_IS_BETTER);
33
34         if (!INDEPENDENT_PLAYERS)
35                 ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES,     "suicides",  SFL_LOWER_IS_BETTER);
36
37         if(score_enabled)
38                 ScoreInfo_SetLabel_PlayerScore(SP_SCORE,        "score",     sprio);
39
40         ScoreInfo_SetLabel_PlayerScore(SP_DMG, "damage", 0);
41         ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "damagetaken", SFL_LOWER_IS_BETTER);
42 }
43 void ScoreRules_basics_end()
44 {
45         ScoreInfo_Init(ScoreRules_teams);
46 }
47 void ScoreRules_generic()
48 {
49         if(teamplay)
50         {
51                 CheckAllowedTeams(NULL);
52                 int teams = 0;
53                 if(c1 >= 0) teams |= BIT(0);
54                 if(c2 >= 0) teams |= BIT(1);
55                 if(c3 >= 0) teams |= BIT(2);
56                 if(c4 >= 0) teams |= BIT(3);
57                 ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true);
58         }
59         else
60                 ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true);
61         ScoreRules_basics_end();
62 }