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

Go to the source code of this file.

Macros

#define EVAL_REPLICATE(...)
#define REPLICATE(...)
 Replicates a client cvar into a server field.
#define REPLICATE_3(fld, type, var)
#define REPLICATE_4(fld, type, var, func)
#define REPLICATE_7(fld, type, var, func, check, update, destroy)
#define REPLICATE_7(fld, type, var, func, create, destroy, after)
#define REPLICATE_APPLYCHANGE(var, ApplyChange_code)
 Allows setting code that will be executed on cvar value changes.
#define REPLICATE_bool(fld, var, func)
#define REPLICATE_bool(fld, var, func)
#define REPLICATE_float(fld, var, func)
#define REPLICATE_float(fld, var, func)
#define REPLICATE_INIT(type, name)
#define REPLICATE_INIT(type, name)
#define REPLICATE_int(fld, var, func)
#define REPLICATE_int(fld, var, func)
#define REPLICATE_SIMPLE(field, cvarname)
#define REPLICATE_string(fld, var, func)
#define REPLICATE_string(fld, var, func)
#define REPLICATE_vector(fld, var, func)
#define REPLICATE_vector(fld, var, func)

Functions

ACCUMULATE void ReplicateVars (entity this, entity store, string thisname, int i)
ACCUMULATE void ReplicateVars (int mode)
ACCUMULATE void ReplicateVars_ApplyChange (entity this, entity store, string thisname, int i)
void ReplicateVars_Send (string cvarname)
void ReplicateVars_Start ()

Variables

const int REPLICATEVARS_CHECK = 0
 check if any cvar has changed and sync it with the server
const int REPLICATEVARS_DESTROY = 1
 destroy data associated with cvars (shutdown)
const int REPLICATEVARS_SEND_ALL = -1
 sync all cvars with the server (init)
noref float ReplicateVars_time

Macro Definition Documentation

◆ EVAL_REPLICATE

#define EVAL_REPLICATE ( ...)
Value:
__VA_ARGS__

Definition at line 24 of file replicate.qh.

◆ REPLICATE

#define REPLICATE ( ...)
Value:
#define EVAL_REPLICATE(...)
Definition replicate.qh:24
#define REPLICATE(...)
Replicates a client cvar into a server field.
Definition replicate.qh:23
#define OVERLOAD(F,...)
Definition misc.qh:12

Replicates a client cvar into a server field.

Parameters
fldThe field to replicate into
typeThe field type
cvarname
fixup_func((entitythis, string original_value)) optional parameter

Definition at line 23 of file replicate.qh.

Referenced by REPLICATE(), REPLICATE(), REPLICATE(), and REPLICATE().

◆ REPLICATE_3

#define REPLICATE_3 ( fld,
type,
var )
Value:
REPLICATE_4(fld, type, var, )
#define REPLICATE_4(fld, type, var, func)
Definition replicate.qh:61

Definition at line 60 of file replicate.qh.

◆ REPLICATE_4

#define REPLICATE_4 ( fld,
type,
var,
func )
Value:
REPLICATE_##type(fld, var, func)

Definition at line 61 of file replicate.qh.

◆ REPLICATE_7 [1/2]

#define REPLICATE_7 ( fld,
type,
var,
func,
check,
update,
destroy )
Value:
void ReplicateVars(int mode) \
{ \
if (mode == REPLICATEVARS_DESTROY) \
LAMBDA(destroy) \
else if (mode == REPLICATEVARS_SEND_ALL || (check)) \
{ \
ReplicateVars_Send(var); \
LAMBDA(update) \
} \
}
const int REPLICATEVARS_DESTROY
destroy data associated with cvars (shutdown)
Definition replicate.qh:6
const int REPLICATEVARS_SEND_ALL
sync all cvars with the server (init)
Definition replicate.qh:4
void ReplicateVars(bool would_destroy)
Definition all.qh:885

Definition at line 79 of file replicate.qh.

79 #define REPLICATE_7(fld, type, var, func, create, destroy, after) \
80 void ReplicateVars(entity this, entity store, string thisname, int i) \
81 { \
82 type field = store.fld; \
83 if (i < 0) \
84 LAMBDA(destroy) \
85 else \
86 { \
87 string it = func(argv(i + 1)); \
88 bool current = (thisname == var); \
89 if (i > 0) \
90 { \
91 if (current) \
92 LAMBDA(create) \
93 } \
94 else \
95 stuffcmd(this, strcat("cl_cmd sendcvar ", var, "\n")); \
96 if (current) \
97 LAMBDA(after) \
98 } \
99 store.fld = field; \
100 }

◆ REPLICATE_7 [2/2]

#define REPLICATE_7 ( fld,
type,
var,
func,
create,
destroy,
after )
Value:
void ReplicateVars(entity this, entity store, string thisname, int i) \
{ \
type field = store.fld; \
if (i < 0) \
LAMBDA(destroy) \
else \
{ \
string it = func(argv(i + 1)); \
bool current = (thisname == var); \
if (i > 0) \
{ \
if (current) \
LAMBDA(create) \
} \
else \
stuffcmd(this, strcat("cl_cmd sendcvar ", var, "\n")); \
if (current) \
LAMBDA(after) \
} \
store.fld = field; \
}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

Definition at line 79 of file replicate.qh.

79 #define REPLICATE_7(fld, type, var, func, create, destroy, after) \
80 void ReplicateVars(entity this, entity store, string thisname, int i) \
81 { \
82 type field = store.fld; \
83 if (i < 0) \
84 LAMBDA(destroy) \
85 else \
86 { \
87 string it = func(argv(i + 1)); \
88 bool current = (thisname == var); \
89 if (i > 0) \
90 { \
91 if (current) \
92 LAMBDA(create) \
93 } \
94 else \
95 stuffcmd(this, strcat("cl_cmd sendcvar ", var, "\n")); \
96 if (current) \
97 LAMBDA(after) \
98 } \
99 store.fld = field; \
100 }

◆ REPLICATE_APPLYCHANGE

#define REPLICATE_APPLYCHANGE ( var,
ApplyChange_code )
Value:
void ReplicateVars_ApplyChange(entity this, entity store, string thisname, int i) \
{ \
if (thisname == var) \
LAMBDA(ApplyChange_code) \
}
ACCUMULATE void ReplicateVars_ApplyChange(entity this, entity store, string thisname, int i)
Definition replicate.qh:28

Allows setting code that will be executed on cvar value changes.

Parameters
cvarname
ApplyChange_codecode meant to be run on cvar value changes

Definition at line 36 of file replicate.qh.

36 #define REPLICATE_APPLYCHANGE(var, ApplyChange_code) \
37 void ReplicateVars_ApplyChange(entity this, entity store, string thisname, int i) \
38 { \
39 if (thisname == var) \
40 LAMBDA(ApplyChange_code) \
41 }

◆ REPLICATE_bool [1/2]

#define REPLICATE_bool ( fld,
var,
func )
Value:
REPLICATE_7(fld, bool, var, func, fld != cvar(var), fld = cvar(var), )
#define REPLICATE_7(fld, type, var, func, create, destroy, after)
Definition replicate.qh:79
float cvar(string name)

Definition at line 76 of file replicate.qh.

◆ REPLICATE_bool [2/2]

#define REPLICATE_bool ( fld,
var,
func )
Value:
REPLICATE_7(fld, bool, var, func, field = boolean(stoi(it)), , )
#define stoi(s)
Definition int.qh:4

Definition at line 76 of file replicate.qh.

◆ REPLICATE_float [1/2]

#define REPLICATE_float ( fld,
var,
func )
Value:
REPLICATE_7(fld, float, var, func, fld != cvar(var), fld = cvar(var), )

Definition at line 75 of file replicate.qh.

◆ REPLICATE_float [2/2]

#define REPLICATE_float ( fld,
var,
func )
Value:
REPLICATE_7(fld, float, var, func, field = stof(it), , )
float stof(string val,...)

Definition at line 75 of file replicate.qh.

◆ REPLICATE_INIT [1/2]

#define REPLICATE_INIT ( type,
name )
Value:
.type name
string name
Definition menu.qh:30

Definition at line 7 of file replicate.qh.

◆ REPLICATE_INIT [2/2]

#define REPLICATE_INIT ( type,
name )
Value:
type name

Definition at line 7 of file replicate.qh.

◆ REPLICATE_int [1/2]

#define REPLICATE_int ( fld,
var,
func )
Value:
REPLICATE_7(fld, int, var, func, fld != cvar(var), fld = cvar(var), )

Definition at line 77 of file replicate.qh.

◆ REPLICATE_int [2/2]

#define REPLICATE_int ( fld,
var,
func )
Value:
REPLICATE_7(fld, int, var, func, field = stoi(it), , )

Definition at line 77 of file replicate.qh.

◆ REPLICATE_SIMPLE

#define REPLICATE_SIMPLE ( field,
cvarname )
Value:
MACRO_BEGIN \
float thecvar = cvar(cvarname); \
if (field != thecvar) \
{ \
ReplicateVars_Send(cvarname); \
field = thecvar; \
} \
#define MACRO_END
Definition macro.qh:7

Definition at line 125 of file replicate.qh.

125 #define REPLICATE_SIMPLE(field, cvarname) MACRO_BEGIN \
126 float thecvar = cvar(cvarname); \
127 if (field != thecvar) \
128 { \
129 ReplicateVars_Send(cvarname); \
130 field = thecvar; \
131 } \
132 MACRO_END

◆ REPLICATE_string [1/2]

#define REPLICATE_string ( fld,
var,
func )
Value:
REPLICATE_7(fld, float, var, func, fld != cvar_string(var), strcpy(fld, cvar_string(var)), strfree(fld))
const string cvar_string(string name)
#define strfree(this)
Definition string.qh:57
#define strcpy(this, s)
Definition string.qh:51

Definition at line 63 of file replicate.qh.

63 #define REPLICATE_string(fld, var, func) \
64 REPLICATE_7(fld, string, var, , \
65 strcpy(field, it), \
66 strfree(field), \
67 { \
68 /* also initialize to the default value of func when requesting cvars */ \
69 string s = func(this, strcat(field)); \
70 if (s != field) \
71 strcpy(field, s); \
72 } \
73 )

◆ REPLICATE_string [2/2]

#define REPLICATE_string ( fld,
var,
func )
Value:
REPLICATE_7(fld, string, var, , \
strcpy(field, it), \
strfree(field), \
{ \
/* also initialize to the default value of func when requesting cvars */ \
string s = func(this, strcat(field)); \
if (s != field) \
strcpy(field, s); \
} \
)

Definition at line 63 of file replicate.qh.

63 #define REPLICATE_string(fld, var, func) \
64 REPLICATE_7(fld, string, var, , \
65 strcpy(field, it), \
66 strfree(field), \
67 { \
68 /* also initialize to the default value of func when requesting cvars */ \
69 string s = func(this, strcat(field)); \
70 if (s != field) \
71 strcpy(field, s); \
72 } \
73 )

◆ REPLICATE_vector [1/2]

#define REPLICATE_vector ( fld,
var,
func )
Value:
REPLICATE_7(fld, vector, var, func, fld != stov(cvar_string(var)), fld = stov(cvar_string(var)), )
vector stov(string s)
vector
Definition self.qh:96

Definition at line 74 of file replicate.qh.

◆ REPLICATE_vector [2/2]

#define REPLICATE_vector ( fld,
var,
func )
Value:
REPLICATE_7(fld, vector, var, func, field = stov(it), , )

Definition at line 74 of file replicate.qh.

Function Documentation

◆ ReplicateVars() [1/2]

ACCUMULATE void ReplicateVars ( entity this,
entity store,
string thisname,
int i )

Definition at line 27 of file replicate.qh.

27{}

References ACCUMULATE, and entity().

Referenced by ReplicateVars_Start().

◆ ReplicateVars() [2/2]

ACCUMULATE void ReplicateVars ( int mode)

Definition at line 44 of file replicate.qh.

45 {
47 return;
48 ReplicateVars_time = time + 0.8 + random() * 0.4; // check cvars periodically
49 }
float time
noref float ReplicateVars_time
Definition replicate.qh:43
float random(void)

References ACCUMULATE, random(), ReplicateVars_time, and time.

◆ ReplicateVars_ApplyChange()

ACCUMULATE void ReplicateVars_ApplyChange ( entity this,
entity store,
string thisname,
int i )

Definition at line 28 of file replicate.qh.

28{}

References ACCUMULATE, and entity().

Referenced by GetCvars().

◆ ReplicateVars_Send()

void ReplicateVars_Send ( string cvarname)

Definition at line 108 of file replicate.qh.

109 {
110 localcmd(strcat("cl_cmd sendcvar ", cvarname, "\n"));
111 }
void localcmd(string command,...)

References localcmd(), and strcat().

◆ ReplicateVars_Start()

void ReplicateVars_Start ( )

Definition at line 50 of file replicate.qh.

51 {
52 if (!ReplicateVars_time) // make sure it gets executed only once
53 {
56 }
57 }
ACCUMULATE void ReplicateVars(entity this, entity store, string thisname, int i)
Definition replicate.qh:27

References ReplicateVars(), REPLICATEVARS_SEND_ALL, ReplicateVars_time, and time.

Referenced by PostInit().

Variable Documentation

◆ REPLICATEVARS_CHECK

const int REPLICATEVARS_CHECK = 0

check if any cvar has changed and sync it with the server

Definition at line 5 of file replicate.qh.

Referenced by CSQC_UpdateView().

◆ REPLICATEVARS_DESTROY

const int REPLICATEVARS_DESTROY = 1

destroy data associated with cvars (shutdown)

Definition at line 6 of file replicate.qh.

Referenced by Shutdown().

◆ REPLICATEVARS_SEND_ALL

const int REPLICATEVARS_SEND_ALL = -1

sync all cvars with the server (init)

Definition at line 4 of file replicate.qh.

Referenced by ReplicateVars_Start().

◆ ReplicateVars_time

noref float ReplicateVars_time

Definition at line 43 of file replicate.qh.

Referenced by ReplicateVars(), and ReplicateVars_Start().