X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Faccuracy.qc;h=8005506179bbae8ae813bfbe14fd819f5ed488e6;hb=ea7a3b717331f01a459bf8e19a6ae259987a8fe2;hp=337ae54a98c86d4b889bb03da4b1cac0439116ee;hpb=e485bcaeede5f929c1ceefa26a51da840c2f1a1e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/accuracy.qc b/qcsrc/server/weapons/accuracy.qc index 337ae54a9..800550617 100644 --- a/qcsrc/server/weapons/accuracy.qc +++ b/qcsrc/server/weapons/accuracy.qc @@ -25,6 +25,12 @@ bool accuracy_send(entity this, entity to, int sf) entity a = this.owner; if (IS_SPEC(a)) a = a.enemy; a = CS(a).accuracy; + + // z411 send entity number + if(g_duel) + WriteByte(MSG_ENTITY, etof(a.owner)); + else + WriteByte(MSG_ENTITY, 0); if (to != a.owner) if (!autocvar_sv_accuracy_data_share && !CS_CVAR(a.owner).cvar_cl_accuracy_data_share) @@ -32,10 +38,20 @@ bool accuracy_send(entity this, entity to, int sf) // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy! WriteInt24_t(MSG_ENTITY, sf); if (sf == 0) return true; + // note: we know that client and server agree about SendFlags... int f = 1; for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) { - if (sf & f) WriteByte(MSG_ENTITY, accuracy_byte(a.accuracy_hit[w], a.accuracy_fired[w])); + if (sf & f) { + if(g_duel) { + WriteByte(MSG_ENTITY, a.accuracy_frags[w]); + WriteShort(MSG_ENTITY, a.accuracy_hit[w]); + WriteShort(MSG_ENTITY, a.accuracy_cnt_hit[w]); + WriteShort(MSG_ENTITY, a.accuracy_cnt_fired[w]); + } else { + WriteByte(MSG_ENTITY, accuracy_byte(a.accuracy_hit[w], a.accuracy_fired[w])); + } + } f = (f == 0x800000) ? 1 : f * 2; } return true; @@ -45,14 +61,17 @@ bool accuracy_send(entity this, entity to, int sf) void accuracy_init(entity e) { entity a = CS(e).accuracy = new_pure(accuracy); + e.roundaccuracy = new_pure(accuracy); a.owner = e; - a.drawonlytoclient = e; + if(!g_duel) // z411 + a.drawonlytoclient = e; Net_LinkEntity(a, false, 0, accuracy_send); } void accuracy_free(entity e) { delete(CS(e).accuracy); + delete(e.roundaccuracy); } void accuracy_reset(entity e) @@ -80,33 +99,58 @@ void accuracy_resend(entity e) //.float hit_time; .float fired_time; +void roundaccuracy_clear(entity this) +{ + if (IS_INDEPENDENT_PLAYER(this)) return; + entity ra = this.roundaccuracy; + + for (int w = 0; w <= WEP_LAST - WEP_FIRST; ++w) { + ra.accuracy_frags[w] = 0; + ra.accuracy_hit[w] = 0; + ra.accuracy_fired[w] = 0; + ra.accuracy_cnt_hit[w] = 0; + ra.accuracy_cnt_fired[w] = 0; + } +} + void accuracy_add(entity this, Weapon w, float fired, float hit) { if (IS_INDEPENDENT_PLAYER(this)) return; entity a = CS(this).accuracy; + entity ra = this.roundaccuracy; if (!a) return; if (!hit && !fired) return; if (w == WEP_Null) return; int wepid = w.m_id; wepid -= WEP_FIRST; int b = accuracy_byte(a.accuracy_hit[wepid], a.accuracy_fired[wepid]); - if (hit) a.accuracy_hit [wepid] += hit; - if (fired) a.accuracy_fired[wepid] += fired; + if (hit) { + a.accuracy_hit[wepid] += hit; + ra.accuracy_hit[wepid] += hit; + } + if (fired) { + a.accuracy_fired[wepid] += fired; + ra.accuracy_fired[wepid] += fired; + } if (hit && STAT(HIT_TIME, a) != time) { // only run this once per frame a.accuracy_cnt_hit[wepid] += 1; + ra.accuracy_cnt_hit[wepid] += 1; STAT(HIT_TIME, a) = time; } if (fired && a.fired_time != time) { // only run this once per frame a.accuracy_cnt_fired[wepid] += 1; + ra.accuracy_cnt_fired[wepid] += 1; a.fired_time = time; } - if (b == accuracy_byte(a.accuracy_hit[wepid], a.accuracy_fired[wepid])) return; // no change + if (!g_duel && b == accuracy_byte(a.accuracy_hit[wepid], a.accuracy_fired[wepid])) return; // no change int sf = 1 << (wepid % 24); a.SendFlags |= sf; - FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, { CS(it).accuracy.SendFlags |= sf; }); + + if(!g_duel) + FOREACH_CLIENT(IS_SPEC(it) && it.enemy == this, { CS(it).accuracy.SendFlags |= sf; }); } bool accuracy_isgooddamage(entity attacker, entity targ)