From 901b35d4b1089bd0a8b64d09e27d2f11f57d5925 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 27 Jan 2024 17:31:34 +0300 Subject: [PATCH] ref: soft: rework @SNMetamorph's fix for avoiding crash when no world is set (like Customize menu with enabled 3D view) --- ref/soft/r_light.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ref/soft/r_light.c b/ref/soft/r_light.c index e026c959..6d5b3f65 100644 --- a/ref/soft/r_light.c +++ b/ref/soft/r_light.c @@ -156,8 +156,12 @@ void R_PushDlights( void ) tr.dlightframecount = tr.framecount; RI.currententity = CL_GetEntityByIndex( 0 ); - if( RI.currententity ) - RI.currentmodel = RI.currententity->model; + + // no world -- no dlights + if( !RI.currententity ) + return; + + RI.currentmodel = RI.currententity->model; for( i = 0; i < MAX_DLIGHTS; i++, l++ ) { @@ -169,8 +173,7 @@ void R_PushDlights( void ) //if( GL_FrustumCullSphere( &RI.frustum, l->origin, l->radius, 15 )) //continue; - if( RI.currententity ) - R_MarkLights( l, 1<nodes ); + R_MarkLights( l, 1<nodes ); } }