5 #define REPLICATE(...) EVAL(OVERLOAD(REPLICATE, __VA_ARGS__))
7 [[accumulate]] void ReplicateVars(entity this, string thisname, int i) {}
9 #define REPLICATE_3(fld, type, var) REPLICATE_4(fld, type, var, )
10 #define REPLICATE_4(fld, type, var, func) REPLICATE_##type(fld, var, func)
11 #define REPLICATE_string(fld, var, func) \
12 REPLICATE_7(fld, string, var, , \
13 { if (field) strunzone(field); field = strzone(it); }, \
14 { if (field) strunzone(field); field = string_null; }, \
16 /* also initialize to the default value of func when requesting cvars */ \
17 string s = func(field); \
24 #define REPLICATE_float(fld, var, func) REPLICATE_7(fld, float, var, func, { field = stof(it); }, , )
25 #define REPLICATE_bool(fld, var, func) REPLICATE_7(fld, bool, var, func, { field = boolean(stoi(it)); }, , )
26 #define REPLICATE_int(fld, var, func) REPLICATE_7(fld, int, var, func, { field = stoi(it); }, , )
29 #define REPLICATE_7(fld, type, var, func, create, destroy, after) \
30 void ReplicateVars(entity this, string thisname, int i) \
32 type field = this.fld; \
33 if (i < 0) { destroy } \
36 string it = func(argv(i + 1)); \
37 bool current = thisname == var; \
40 if (current) { create } \
44 stuffcmd(this, "cl_cmd sendcvar " var "\n"); \
46 if (current) { after } \
52 #define REPLICATE_7(fld, type, var, func, create, destroy, after)