Fix lighting origins on CSQC entities.
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 Apr 2018 21:59:24 +0000 (21:59 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 30 Apr 2018 21:59:24 +0000 (21:59 +0000)
Fix a couple crashes with showtex 1 on level change where prog is not fully initialized.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12409 d7cf8633-e32d-0410-b094-e92efae38249

csprogs.c
world.c

index 6c2d1ef..68dbd83 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -349,8 +349,8 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
 
        // LadyHavoc: use the CL_GetTagMatrix function on self to ensure consistent behavior (duplicate code would be bad)
        // this also sets the custommodellight_origin for us
-       VectorCopy(modellight_origin, entrender->custommodellight_origin);
        CL_GetTagMatrix(prog, &entrender->matrix, ed, 0, modellight_origin);
+       VectorCopy(modellight_origin, entrender->custommodellight_origin);
 
        // set up the animation data
        VM_GenerateFrameGroupBlend(prog, ed->priv.server->framegroupblend, ed);
diff --git a/world.c b/world.c
index 60bd093..c62a83f 100644 (file)
--- a/world.c
+++ b/world.c
@@ -185,6 +185,10 @@ int World_EntitiesInBox(world_t *world, const vec3_t requestmins, const vec3_t r
        vec3_t paddedmins, paddedmaxs;
        int igrid[3], igridmins[3], igridmaxs[3];
 
+       // avoid crash in showtex code on level change
+       if (prog == NULL || prog->num_edicts < 1)
+               return 0;
+
        // LordHavoc: discovered this actually causes its own bugs (dm6 teleporters being too close to info_teleport_destination)
        //VectorSet(paddedmins, requestmins[0] - 1.0f, requestmins[1] - 1.0f, requestmins[2] - 1.0f);
        //VectorSet(paddedmaxs, requestmaxs[0] + 1.0f, requestmaxs[1] + 1.0f, requestmaxs[2] + 1.0f);