6 * Replicate a client cvar into a server field
8 * @param fld The field to replicate into
9 * @param type The field type
10 * @param cvar The cvar name
12 #define REPLICATE(...) EVAL_REPLICATE(OVERLOAD(REPLICATE, __VA_ARGS__))
13 #define EVAL_REPLICATE(...) __VA_ARGS__
15 ACCUMULATE void ReplicateVars(entity this, entity store, string thisname, int i) {}
17 #define REPLICATE_3(fld, type, var) REPLICATE_4(fld, type, var, )
18 #define REPLICATE_4(fld, type, var, func) REPLICATE_##type(fld, var, func)
19 #define REPLICATE_string(fld, var, func) \
20 REPLICATE_7(fld, string, var, , \
21 { strcpy(field, it); }, \
22 { strfree(field); }, \
24 /* also initialize to the default value of func when requesting cvars */ \
25 string s = func(field); \
31 #define REPLICATE_float(fld, var, func) REPLICATE_7(fld, float, var, func, { field = stof(it); }, , )
32 #define REPLICATE_bool(fld, var, func) REPLICATE_7(fld, bool, var, func, { field = boolean(stoi(it)); }, , )
33 #define REPLICATE_int(fld, var, func) REPLICATE_7(fld, int, var, func, { field = stoi(it); }, , )
36 #define REPLICATE_7(fld, type, var, func, create, destroy, after) \
37 void ReplicateVars(entity this, entity store, string thisname, int i) \
39 type field = store.fld; \
40 if (i < 0) { destroy } \
43 string it = func(argv(i + 1)); \
44 bool current = thisname == var; \
47 if (current) { create } \
51 stuffcmd(this, "cl_cmd sendcvar " var "\n"); \
53 if (current) { after } \
59 #define REPLICATE_7(fld, type, var, func, create, destroy, after)