]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/scores.qh
Merge branch 'master' into Juhu/scoreboard-strafe
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / scores.qh
1 #pragma once
2
3 #define MAX_SCORE 64
4
5 #define REGISTER_SP(id) REGISTER(Scores, SP, id, m_id, new_pure(PlayerScoreField))
6 REGISTRY(Scores, MAX_SCORE);
7 REGISTER_REGISTRY(Scores)
8 // do not sort alphabetically, player sort priority is based on score registration order
9 //REGISTRY_SORT(Scores);
10 REGISTRY_CHECK(Scores);
11
12 REGISTRY_DEFINE_GET(Scores, NULL)
13 STATIC_INIT(Scores_renumber) { FOREACH(Scores, true, it.m_id = i); }
14
15 /*
16  * Score indices
17  */
18 #ifdef GAMEQC
19 // networked fields
20 // NOTE: score registration order is used as player sort priority (after primary and secondary)
21
22 // TODO: move gamemode scores to gamemode files
23 // TODO: allow gamemodes to fully customize player sorting priority, even the common ones
24
25 REGISTER_SP(RACE_LAPS);
26 REGISTER_SP(RACE_TIME);
27 REGISTER_SP(RACE_FASTEST);
28
29 REGISTER_SP(CTS_STRAFE);
30 REGISTER_SP(CTS_STARTSPEED);
31 REGISTER_SP(CTS_AVGSPEED);
32 REGISTER_SP(CTS_TOPSPEED);
33
34 REGISTER_SP(ASSAULT_OBJECTIVES);
35
36 REGISTER_SP(CTF_CAPS);
37 REGISTER_SP(CTF_FCKILLS);
38 REGISTER_SP(CTF_RETURNS);
39 REGISTER_SP(CTF_DROPS);
40 REGISTER_SP(CTF_PICKUPS);
41 REGISTER_SP(CTF_CAPTIME);
42
43 REGISTER_SP(DOM_TAKES);
44 REGISTER_SP(DOM_TICKS);
45
46 REGISTER_SP(FREEZETAG_REVIVALS);
47
48 REGISTER_SP(KEEPAWAY_BCTIME);
49 REGISTER_SP(KEEPAWAY_CARRIERKILLS);
50 REGISTER_SP(KEEPAWAY_PICKUPS);
51
52 REGISTER_SP(KH_CAPS);
53 REGISTER_SP(KH_KCKILLS);
54 REGISTER_SP(KH_LOSSES);
55 REGISTER_SP(KH_DESTROYS);
56 REGISTER_SP(KH_PUSHES);
57 REGISTER_SP(KH_PICKUPS);
58
59 REGISTER_SP(LMS_RANK);
60 REGISTER_SP(LMS_LIVES);
61
62 REGISTER_SP(NEXBALL_GOALS);
63 REGISTER_SP(NEXBALL_FAULTS);
64
65 REGISTER_SP(ONS_CAPS);
66 REGISTER_SP(ONS_TAKES);
67
68 REGISTER_SP(TKA_PICKUPS);
69 REGISTER_SP(TKA_BCTIME);
70 REGISTER_SP(TKA_CARRIERKILLS);
71
72 REGISTER_SP(SURV_SURVIVALS);
73 REGISTER_SP(SURV_HUNTS);
74
75 REGISTER_SP(SCORE);
76 REGISTER_SP(KILLS);
77 REGISTER_SP(DEATHS);
78 REGISTER_SP(TEAMKILLS);
79 REGISTER_SP(SUICIDES);
80 REGISTER_SP(DMG);
81 REGISTER_SP(DMGTAKEN);
82
83 REGISTER_SP(ROUNDS_PL);
84
85 REGISTER_SP(ELO); // not sortable
86 REGISTER_SP(FPS); // not sortable
87
88 // fields not networked via the score system
89 REGISTER_SP(END);
90
91 REGISTER_SP(PING);
92 REGISTER_SP(PL);
93 REGISTER_SP(NAME);
94 REGISTER_SP(SEPARATOR);
95
96 REGISTER_SP(KDRATIO); // kills / deaths
97 REGISTER_SP(SUM); // kills - deaths
98 REGISTER_SP(FRAGS); // kills - suicides
99 #endif
100
101
102 // the stuff you don't need to see
103
104 /**
105  * Lower scores are better (e.g. suicides)
106  */
107 const int SFL_LOWER_IS_BETTER = BIT(0);
108
109 /**
110  * Don't show zero values as scores
111  */
112 const int SFL_HIDE_ZERO = BIT(1);
113
114 /**
115  * Allow a column to be hidden (do not automatically add it even if it is a sorting key)
116  */
117 const int SFL_ALLOW_HIDE = BIT(4);
118
119 /**
120  * Display as a rank (with st, nd, rd, th suffix)
121  */
122 const int SFL_RANK = BIT(5);
123
124 /**
125  * Display as mm:ss.s, value is stored as 10ths of a second (AND 0 is the worst possible value!)
126  */
127 const int SFL_TIME = BIT(6);
128
129 const int SFL_NOT_SORTABLE = BIT(7); // don't sort by this field
130
131 // not an extra constant yet
132 #define SFL_ZERO_IS_WORST SFL_TIME
133
134 /**
135  * Scoring priority (NOTE: PRIMARY is used for fraglimit)
136  * NOTE: SFL_SORT_PRIO_SECONDARY value must be lower than SFL_SORT_PRIO_PRIMARY's
137  */
138 const int SFL_SORT_PRIO_SECONDARY = BIT(2);
139 const int SFL_SORT_PRIO_PRIMARY = BIT(3);
140 const int SFL_SORT_PRIO_MASK = SFL_SORT_PRIO_PRIMARY | SFL_SORT_PRIO_SECONDARY;
141
142 #define IS_INCREASING(x) ( (x) & SFL_LOWER_IS_BETTER )
143 #define IS_DECREASING(x) ( !((x) & SFL_LOWER_IS_BETTER) )
144
145 USING(PlayerScoreField, entity);
146 .int _scores[MAX_SCORE];
147 .string m_name;
148 .int m_flags;
149
150 #define scores(this) _scores[(this).m_id]
151 #define scores_label(this) ((this).m_name)
152 #define scores_flags(this) ((this).m_flags)
153
154 #define MAX_TEAMSCORE 2
155 USING(ScoreTeam, string);
156 .int _teamscores[MAX_TEAMSCORE];
157 #define teamscores(i) _teamscores[i]
158 string _teamscores_label[MAX_TEAMSCORE];
159 #define teamscores_label(i) _teamscores_label[i]
160 int _teamscores_flags[MAX_TEAMSCORE];
161 #define teamscores_flags(i) _teamscores_flags[i]
162
163 const int ST_SCORE = 0;