From c11e10b6930fe154c0947c5a5ed7af6bebce69f5 Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 28 Jul 2005 00:42:26 +0000 Subject: [PATCH] Added full particle effect number range checking. This'll stop crashes with beams not registered in advance. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1165 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/r_part.c | 75 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/engine/client/r_part.c b/engine/client/r_part.c index 1bf1c240f..8175fdf02 100644 --- a/engine/client/r_part.c +++ b/engine/client/r_part.c @@ -1771,7 +1771,7 @@ int P_RunParticleEffectType (vec3_t org, vec3_t dir, float count, int typenum) beamseg_t *b, *bfirst; vec3_t ofsvec, arsvec; // offsetspread vec, areaspread vec - if (typenum < 0) + if (typenum < 0 || typenum >= numparticletypes) return 1; if (!ptype->loaded) @@ -2301,9 +2301,75 @@ void P_RunParticleEffect4 (vec3_t org, float radius, int color, int effect, int } } +void P_RunParticleCube(vec3_t minb, vec3_t maxb, vec3_t dir, float count, int colour, qboolean gravity, float jitter) +{ + vec3_t org; + int i, j; + vec3_t nvel; + float num; + float invcount; + int ptype = P_FindParticleType(va("te_cube%s_%i", gravity?"_g":"", colour)); + if (ptype < 0) + { + ptype = P_FindParticleType(va("te_cube%s", gravity?"_g":"")); + if (ptype < 0) + ptype = pe_default; + part_type[ptype].colorindex = colour; + } + invcount = 1/part_type[ptype].count; // using this to get R_RPET to always spawn 1 + count = count * part_type[ptype].count; + + for (i=0 ; i= numparticletypes) + return 1; //bad value + if (!ptype->loaded) return 1; @@ -2786,10 +2855,10 @@ qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal) if (pe->model) { hull = &pe->model->hulls[0]; - memset (&trace, 0, sizeof(trace)); VectorSubtract(start, pe->origin, ts); VectorSubtract(end, pe->origin, te); - if (!pe->model->funcs.Trace(pe->model, 0, 0, ts, te, vec3_origin, vec3_origin, &trace)) + pe->model->funcs.Trace(pe->model, 0, 0, ts, te, vec3_origin, vec3_origin, &trace); + if (trace.fraction) { VectorSubtract(trace.endpos, ts, delta); len = Length(delta);