From 9895f3b895b7f000df412fd4107acc40a9432a5f Mon Sep 17 00:00:00 2001 From: myT Date: Fri, 17 Jun 2022 03:26:36 +0200 Subject: [PATCH] fixed RB_RenderLitSurfList still crashing because of an invalid stage index the first attempt was f99c223495f8f83e876d2e98b3746df77b380734 this is really not a proper fix since I haven't solved how it gets to that stage but, knowing I will be deleting this whole part of the code soon enough anyway... --- code/renderer/tr_backend.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/renderer/tr_backend.cpp b/code/renderer/tr_backend.cpp index 5dd35af..7f7b6b4 100644 --- a/code/renderer/tr_backend.cpp +++ b/code/renderer/tr_backend.cpp @@ -419,13 +419,15 @@ static void RB_RenderLitSurfList( dlight_t* dl, qbool opaque ) if (!opaque && shader->sort <= SS_OPAQUE) continue; + const int stageIndex = shader->lightingStages[ST_DIFFUSE]; + if (stageIndex < 0 || stageIndex >= shader->numStages) + continue; + if (shaderPrev) RB_EndSurface(); RB_BeginSurface( shader, fogNum ); tess.greyscale = litSurf->greyscale; - // stage index is guaranteed valid by R_AddLitSurface - const int stageIndex = shader->lightingStages[ST_DIFFUSE]; const shaderStage_t* const stage = shader->stages[stageIndex]; backEnd.dlIntensity = (shader->contentFlags & liquidFlags) != 0 ? 0.5f : 1.0f; backEnd.dlStateBits =