Merge branch 'master' into Mario/stats_eloranking
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / handicap.qc
1 #include "handicap.qh"
2
3 /// \file
4 /// \brief Source file that contains implementation of the handicap system.
5 /// \author Lyberta
6 /// \copyright GNU GPLv2 or any later version.
7
8 #include <common/state.qh>
9 #include "client.qh"
10
11 .float m_handicap; ///< Holds the handicap value.
12
13 void Handicap_Initialize(entity player)
14 {
15         CS(player).m_handicap = 1;
16 }
17
18 float Handicap_GetVoluntaryHandicap(entity player)
19 {
20         return bound(1.0, CS(player).cvar_cl_handicap, 10.0);
21 }
22
23 float Handicap_GetForcedHandicap(entity player)
24 {
25         return (CS(player)) ? CS(player).m_handicap : 1;
26 }
27
28 void Handicap_SetForcedHandicap(entity player, float value)
29 {
30         if (value <= 0)
31         {
32                 error("Handicap_SetForcedHandicap: Invalid handicap value.");
33         }
34         CS(player).m_handicap = value;
35 }
36
37 float Handicap_GetTotalHandicap(entity player)
38 {
39         return Handicap_GetForcedHandicap(player) * Handicap_GetVoluntaryHandicap(
40                 player);
41 }