From da898acce3a98f4d382f0beaabf7e4b949c8712e Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 16 Jul 2017 00:24:39 +1000 Subject: [PATCH] Port parm_idlesince to ClientState --- qcsrc/ecs/systems/sv_physics.qc | 8 ++++---- qcsrc/server/client.qc | 14 +++++++------- qcsrc/server/client.qh | 2 ++ qcsrc/server/defs.qh | 1 - 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc index 9e46dcfc5..20cd53144 100644 --- a/qcsrc/ecs/systems/sv_physics.qc +++ b/qcsrc/ecs/systems/sv_physics.qc @@ -11,11 +11,11 @@ void sys_phys_fix(entity this, float dt) bool sys_phys_override(entity this, float dt) { int buttons = PHYS_INPUT_BUTTON_MASK(this); - float idlesince = this.parm_idlesince; - this.parm_idlesince = time; // in the case that physics are overridden + float idlesince = CS(this).parm_idlesince; + CS(this).parm_idlesince = time; // in the case that physics are overridden if (PM_check_specialcommand(this, buttons)) { return true; } if (this.PlayerPhysplug && this.PlayerPhysplug(this, dt)) { return true; } - this.parm_idlesince = idlesince; + CS(this).parm_idlesince = idlesince; return false; } @@ -26,7 +26,7 @@ void sys_phys_monitor(entity this, float dt) if (sv_maxidle > 0) { if (buttons != this.buttons_old || this.movement != this.movement_old - || this.v_angle != this.v_angle_old) { this.parm_idlesince = time; } + || this.v_angle != this.v_angle_old) { CS(this).parm_idlesince = time; } } PM_check_nickspam(this); PM_check_punch(this, dt); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 3d83a99d2..bbfe2eacd 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -821,7 +821,7 @@ SetChangeParms void SetChangeParms (entity this) { // save parms for level change - parm1 = this.parm_idlesince - time; + parm1 = CS(this).parm_idlesince - time; MUTATOR_CALLHOOK(SetChangeParms); } @@ -834,12 +834,12 @@ DecodeLevelParms void DecodeLevelParms(entity this) { // load parms - this.parm_idlesince = parm1; - if (this.parm_idlesince == -(86400 * 366)) - this.parm_idlesince = time; + CS(this).parm_idlesince = parm1; + if (CS(this).parm_idlesince == -(86400 * 366)) + CS(this).parm_idlesince = time; // whatever happens, allow 60 seconds of idling directly after connect for map loading - this.parm_idlesince = max(this.parm_idlesince, time - sv_maxidle + 60); + CS(this).parm_idlesince = max(CS(this).parm_idlesince, time - sv_maxidle + 60); MUTATOR_CALLHOOK(DecodeLevelParms); } @@ -2672,7 +2672,7 @@ void PlayerPostThink (entity this) if (sv_maxidle_slots > 0 && (maxclients - totalClients) > sv_maxidle_slots) { /* do nothing */ } - else if (time - this.parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10 + else if (time - CS(this).parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10 { if (this.idlekick_lasttimeleft) { @@ -2682,7 +2682,7 @@ void PlayerPostThink (entity this) } else { - float timeleft = ceil(sv_maxidle - (time - this.parm_idlesince)); + float timeleft = ceil(sv_maxidle - (time - CS(this).parm_idlesince)); if (timeleft == min(10, sv_maxidle - 1)) { // - 1 to support sv_maxidle <= 10 if (!this.idlekick_lasttimeleft) Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_DISCONNECT_IDLING, timeleft); diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 37e5eeb94..c63d26190 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -33,6 +33,8 @@ CLASS(Client, Object) ATTRIB(Client, playerid, int, this.playerid); + ATTRIB(Client, parm_idlesince, int, this.parm_idlesince); + METHOD(Client, m_unwind, bool(Client this)); STATIC_METHOD(Client, Add, void(Client this, int _team)); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index a6ca911bd..7a155fddd 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -232,7 +232,6 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d float lockteams; -.float parm_idlesince; float sv_maxidle; float sv_maxidle_spectatorsareidle; int sv_maxidle_slots; -- 2.39.2