ReplicateVars API improvements
Premise:
With REPLICATE you can sync the value of a cvar with the server (value is sent on connection and everytime the user changes it) for cvars that need to be sent to the server to take effect, e.g. cl_gunalign.
This patch improves ReplicateVars API, if a replicated cvar needs special handling on the server on cvar change there's no longer a need to patch GetCvars or define the mutator hook GetCvars, it can be entirely defined in an user file using ReplicateVars API.
-
REPLICATE
now accepts a server-side function name as 4th parameter meant to handle cvar value in a different format. In master this function can be set only by calling GetCvars_handleString_Fixup inside GetCvars.- e.g.
REPLICATE(cvar_cl_weaponpriority, string, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
- e.g.
- Introduce
REPLICATE_APPLYCHANGE
that allows setting extra server-side code that is executed on cvar change. In master this code can be defined only inside GetCvars.- e.g.
REPLICATE_APPLYCHANGE("cl_allow_uidtracking", { PlayerStats_GameReport_AddPlayer(this); });
- e.g.
- Introduce
REPLICATE_INIT
that initializes replicated cvar on both client and server. It just creates a global in the client and a field in the server. - Move many replicated cvar definitions out of
qcsrc\common\replicate.qh
to files that use them.
Extra change:
- Remove unused cvar_cl_newusekeysupported field
Edited by terencehill