shithub: qk1

Download patch

ref: a4c94ff0a55c99b2bf3aab13bcea037b76ab43f2
parent: ba6ad8ddabdf363f0053ce859d59b6ff097d880d
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Nov 7 21:04:33 EST 2023

draw: make sure to not underflow

--- a/r_main.c
+++ b/r_main.c
@@ -751,10 +751,12 @@
 	r_drawflags = DRAW_BLEND;
 	R_EdgeDrawing();
 	// FIXME(sigrid): these need to be sorted and drawn back to front
-	for(i = cl_numvisedicts, e = ent_reject; e != nil; e = e->last_reject)
-		cl_visedicts[--i] = e;
-	for(; i < cl_numvisedicts; i++)
-		R_DrawEntity(cl_visedicts[i]);
+	if(cl_numvisedicts > 0){
+		for(i = cl_numvisedicts, e = ent_reject; e != nil && i > 0; e = e->last_reject)
+			cl_visedicts[--i] = e;
+		for(; i < cl_numvisedicts; i++)
+			R_DrawEntity(cl_visedicts[i]);
+	}
 	r_drawflags = 0;
 
 	if (r_dowarp)