Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
sv_rules.qh File Reference
Include dependency graph for sv_rules.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _GameRules_scoring_begin(teams, spprio, stprio)
#define _GameRules_scoring_end   ScoreRules_basics_end
#define _GameRules_scoring_field   ScoreInfo_SetLabel_PlayerScore
#define _GameRules_scoring_field_team   ScoreInfo_SetLabel_TeamScore
#define GameRules_score_enabled(value)
#define GameRules_scoring(teams, spprio, stprio, fields)
#define GameRules_scoring_add(client, fld, value)
#define GameRules_scoring_add_float2int(client, fld, value, float_field, score_factor)
#define GameRules_scoring_add_team(client, fld, value)
#define GameRules_scoring_add_team_float2int(client, fld, value, float_field, score_factor)
#define GameRules_scoring_is_vip(player)
#define GameRules_scoring_vip(player, value)
#define GameRules_spawning_teams(value)
 Used to disable team spawns in team modes.
#define INGAME(it)
#define INGAME_JOINED(it)
#define INGAME_JOINING(it)
#define INGAME_STATUS_CLEAR(it)
#define INGAME_STATUS_JOINED   1
#define INGAME_STATUS_JOINING   0.5
#define INGAME_STATUS_NONE   0
#define INGAME_STATUS_SET(it, s)

Functions

float _GameRules_scoring_add_float2int (entity client, entity sp, int st, float value,.float float_field, float score_factor, bool team)
 Accumulates the decimal part of the score to player.
void GameRules_limit_fallbacks ()
 Set any unspecified rules to their defaults.
void GameRules_limit_lead (int limit)
void GameRules_limit_score (int limit)
void GameRules_limit_time (int limit)
void GameRules_limit_time_qualifying (int limit)
void GameRules_teams (bool value)

Variables

bool _GameRules_score_enabled = true
 Disabling score disables the "score" column on the scoreboard.
int autocvar_leadlimit_and_fraglimit
int autocvar_leadlimit_override
int ingame
bool m_GameRules_scoring_vip
 Mark a player as being 'important' (flag carrier, ball carrier, etc)
int total_players

Macro Definition Documentation

◆ _GameRules_scoring_begin

#define _GameRules_scoring_begin ( teams,
spprio,
stprio )
Value:
entity teams
Definition main.qh:58
void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
bool _GameRules_score_enabled
Disabling score disables the "score" column on the scoreboard.
Definition sv_rules.qh:40

Definition at line 67 of file sv_rules.qh.

◆ _GameRules_scoring_end

#define _GameRules_scoring_end   ScoreRules_basics_end

Definition at line 70 of file sv_rules.qh.

◆ _GameRules_scoring_field

#define _GameRules_scoring_field   ScoreInfo_SetLabel_PlayerScore

Definition at line 68 of file sv_rules.qh.

◆ _GameRules_scoring_field_team

#define _GameRules_scoring_field_team   ScoreInfo_SetLabel_TeamScore

Definition at line 69 of file sv_rules.qh.

◆ GameRules_score_enabled

#define GameRules_score_enabled ( value)
Value:

Definition at line 41 of file sv_rules.qh.

Referenced by cts_ScoreRules(), invasion_ScoreRules(), race_ScoreRules(), and REGISTER_MUTATOR().

◆ GameRules_scoring

#define GameRules_scoring ( teams,
spprio,
stprio,
fields )
Value:
MACRO_BEGIN \
_GameRules_scoring_begin((teams), (spprio), (stprio)); \
noref void(entity, string, float) field = _GameRules_scoring_field; \
/* todo: just have the one `field` function */ \
noref void(int, string, float) field_team = _GameRules_scoring_field_team; \
LAMBDA(fields); \
_GameRules_scoring_end(); \
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define MACRO_END
Definition macro.qh:7
void
Definition self.qh:72
#define _GameRules_scoring_field_team
Definition sv_rules.qh:69
#define _GameRules_scoring_field
Definition sv_rules.qh:68
Parameters
teamsa bitmask of active teams
spprioplayer score priority (if frags aren't enabled)
stprioteam score priority (if frags aren't enabled)

Definition at line 58 of file sv_rules.qh.

58#define GameRules_scoring(teams, spprio, stprio, fields) MACRO_BEGIN \
59 _GameRules_scoring_begin((teams), (spprio), (stprio)); \
60 noref void(entity, string, float) field = _GameRules_scoring_field; \
61 /* todo: just have the one `field` function */ \
62 noref void(int, string, float) field_team = _GameRules_scoring_field_team; \
63 LAMBDA(fields); \
64 _GameRules_scoring_end(); \
65MACRO_END

Referenced by ctf_ScoreRules(), cts_ScoreRules(), freezetag_Initialize(), invasion_ScoreRules(), kh_ScoreRules(), nb_ScoreRules(), ons_ScoreRules(), race_ScoreRules(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), ScoreRules_dom(), ScoreRules_generic(), and surv_Initialize().

◆ GameRules_scoring_add

#define GameRules_scoring_add ( client,
fld,
value )

◆ GameRules_scoring_add_float2int

#define GameRules_scoring_add_float2int ( client,
fld,
value,
float_field,
score_factor )
Value:
_GameRules_scoring_add_float2int(client, SP_##fld, 0, value, float_field, score_factor, false)
float _GameRules_scoring_add_float2int(entity client, entity sp, int st, float value,.float decimal_field, float score_factor, bool team)
Accumulates the decimal part of the score to player.
Definition sv_rules.qc:73

Definition at line 83 of file sv_rules.qh.

83#define GameRules_scoring_add_float2int(client, fld, value, float_field, score_factor) \
84 _GameRules_scoring_add_float2int(client, SP_##fld, 0, value, float_field, score_factor, false)

Referenced by ka_BallThink_Carried(), and MUTATOR_HOOKFUNCTION().

◆ GameRules_scoring_add_team

#define GameRules_scoring_add_team ( client,
fld,
value )
Value:
PlayerTeamScore_Add(client, SP_##fld, ST_##fld, value)
float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score)
Adds a score to both the player and the team.
Definition scores.qc:406

Definition at line 89 of file sv_rules.qh.

Referenced by assault_objective_decrease_use(), ctf_Handle_Capture(), ctf_Handle_Drop(), ctf_Handle_Pickup(), ctf_Handle_Return(), GiveFrags(), kh_WinnerTeam(), MayhemCalculatePlayerScore(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), ons_ControlPoint_Icon_BuildThink(), and race_SendTime().

◆ GameRules_scoring_add_team_float2int

#define GameRules_scoring_add_team_float2int ( client,
fld,
value,
float_field,
score_factor )
Value:
_GameRules_scoring_add_float2int(client, SP_##fld, ST_##fld, value, float_field, score_factor, true)

Definition at line 87 of file sv_rules.qh.

87#define GameRules_scoring_add_team_float2int(client, fld, value, float_field, score_factor) \
88 _GameRules_scoring_add_float2int(client, SP_##fld, ST_##fld, value, float_field, score_factor, true)

Referenced by kh_Scores_Event(), and tka_BallThink_Carried().

◆ GameRules_scoring_is_vip

#define GameRules_scoring_is_vip ( player)
Value:
bool m_GameRules_scoring_vip
Mark a player as being 'important' (flag carrier, ball carrier, etc)
Definition sv_rules.qh:77

Definition at line 79 of file sv_rules.qh.

Referenced by MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ GameRules_scoring_vip

#define GameRules_scoring_vip ( player,
value )

◆ GameRules_spawning_teams

#define GameRules_spawning_teams ( value)
Value:
have_team_spawns = (value) ? -1 : 0
int have_team_spawns

Used to disable team spawns in team modes.

Definition at line 35 of file sv_rules.qh.

Referenced by GameRules_teams(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), tdm_Initialize(), and tmayhem_Initialize().

◆ INGAME

◆ INGAME_JOINED

◆ INGAME_JOINING

#define INGAME_JOINING ( it)
Value:
((it).ingame == INGAME_STATUS_JOINING)
#define INGAME_STATUS_JOINING
Definition sv_rules.qh:16

Definition at line 26 of file sv_rules.qh.

Referenced by ca_isEliminated(), MatchEnd_RestoreSpectatorAndTeamStatus(), MUTATOR_HOOKFUNCTION(), and surv_isEliminated().

◆ INGAME_STATUS_CLEAR

#define INGAME_STATUS_CLEAR ( it)

◆ INGAME_STATUS_JOINED

#define INGAME_STATUS_JOINED   1

◆ INGAME_STATUS_JOINING

#define INGAME_STATUS_JOINING   0.5

Definition at line 16 of file sv_rules.qh.

Referenced by lms_AddPlayer(), MUTATOR_HOOKFUNCTION(), and MUTATOR_HOOKFUNCTION().

◆ INGAME_STATUS_NONE

#define INGAME_STATUS_NONE   0

Definition at line 15 of file sv_rules.qh.

◆ INGAME_STATUS_SET

#define INGAME_STATUS_SET ( it,
s )

Function Documentation

◆ _GameRules_scoring_add_float2int()

float _GameRules_scoring_add_float2int ( entity client,
entity sp,
int st,
float value,
.float decimal_field,
float score_factor,
bool team )

Accumulates the decimal part of the score to player.

(decimal_field) and adds the score to the player as int only when at least one unit of score has been accumulated. It works with negative score too Float scores can't be used as score because they aren't supported by the QC score networking system and online server browsers (e.g. qstat)

Definition at line 73 of file sv_rules.qc.

74{
75 client.(decimal_field) += value;
76 float score_counter = client.(decimal_field) / score_factor;
77 if (score_counter >= -0.5 && score_counter < 0.5)
78 return 0;
79
80 // NOTE: this code works for subtracting score too
81 int points = floor(score_counter + 0.5);
82 if (!points)
83 return 0;
84 client.(decimal_field) -= points * score_factor;
85 return team ? PlayerTeamScore_Add(client, sp, st, points) : PlayerScore_Add(client, sp, points);
86}
int team
Definition main.qh:188
float floor(float f)

References entity(), floor(), PlayerScore_Add(), PlayerTeamScore_Add(), and team.

◆ GameRules_limit_fallbacks()

void GameRules_limit_fallbacks ( )

Set any unspecified rules to their defaults.

Definition at line 62 of file sv_rules.qc.

63{
67}
#define autocvar_timelimit_override
Definition stats.qh:93
#define autocvar_fraglimit_override
Definition stats.qh:91
void GameRules_limit_score(int limit)
Definition sv_rules.qc:23
void GameRules_limit_lead(int limit)
Definition sv_rules.qc:33
void GameRules_limit_time(int limit)
Definition sv_rules.qc:43
int autocvar_leadlimit_override
Definition sv_rules.qh:9

References autocvar_fraglimit_override, autocvar_leadlimit_override, autocvar_timelimit_override, GameRules_limit_lead(), GameRules_limit_score(), and GameRules_limit_time().

Referenced by spawnfunc().

◆ GameRules_limit_lead()

void GameRules_limit_lead ( int limit)

Definition at line 33 of file sv_rules.qc.

34{
36 if (autocvar_g_campaign) return;
37 if (limit < 0) return;
38 cvar_set("leadlimit", ftos(limit));
40}
bool autocvar_g_campaign
Definition menu.qc:747
void cvar_set(string name, string value)
string ftos(float f)
bool GameRules_limit_lead_initialized
Definition sv_rules.qc:32

References autocvar_g_campaign, cvar_set(), ftos(), and GameRules_limit_lead_initialized.

Referenced by GameRules_limit_fallbacks(), mayhem_Initialize(), nb_Initialize(), rc_SetLimits(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), tdm_Initialize(), and tmayhem_Initialize().

◆ GameRules_limit_score()

◆ GameRules_limit_time()

void GameRules_limit_time ( int limit)

Definition at line 43 of file sv_rules.qc.

44{
46 if (autocvar_g_campaign) return;
47 if (limit < 0) return;
48 cvar_set("timelimit", ftos(limit));
50}
bool GameRules_limit_time_initialized
Definition sv_rules.qc:42

References autocvar_g_campaign, cvar_set(), ftos(), and GameRules_limit_time_initialized.

Referenced by GameRules_limit_fallbacks(), and rc_SetLimits().

◆ GameRules_limit_time_qualifying()

void GameRules_limit_time_qualifying ( int limit)

Definition at line 53 of file sv_rules.qc.

54{
56 if (autocvar_g_campaign) return;
57 if (limit < 0) return;
58 cvar_set("g_race_qualifying_timelimit", ftos(limit));
60}
bool GameRules_limit_time_qualifying_initialized
Definition sv_rules.qc:52

References autocvar_g_campaign, cvar_set(), ftos(), and GameRules_limit_time_qualifying_initialized.

Referenced by rc_SetLimits().

◆ GameRules_teams()

void GameRules_teams ( bool value)

Definition at line 3 of file sv_rules.qc.

4{
5 if (value)
6 {
8 teamplay = 1; // aka AVAILABLE_TEAMS, updated by ScoreRules_basics() after team ents spawn
9 cvar_set("teamplay", "2"); // DP needs this for sending proper getstatus replies.
12 }
13 else
14 {
16 teamplay = 0;
17 cvar_set("teamplay", "0"); // DP needs this for sending proper getstatus replies.
19 }
20}
int serverflags
Definition main.qh:211
const int SERVERFLAG_TEAMPLAY
Definition constants.qh:17
#define GameRules_spawning_teams(value)
Used to disable team spawns in team modes.
Definition sv_rules.qh:35
void Team_InitTeams()
Definition teamplay.qc:47
bool teamplay
Definition teams.qh:59

References cvar_set(), GameRules_spawning_teams, SERVERFLAG_TEAMPLAY, serverflags, Team_InitTeams(), and teamplay.

Referenced by InitGameplayMode(), nb_Initialize(), rc_SetLimits(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), REGISTER_MUTATOR(), tdm_Initialize(), and tmayhem_Initialize().

Variable Documentation

◆ _GameRules_score_enabled

bool _GameRules_score_enabled = true

Disabling score disables the "score" column on the scoreboard.

Definition at line 40 of file sv_rules.qh.

◆ autocvar_leadlimit_and_fraglimit

int autocvar_leadlimit_and_fraglimit

Definition at line 8 of file sv_rules.qh.

Referenced by WinningCondition_Scores().

◆ autocvar_leadlimit_override

int autocvar_leadlimit_override

Definition at line 9 of file sv_rules.qh.

Referenced by GameRules_limit_fallbacks().

◆ ingame

int ingame

Definition at line 14 of file sv_rules.qh.

◆ m_GameRules_scoring_vip

bool m_GameRules_scoring_vip

Mark a player as being 'important' (flag carrier, ball carrier, etc)

Parameters
playerthe entity to mark
valueVIP status

Definition at line 77 of file sv_rules.qh.

◆ total_players