]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/scores_rules.qc
Update default video settings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / scores_rules.qc
1 #include "scores_rules.qh"
2
3 #include <common/gamemodes/rules.qh>
4 #include <common/stats.qh>
5 #include <common/weapons/_all.qh>
6 #include <server/client.qh>
7 #include <server/scores.qh>
8 #include <server/teamplay.qh>
9
10 int ScoreRules_teams;
11
12 bool IsTeamAvailable(int team_num)
13 {
14         return boolean(ScoreRules_teams & Team_TeamToBit(team_num));
15 }
16
17 int NumTeams(int teams)
18 {
19         return boolean(teams & BIT(0)) + boolean(teams & BIT(1)) + boolean(teams & BIT(2)) + boolean(teams & BIT(3));
20 }
21
22 int AvailableTeams()
23 {
24         return NumTeams(ScoreRules_teams);
25 }
26
27 // NOTE: ST_constants may not be >= MAX_TEAMSCORE
28 // scores that should be in all modes:
29 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
30 {
31         FOREACH(Scores, true, {
32                 ScoreInfo_SetLabel_PlayerScore(it, "", 0);
33         });
34         for(int i = 0; i < MAX_TEAMSCORE; ++i)
35                 ScoreInfo_SetLabel_TeamScore(i, "", 0);
36
37         ScoreRules_teams = teams;
38
39         if(score_enabled)
40                 ScoreInfo_SetLabel_TeamScore(ST_SCORE, "score", stprio);
41
42         if (!INDEPENDENT_PLAYERS)
43                 ScoreInfo_SetLabel_PlayerScore(SP_KILLS, "kills", 0);
44
45         ScoreInfo_SetLabel_PlayerScore(SP_DEATHS, "deaths", SFL_LOWER_IS_BETTER);
46
47         if (!INDEPENDENT_PLAYERS)
48         {
49                 ScoreInfo_SetLabel_PlayerScore(SP_SUICIDES, "suicides", SFL_LOWER_IS_BETTER);
50                 ScoreInfo_SetLabel_PlayerScore(SP_TEAMKILLS, "teamkills", SFL_LOWER_IS_BETTER);
51         }
52
53         if(score_enabled)
54                 ScoreInfo_SetLabel_PlayerScore(SP_SCORE, "score", sprio);
55
56         ScoreInfo_SetLabel_PlayerScore(SP_DMG, "dmg", 0);
57         ScoreInfo_SetLabel_PlayerScore(SP_DMGTAKEN, "dmgtaken", SFL_LOWER_IS_BETTER);
58         ScoreInfo_SetLabel_PlayerScore(SP_ELO, "elo", 0);
59
60         if(STAT(SHOWFPS))
61                 ScoreInfo_SetLabel_PlayerScore(SP_FPS, "fps", 0);
62 }
63
64 void ScoreRules_basics_end()
65 {
66         ScoreInfo_Init(ScoreRules_teams);
67 }
68
69 void ScoreRules_generic()
70 {
71         int teams = 0;
72         if (teamplay)
73         {
74                 entity balance = TeamBalance_CheckAllowedTeams(NULL);
75                 teams = TeamBalance_GetAllowedTeams(balance);
76                 TeamBalance_Destroy(balance);
77         }
78         GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, {});
79 }