.int cvar_value;
void ReplicateVars(bool would_destroy)
{
- FOREACH(Notifications, it.nent_type == MSG_CHOICE, {
- string cvarname = sprintf("notification_%s", Get_Notif_CvarName(it));
- REPLICATE_SIMPLE(it.cvar_value, cvarname);
- });
+ if (!would_destroy)
+ FOREACH(Notifications, it.nent_type == MSG_CHOICE, {
+ string cvarname = sprintf("notification_%s", Get_Notif_CvarName(it));
+ // NOTE: REPLICATE_SIMPLE can return;
+ REPLICATE_SIMPLE(it.cvar_value, cvarname);
+ });
}
float bgmtime;
float prev_myteam;
int lasthud;
float vh_notice_time;
-float ReplicateVars_time;
void CSQC_UpdateView(entity this, float w, float h)
{
TC(int, w); TC(int, h);
// TODO remove references to sendcvar from cvar descriptions
// TODO stop server from requesting cvar values to the client on connection as it's no longer necessary
- if (time > ReplicateVars_time) // prevents network spam
- {
- ReplicateVars(false);
- ReplicateVars_time = time + 0.8 + random() * 0.4;
- }
+ ReplicateVars(false);
+ if (ReplicateVars_NOT_SENDING())
+ ReplicateVars_DELAY(0.8 + random() * 0.4); // no need to check cvars every frame
HUD_Scale_Disable();
store.fld = field; \
}
#elif defined(CSQC)
+ float ReplicateVars_time;
+ #define ReplicateVars_NOT_SENDING() (time > ReplicateVars_time)
+ #define ReplicateVars_DELAY(t) ReplicateVars_time = time + t
+ #define ReplicateVars_DELAY_1FRAME() ReplicateVars_time = time
#define REPLICATE_string(fld, var, func) REPLICATE_7(fld, float, var, func, (fld != cvar_string(var)), { strcpy(fld, cvar_string(var)); }, { strfree(fld); })
#define REPLICATE_float(fld, var, func) REPLICATE_7(fld, float, var, func, (fld != cvar(var)), { fld = cvar(var); }, )
#define REPLICATE_bool(fld, var, func) REPLICATE_7(fld, bool, var, func, (fld != cvar(var)), { fld = cvar(var); }, )
void ReplicateVars(bool would_destroy) \
{ \
if (would_destroy > 0) { destroy } \
- else if (check) \
+ else if (ReplicateVars_NOT_SENDING() && check) \
{ \
localcmd(strcat("cl_cmd sendcvar ", var, "\n")); \
+ ReplicateVars_DELAY_1FRAME(); \
update \
+ return; \
} \
}
#define REPLICATE_SIMPLE(field, cvarname) MACRO_BEGIN \
- if (field != cvar(cvarname)) \
+ if (ReplicateVars_NOT_SENDING() && field != cvar(cvarname)) \
{ \
localcmd(strcat("cl_cmd sendcvar ", cvarname, "\n")); \
+ ReplicateVars_DELAY_1FRAME(); \
field = cvar(cvarname); \
+ return; \
} \
MACRO_END
#endif