From: Mario Date: Tue, 18 Jul 2017 02:30:34 +0000 (+1000) Subject: Port hitplotfh to ClientState X-Git-Tag: xonotic-v0.8.5~2568 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3d47a9ae2ec4ef14fe43ddbeade11798c4e5c6dc;p=xonotic%2Fxonotic-data.pk3dir.git Port hitplotfh to ClientState --- diff --git a/qcsrc/common/state.qc b/qcsrc/common/state.qc index cbf9eff72..7013cff1c 100644 --- a/qcsrc/common/state.qc +++ b/qcsrc/common/state.qc @@ -71,6 +71,7 @@ void ClientState_detach(entity this) { accuracy_free(this); // TODO: needs to be before CS() is deleted! PlayerScore_Detach(this); // what ^they^ said + W_HitPlotClose(this); delete(CS(this)); this._cs = NULL; @@ -78,7 +79,6 @@ void ClientState_detach(entity this) bot_clientdisconnect(this); - W_HitPlotClose(this); anticheat_report_to_eventlog(this); playerdemo_shutdown(this); entcs_detach(this); diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 88614214c..0c3eddfeb 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -105,6 +105,7 @@ CLASS(Client, Object) ATTRIB(Client, hasweapon_complain_spam, float, this.hasweapon_complain_spam); ATTRIB(Client, scorekeeper, entity, this.scorekeeper); ATTRIB(Client, specialcommand_pos, int, this.specialcommand_pos); + ATTRIB(Client, hitplotfh, int, this.hitplotfh); METHOD(Client, m_unwind, bool(Client this)); diff --git a/qcsrc/server/weapons/hitplot.qc b/qcsrc/server/weapons/hitplot.qc index 2a0fad7de..89cec6aea 100644 --- a/qcsrc/server/weapons/hitplot.qc +++ b/qcsrc/server/weapons/hitplot.qc @@ -54,27 +54,23 @@ vector W_HitPlotNormalizedUntransform(vector org, entity targ, vector screenforw void W_HitPlotAnalysis(entity player, .entity weaponentity, vector screenforward, vector screenright, vector screenup) { - vector hitplot; - vector org; - float lag; - - if(player.hitplotfh >= 0) + if(CS(player).hitplotfh >= 0) { - lag = ANTILAG_LATENCY(player); + float lag = ANTILAG_LATENCY(player); if(lag < 0.001) lag = 0; if(!IS_REAL_CLIENT(player)) lag = 0; // only antilag for clients - org = player.origin + player.view_ofs; + vector org = player.origin + player.view_ofs; traceline_antilag_force(player, org, org + screenforward * max_shot_distance, MOVE_NORMAL, player, lag); if(IS_CLIENT(trace_ent) || IS_MONSTER(trace_ent)) { entity store = IS_CLIENT(trace_ent) ? CS(trace_ent) : trace_ent; antilag_takeback(trace_ent, store, time - lag); - hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos); + vector hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos); antilag_restore(trace_ent, store); - fputs(player.hitplotfh, strcat(ftos(hitplot.x), " ", ftos(hitplot.y), " ", ftos(hitplot.z), " ", ftos(player.(weaponentity).m_switchweapon.m_id), "\n")); + fputs(CS(player).hitplotfh, strcat(ftos(hitplot.x), " ", ftos(hitplot.y), " ", ftos(hitplot.z), " ", ftos(player.(weaponentity).m_switchweapon.m_id), "\n")); //print(strcat(ftos(hitplot_x), " ", ftos(hitplot_y), " ", ftos(hitplot_z), "\n")); } } @@ -84,17 +80,17 @@ void W_HitPlotOpen(entity player) { if(autocvar_g_hitplots || strhasword(autocvar_g_hitplots_individuals, player.netaddress)) { - player.hitplotfh = fopen(strcat("hits-", matchid, "-", player.netaddress, "-", ftos(player.playerid), ".plot"), FILE_WRITE); - fputs(player.hitplotfh, strcat("#name ", playername(player, false), "\n")); + CS(player).hitplotfh = fopen(strcat("hits-", matchid, "-", player.netaddress, "-", ftos(player.playerid), ".plot"), FILE_WRITE); + fputs(CS(player).hitplotfh, strcat("#name ", playername(player, false), "\n")); } - else { player.hitplotfh = -1; } + else { CS(player).hitplotfh = -1; } } void W_HitPlotClose(entity player) { - if(player.hitplotfh >= 0) + if(CS(player).hitplotfh >= 0) { - fclose(player.hitplotfh); - player.hitplotfh = -1; + fclose(CS(player).hitplotfh); + CS(player).hitplotfh = -1; } }