From 50ad2c94eefa8226b5568d89859651bb7ee75c88 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 12 Jul 2003 16:50:07 +0000 Subject: [PATCH] fix a bunch of things that should have been checking if the model (usually cl.worldmodel) was not NULL before calling its functions git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3261 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_main.c | 3 ++- cl_particles.c | 3 +++ gl_rsurf.c | 2 +- r_lerpanim.c | 2 +- r_light.c | 6 +++--- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cl_main.c b/cl_main.c index 7dfb971f..820d6253 100644 --- a/cl_main.c +++ b/cl_main.c @@ -452,7 +452,8 @@ dlightsetup: //Con_Printf("dlight %i : %f %f %f : %f %f %f\n", i, org[0], org[1], org[2], red * radius, green * radius, blue * radius); memset (dl, 0, sizeof(*dl)); dl->ent = ent; - cl.worldmodel->FindNonSolidLocation(cl.worldmodel, org, dl->origin, 6); + if (cl.worldmodel) + cl.worldmodel->FindNonSolidLocation(cl.worldmodel, org, dl->origin, 6); //VectorCopy(org, dl->origin); dl->radius = radius; dl->color[0] = red; diff --git a/cl_particles.c b/cl_particles.c index c25a3b4b..da6be2fa 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -458,6 +458,9 @@ void CL_ReadPointFile_f (void) char *pointfile = NULL, *pointfilepos, *t, tchar; char name[MAX_OSPATH]; + if (!cl.worldmodel) + return; + FS_StripExtension(cl.worldmodel->name, name); strcat(name, ".pts"); #if WORKINGLQUAKE diff --git a/gl_rsurf.c b/gl_rsurf.c index 51be852c..35b582a5 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1764,7 +1764,7 @@ void R_WorldVisibility (entity_render_t *ent) mleaf_t *viewleaf; Matrix4x4_Transform(&ent->inversematrix, r_origin, modelorg); - viewleaf = ent->model->PointInLeaf(ent->model, modelorg); + viewleaf = ent->model ? ent->model->PointInLeaf(ent->model, modelorg) : NULL; R_PVSUpdate(ent, viewleaf); if (!viewleaf) diff --git a/r_lerpanim.c b/r_lerpanim.c index 91b55bff..0a91e813 100644 --- a/r_lerpanim.c +++ b/r_lerpanim.c @@ -11,7 +11,7 @@ void R_LerpAnimation(entity_render_t *r) animscene_t *scene; frameblend_t *blend; - if (!r->model) + if (!r->model || !r->model->type) return; blend = r->frameblend; diff --git a/r_light.c b/r_light.c index 7da1daa0..2e5067da 100644 --- a/r_light.c +++ b/r_light.c @@ -298,7 +298,7 @@ static void R_VisMarkLights (entity_render_t *ent, rdlight_t *rd, int bit, int b int row; float low[3], high[3], dist, maxdist; - if (!r_dynamic.integer) + if (!r_dynamic.integer || !ent->model) return; Matrix4x4_Transform(&ent->inversematrix, rd->origin, lightorigin); @@ -579,7 +579,7 @@ void R_CompleteLightPoint (vec3_t color, const vec3_t p, int dynamic, const mlea float f; rdlight_t *rd; mlight_t *sl; - if (leaf == NULL) + if (leaf == NULL && cl.worldmodel != NULL) leaf = cl.worldmodel->PointInLeaf(cl.worldmodel, p); if (!leaf || leaf->contents == CONTENTS_SOLID || r_fullbright.integer || !cl.worldmodel->lightdata) { @@ -681,7 +681,7 @@ int R_LightModel(float *ambient4f, const entity_render_t *ent, float colorr, flo ambient4f[3] = colora; return false; } - leaf = cl.worldmodel->PointInLeaf(cl.worldmodel, ent->origin); + leaf = cl.worldmodel ? cl.worldmodel->PointInLeaf(cl.worldmodel, ent->origin) : NULL; if (!leaf || leaf->contents == CONTENTS_SOLID || !cl.worldmodel->lightdata) ambient4f[0] = ambient4f[1] = ambient4f[2] = 1; else -- 2.39.2