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

Go to the source code of this file.

Functions

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.
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_limit_lead_initialized
bool GameRules_limit_score_initialized
bool GameRules_limit_time_initialized
bool GameRules_limit_time_qualifying_initialized

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)
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
float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
Adds a score to the player's scores.
Definition scores.qc:352

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_limit_lead_initialized

bool GameRules_limit_lead_initialized

Definition at line 32 of file sv_rules.qc.

Referenced by GameRules_limit_lead().

◆ GameRules_limit_score_initialized

bool GameRules_limit_score_initialized

Definition at line 22 of file sv_rules.qc.

Referenced by GameRules_limit_score().

◆ GameRules_limit_time_initialized

bool GameRules_limit_time_initialized

Definition at line 42 of file sv_rules.qc.

Referenced by GameRules_limit_time().

◆ GameRules_limit_time_qualifying_initialized

bool GameRules_limit_time_qualifying_initialized

Definition at line 52 of file sv_rules.qc.

Referenced by GameRules_limit_time_qualifying().