X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fhitplot.qc;h=fb13bd1b9e126201de97ef73bf439f4119a6a97e;hb=a9c2426d7cc2e1f42f0e7469f95efffa29957293;hp=9846443647a921fa99e3effbc1cf669383c1be42;hpb=678a61b45f332fcd560083b01e6b0bf5a5ae268c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/hitplot.qc b/qcsrc/server/weapons/hitplot.qc index 984644364..fb13bd1b9 100644 --- a/qcsrc/server/weapons/hitplot.qc +++ b/qcsrc/server/weapons/hitplot.qc @@ -1,8 +1,12 @@ #include "hitplot.qh" +#include +#include #include "../antilag.qh" #include "../g_subs.qh" -#include "../../common/weapons/all.qh" +#include +#include +#include vector W_HitPlotUnnormalizedUntransform(vector screenforward, vector screenright, vector screenup, vector v) { @@ -50,28 +54,25 @@ vector W_HitPlotNormalizedUntransform(vector org, entity targ, vector screenforw return ret; } -void W_HitPlotAnalysis(entity player, vector screenforward, vector screenright, vector screenup) +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; - traceline_antilag_force(player, org, org + screenforward * MAX_SHOT_DISTANCE, MOVE_NORMAL, player, lag); + 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)) { - antilag_takeback(trace_ent, time - lag); - hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos); - antilag_restore(trace_ent); - fputs(player.hitplotfh, strcat(ftos(hitplot.x), " ", ftos(hitplot.y), " ", ftos(hitplot.z), " ", ftos(PS(player).m_switchweapon.m_id), "\n")); + entity store = IS_CLIENT(trace_ent) ? CS(trace_ent) : trace_ent; + antilag_takeback(trace_ent, store, time - lag); + vector hitplot = W_HitPlotNormalizedUntransform(org, trace_ent, screenforward, screenright, screenup, trace_endpos); + antilag_restore(trace_ent, store); + 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")); } } @@ -81,17 +82,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 ", player.netname, "\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; } }