g_rogue_utils.cpp 980 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright (c) ZeniMax Media Inc.
  2. // Licensed under the GNU General Public License 2.0.
  3. #include "../g_local.h"
  4. /*
  5. =================
  6. findradius2
  7. Returns entities that have origins within a spherical area
  8. ROGUE - tweaks for performance for tesla specific code
  9. only returns entities that can be damaged
  10. only returns entities that are FL_DAMAGEABLE
  11. findradius2 (origin, radius)
  12. =================
  13. */
  14. edict_t *findradius2(edict_t *from, const vec3_t &org, float rad)
  15. {
  16. // rad must be positive
  17. vec3_t eorg;
  18. int j;
  19. if (!from)
  20. from = g_edicts;
  21. else
  22. from++;
  23. for (; from < &g_edicts[globals.num_edicts]; from++)
  24. {
  25. if (!from->inuse)
  26. continue;
  27. if (from->solid == SOLID_NOT)
  28. continue;
  29. if (!from->takedamage)
  30. continue;
  31. if (!(from->flags & FL_DAMAGEABLE))
  32. continue;
  33. for (j = 0; j < 3; j++)
  34. eorg[j] = org[j] - (from->s.origin[j] + (from->mins[j] + from->maxs[j]) * 0.5f);
  35. if (eorg.length() > rad)
  36. continue;
  37. return from;
  38. }
  39. return nullptr;
  40. }