shithub: qk2

Download patch

ref: bf70626bc39f4e2cf8e318423de5eeaeeaa79af5
parent: f17137ef1990270b3f6b46845e8c8ec80644f288
author: qwx <[email protected]>
date: Fri Aug 6 20:22:07 EDT 2021

fix crash with warped surfaces

there are weird assumptions all over the place, but
no idea why this is done that way.
R_PolygonScanLeftEdge can process less spans than
R_PolygonScanRightEdge which then works on
uninitialized data and outputs garbage, but this
somehow is necessary for these surfaces to render.
this might still be a point of failure.

--- a/r_poly.c
+++ b/r_poly.c
@@ -591,7 +591,7 @@
 
 	do
 	{
-		s_spanletvars.pdest   = (byte *)d_viewbuffer + ( d_scantable[pspan->v] /*r_screenwidth * pspan->v*/) + pspan->u;
+		s_spanletvars.pdest   = (byte *)d_viewbuffer + r_screenwidth * pspan->v + pspan->u;
 		s_spanletvars.pz      = d_pzbuffer + (d_zwidth * abs(pspan->v)) + pspan->u;
 		s_spanletvars.u       = pspan->u;
 		s_spanletvars.v       = pspan->v;