From a78d08d4ca175c9f7844aa1df782db9457cdc593 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sun, 12 Jul 2015 18:51:14 +0200 Subject: [PATCH] cleanup additional ray shortening (no longer necessary, since the actual shortening now works) --- source/src/bot/bot_util.h | 10 +++++++++- source/src/protos.h | 7 ------- source/src/weapon.cpp | 22 +++++++++------------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/source/src/bot/bot_util.h b/source/src/bot/bot_util.h index e1be0b83..44035c20 100644 --- a/source/src/bot/bot_util.h +++ b/source/src/bot/bot_util.h @@ -1,6 +1,13 @@ #ifndef BOT_UTIL_H #define BOT_UTIL_H +// Structure for storing traceresults +struct traceresult_s +{ + vec end; + bool collided; +}; + long RandomLong(long from, long to); float RandomFloat(float from, float to); void lsrand(unsigned long initial_seed); @@ -8,7 +15,8 @@ void lsrand(unsigned long initial_seed); void AnglesToVectors(vec angles, vec &forward, vec &right, vec &up); float WrapXAngle(float angle); float WrapYZAngle(float angle); - +void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, + bool SkipTags=false); float GetDistance(vec v1, vec v2); float Get2DDistance(vec v1, vec v2); bool IsVisible(vec v1, vec v2, dynent *tracer = NULL, bool SkipTags=false); diff --git a/source/src/protos.h b/source/src/protos.h index f4ff1318..44a7daae 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -776,13 +776,6 @@ extern void setscope(bool activate); extern void setburst(bool activate); extern int intersect(playerent *d, const vec &from, const vec &to, vec *end = NULL); extern bool intersect(entity *e, const vec &from, const vec &to, vec *end = NULL); -// Structure for storing traceresults -struct traceresult_s -{ - vec end; - bool collided; -}; -void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult_s *tr, bool SkipTags=false); extern void damageeffect(int damage, playerent *d); extern void tryreload(playerent *p); extern void checkweaponstate(); diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index ba508bc5..dcb9f797 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -1280,14 +1280,12 @@ bool gun::attack(vec &targ) void gun::attackfx(const vec &from, const vec &to, int millis) { - traceresult_s tr; - TraceLine(from, to, owner, true, &tr); - if(from != tr.end) + if(from.squareddist(to) > 0.07f) { - addbullethole(owner, from, tr.end); - addshotline(owner, from, tr.end); + addbullethole(owner, from, to); + addshotline(owner, from, to); } - particle_splash(PART_SPARK, 5, 250, tr.end); + particle_splash(PART_SPARK, 5, 250, to); adddynlight(owner, from, 4, 100, 50, 96, 80, 64); attacksound(); } @@ -1338,15 +1336,13 @@ sniperrifle::sniperrifle(playerent *owner) : gun(owner, GUN_SNIPER), scoped(fals void sniperrifle::attackfx(const vec &from, const vec &to, int millis) { - traceresult_s tr; - TraceLine(from, to, owner, true, &tr); - if(from != tr.end) + if(from.squareddist(to) > 0.07f) { - addbullethole(owner, from, tr.end); - addshotline(owner, from, tr.end); - particle_trail(PART_SMOKE, 500, from, tr.end); + addbullethole(owner, from, to); + addshotline(owner, from, to); + particle_trail(PART_SMOKE, 500, from, to); } - particle_splash(PART_SPARK, 50, 200, tr.end); + particle_splash(PART_SPARK, 50, 200, to); adddynlight(owner, from, 4, 100, 50, 96, 80, 64); attacksound(); }