From 7af96fa3f500f70e1869316d201cdc4d31fbb75f Mon Sep 17 00:00:00 2001 From: havoc Date: Tue, 20 Feb 2007 12:32:03 +0000 Subject: [PATCH] fix some crashes related to particles when csqc is not active git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6879 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_collision.h | 2 +- cl_particles.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cl_collision.h b/cl_collision.h index f6837b7b..05176032 100644 --- a/cl_collision.h +++ b/cl_collision.h @@ -11,6 +11,6 @@ model_t *CL_GetModelFromEdict(prvm_edict_t *ed); void CL_LinkEdict(prvm_edict_t *ent); int CL_GenericHitSuperContentsMask(const prvm_edict_t *edict); trace_t CL_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict, int hitsupercontentsmask, qboolean hitnetworkbrushmodels, qboolean hitnetworkplayers, int *hitnetworkentity, qboolean hitcsqcentities); -#define CL_PointSuperContents(point) (CL_Move((point), vec3_origin, vec3_origin, (point), sv_gameplayfix_swiminbmodels.integer ? MOVE_NOMONSTERS : MOVE_WORLDONLY, NULL, 0, true, false, NULL, true).startsupercontents) +#define CL_PointSuperContents(point) (CL_Move((point), vec3_origin, vec3_origin, (point), sv_gameplayfix_swiminbmodels.integer ? MOVE_NOMONSTERS : MOVE_WORLDONLY, NULL, 0, true, false, NULL, false).startsupercontents) #endif diff --git a/cl_particles.c b/cl_particles.c index d658b7b6..1fd2c3f3 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -849,13 +849,18 @@ void CL_ParticleEffect_Fallback(int effectnameindex, float count, const vec3_t o VectorSubtract(originmaxs, originmins, dir); len = VectorNormalizeLength(dir); - dec = -ent->persistent.trail_time; - ent->persistent.trail_time += len; - if (ent->persistent.trail_time < 0.01f) - return; + if (ent) + { + dec = -ent->persistent.trail_time; + ent->persistent.trail_time += len; + if (ent->persistent.trail_time < 0.01f) + return; - // if we skip out, leave it reset - ent->persistent.trail_time = 0.0f; + // if we skip out, leave it reset + ent->persistent.trail_time = 0.0f; + } + else + dec = 0; // advance into this frame to reach the first puff location VectorMA(originmins, dec, dir, pos); @@ -1008,7 +1013,8 @@ void CL_ParticleEffect_Fallback(int effectnameindex, float count, const vec3_t o len -= dec; VectorMA (pos, dec, dir, pos); } - ent->persistent.trail_time = len; + if (ent) + ent->persistent.trail_time = len; } else if (developer.integer >= 1) Con_Printf("CL_ParticleEffect_Fallback: no fallback found for effect %s\n", particleeffectname[effectnameindex]); -- 2.39.2