REPLICATE_FIELD(float, cvar_cl_autotaunt);
REPLICATE_FIELD(bool, cvar_cl_clippedspectating);
REPLICATE_FIELD(bool, cvar_cl_cts_noautoswitch);
-REPLICATE_FIELD(int, cvar_cl_gunalign);
REPLICATE_FIELD(float, cvar_cl_handicap);
REPLICATE_FIELD(bool, cvar_cl_jetpack_jump);
REPLICATE_FIELD(bool, cvar_cl_movement_track_canjump);
REPLICATE(cvar_cl_allow_uid2name, int, "cl_allow_uid2name");
REPLICATE(cvar_cl_allow_uidranking, bool, "cl_allow_uidranking");
REPLICATE(cvar_cl_allow_uidtracking, int, "cl_allow_uidtracking");
+#ifdef SVQC
+REPLICATE_APPLYCHANGE("cl_allow_uidtracking", { PlayerStats_GameReport_AddPlayer(this); });
+#endif
REPLICATE(cvar_cl_autoscreenshot, int, "cl_autoscreenshot");
REPLICATE(cvar_cl_autotaunt, float, "cl_autotaunt");
REPLICATE(cvar_cl_clippedspectating, bool, "cl_clippedspectating");
REPLICATE(cvar_cl_cts_noautoswitch, bool, "cl_cts_noautoswitch");
-REPLICATE(cvar_cl_gunalign, int, "cl_gunalign");
REPLICATE(cvar_cl_handicap, float, "cl_handicap");
REPLICATE(cvar_cl_jetpack_jump, bool, "cl_jetpack_jump");
REPLICATE(cvar_cl_movement_track_canjump, bool, "cl_movement_track_canjump");
string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
#endif
+REPLICATE_FIELD(int, cvar_cl_gunalign);
+REPLICATE(cvar_cl_gunalign, int, "cl_gunalign");
+
REPLICATE_FIELD(string, cvar_cl_weaponpriority);
REPLICATE_FIELD(string, cvar_cl_weaponpriorities[10]);
REPLICATE(cvar_cl_weaponpriority, string, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
#ifdef GAMEQC
/**
+ * \def REPLICATE(fld, type, cvar)
* Replicate a client cvar into a server field
*
* @param fld The field to replicate into
* @param type The field type
- * @param cvar The cvar name
+ * @param cvarname
+ * @param fixup_func((entity this, string original_value)) optional parameter
*/
#define REPLICATE(...) EVAL_REPLICATE(OVERLOAD(REPLICATE, __VA_ARGS__))
#define EVAL_REPLICATE(...) __VA_ARGS__
#if defined(SVQC)
ACCUMULATE void ReplicateVars(entity this, entity store, string thisname, int i) {}
+ ACCUMULATE void ReplicateVars_ApplyChange(entity this, entity store, string thisname, int i) {}
+ /**
+ * \def REPLICATE(cvarname, ApplyChange_code)
+ * Allow setting code to will be executed on cvar value changes
+ *
+ * @param cvarname
+ * @param ApplyChange_code code meant to be run on cvar value changes
+ */
+ #define REPLICATE_APPLYCHANGE(var, ApplyChange_code) \
+ void ReplicateVars_ApplyChange(entity this, entity store, string thisname, int i) \
+ { if (thisname == var) { ApplyChange_code } }
#elif defined(CSQC)
ACCUMULATE void ReplicateVars(int mode) {}
#endif
Notification_GetCvars(this, store);
ReplicateVars(this, store, s, f);
-
- // fixup of switchweapon (needed for LMS or when spectating is disabled, as PutClientInServer comes too early)
if (f > 0)
- {
- if (s == "cl_weaponpriority")
- {
- for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
- {
- .entity weaponentity = weaponentities[slot];
- if (this.(weaponentity) && (this.(weaponentity).m_weapon != WEP_Null || slot == 0))
- this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
- }
- }
- if (s == "cl_allow_uidtracking")
- PlayerStats_GameReport_AddPlayer(this);
- //if (s == "cl_gunalign")
- //W_ResetGunAlign(this, store.cvar_cl_gunalign);
- }
+ ReplicateVars_ApplyChange(this, store, s, f);
}
// previously used if exists and has ammo, (second) best otherwise
void W_LastWeapon(entity this, .entity weaponentity);
+
+// fix switchweapon (needed when spectating is disabled, as PutClientInServer comes too early)
+REPLICATE_APPLYCHANGE("cl_weaponpriority",
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ if (this.(weaponentity) && (this.(weaponentity).m_weapon != WEP_Null || slot == 0))
+ this.(weaponentity).m_switchweapon = w_getbestweapon(this, weaponentity);
+ }
+);
void weapon_prepareattack_do(entity actor, .entity weaponentity, float secondary, float attacktime);
void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void(Weapon thiswep, entity actor, .entity weaponentity, int fire) func);
+
+//REPLICATE_APPLYCHANGE("cl_gunalign", { W_ResetGunAlign(this, store.cvar_cl_gunalign); });