shithub: qk1

Download patch

ref: 6dd66847bebc0aff09e8d74d60d096e925c6a9c9
parent: 944716cf2fa3ee9191f8619a0ee9eae33e5fdaef
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Nov 9 22:51:34 EST 2023

more garbage out

--- a/Makefile
+++ b/Makefile
@@ -35,7 +35,6 @@
 	d_sprite.o\
 	d_surf.o\
 	d_vars.o\
-	d_zpoint.o\
 	dotproduct.o\
 	draw.o\
 	fs.o\
--- a/d_edge.c
+++ b/d_edge.c
@@ -4,7 +4,6 @@
 
 float		scale_for_mip;
 int			ubasestep, errorterm, erroradjustup, erroradjustdown;
-int			vstartscan;
 
 // FIXME: should go away
 extern void			R_RotateBmodel (void);
--- a/d_iface.h
+++ b/d_iface.h
@@ -110,19 +110,17 @@
 
 
 void D_Aff8Patch (void *pcolormap);
-void D_PolysetDraw (void);
-void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts, byte alpha);
+void D_PolysetDraw (byte *colormap);
+void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts, byte *colormap, byte alpha);
 void D_DrawParticle (particle_t *pparticle);
 void D_DrawPoly (void);
 void D_DrawSprite (void);
 void D_DrawSurfaces (void);
-void D_DrawZPoint (void);
 void D_EndParticles (void);
 void D_Init (void);
 void D_ViewChanged (void);
 void D_SetupFrame (void);
 void D_StartParticles (void);
-void D_TurnZOn (void);
 void D_WarpScreen (void);
 
 void D_FillRect (vrect_t *vrect, int color);
--- a/d_modech.c
+++ b/d_modech.c
@@ -25,7 +25,6 @@
 	if (yscale > xscale)
 		scale_for_mip = yscale;
 
-	d_zrowbytes = vid.width * 2;
 	d_zwidth = vid.width;
 
 	d_pix_min = r_refdef.vrect.width / 320;
--- a/d_polyse.c
+++ b/d_polyse.c
@@ -74,7 +74,7 @@
 	int		remainder;
 } adivtab_t;
 
-static adivtab_t	adivtab[32*32] = {
+static const adivtab_t adivtab[32*32] = {
 #include "adivtab.h"
 };
 
@@ -82,9 +82,9 @@
 int		skinwidth;
 byte	*skinstart;
 
-void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage, byte alpha);
+void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage, byte *colormap, byte alpha);
 void D_PolysetCalcGradients (int skinwidth);
-void D_DrawSubdiv (void);
+void D_DrawSubdiv (byte *colormap);
 void D_DrawNonSubdiv (void);
 void D_PolysetRecursiveTriangle (int *p1, int *p2, int *p3, byte alpha);
 void D_PolysetSetEdgeTable (void);
@@ -96,7 +96,7 @@
 D_PolysetDraw
 ================
 */
-void D_PolysetDraw (void)
+void D_PolysetDraw (byte *colormap)
 {
 	static spanpackage_t	spans[DPS_MAXSPANS];
 	a_spans = spans;
@@ -103,7 +103,7 @@
 
 	if (r_affinetridesc.drawtype)
 	{
-		D_DrawSubdiv ();
+		D_DrawSubdiv (colormap);
 	}
 	else
 	{
@@ -117,7 +117,7 @@
 D_PolysetDrawFinalVerts
 ================
 */
-void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts, byte alpha)
+void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts, byte *colormap, byte alpha)
 {
 	int		i, z;
 	uzint	*zbuf;
@@ -135,13 +135,13 @@
 				if(r_drawflags & DRAW_BLEND){
 					int n = d_scantable[fv->v[1]] + fv->v[0];
 					int pix = skintable[fv->v[3]>>16][fv->v[2]>>16];
-					pix = ((byte *)acolormap)[pix + (fv->v[4] & 0xFF00) ];
+					pix = colormap[pix + (fv->v[4] & 0xFF00) ];
 					d_viewbuffer[n] = blendalpha(pix, d_viewbuffer[n], alpha);
 				}else{
 					int		pix;
 					*zbuf = z;
 					pix = skintable[fv->v[3]>>16][fv->v[2]>>16];
-					pix = ((byte *)acolormap)[pix + (fv->v[4] & 0xFF00) ];
+					pix = colormap[pix + (fv->v[4] & 0xFF00) ];
 					d_viewbuffer[d_scantable[fv->v[1]] + fv->v[0]] = pix;
 				}
 			}
@@ -155,7 +155,7 @@
 D_DrawSubdiv
 ================
 */
-void D_DrawSubdiv (void)
+void D_DrawSubdiv (byte *colormap)
 {
 	mtriangle_t		*ptri;
 	finalvert_t		*pfv, *index0, *index1, *index2;
@@ -180,7 +180,7 @@
 			continue;
 		}
 
-		d_pcolormap = &((byte *)acolormap)[index0->v[4] & 0xFF00];
+		d_pcolormap = colormap + (index0->v[4] & 0xFF00);
 
 		if (ptri[i].facesfront)
 		{
@@ -463,8 +463,7 @@
 		fixed8_t endvertu, fixed8_t endvertv)
 {
 	double		dm, dn;
-	int			tm, tn;
-	adivtab_t	*ptemp;
+	int			tm, tn, n;
 
 	// TODO: implement x86 version
 
@@ -476,9 +475,9 @@
 	if (((tm <= 16) && (tm >= -15)) &&
 		((tn <= 16) && (tn >= -15)))
 	{
-		ptemp = &adivtab[((tm+15) << 5) + (tn+15)];
-		ubasestep = ptemp->quotient;
-		erroradjustup = ptemp->remainder;
+		n = ((tm+15) << 5) + (tn+15);
+		ubasestep = adivtab[n].quotient;
+		erroradjustup = adivtab[n].remainder;
 		erroradjustdown = tn;
 	}
 	else
@@ -553,7 +552,7 @@
 D_PolysetDrawSpans8
 ================
 */
-void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage, byte alpha)
+void D_PolysetDrawSpans8 (spanpackage_t *pspanpackage, byte *colormap, byte alpha)
 {
 	int		lcount;
 	byte	*lpdest;
@@ -593,12 +592,12 @@
 				if ((lzi >> 16) >= *lpz){
 					if(r_drawflags & DRAW_BLEND){
 						*lpdest = blendalpha(
-							((byte *)acolormap)[*lptex + (llight & 0xFF00)],
+							colormap[*lptex + (llight & 0xFF00)],
 							*lpdest,
 							alpha
 						);
 					}else{
-						*lpdest = ((byte *)acolormap)[*lptex + (llight & 0xFF00)];
+						*lpdest = colormap[*lptex + (llight & 0xFF00)];
 						// gel mapping	*lpdest = gelmap[*lpdest];
 						*lpz = lzi >> 16;
 					}
@@ -844,7 +843,7 @@
 	d_countextrastep = ubasestep + 1;
 	originalcount = a_spans[initialrightheight].count;
 	a_spans[initialrightheight].count = Q_MININT; // mark end of the spanpackages
-	D_PolysetDrawSpans8 (a_spans, currententity->alpha);
+	D_PolysetDrawSpans8 (a_spans, currententity->colormap, currententity->alpha);
 
 	// scan out the bottom part of the right edge, if it exists
 	if (pedgetable->numrightedges == 2)
@@ -868,7 +867,7 @@
 		d_countextrastep = ubasestep + 1;
 		a_spans[initialrightheight + height].count = Q_MININT;
 											// mark end of the spanpackages
-		D_PolysetDrawSpans8 (pstart, currententity->alpha);
+		D_PolysetDrawSpans8 (pstart, currententity->colormap, currententity->alpha);
 	}
 }
 
--- a/d_scan.c
+++ b/d_scan.c
@@ -1,9 +1,9 @@
 #include "quakedef.h"
 
-unsigned char	*r_turb_pbase, *r_turb_pdest;
-fixed16_t		r_turb_s, r_turb_t, r_turb_sstep, r_turb_tstep;
-int				*r_turb_turb;
-int				r_turb_spancount;
+static unsigned char	*r_turb_pbase, *r_turb_pdest;
+static fixed16_t		r_turb_s, r_turb_t, r_turb_sstep, r_turb_tstep;
+static int				*r_turb_turb;
+static int				r_turb_spancount;
 static uzint	*r_turb_z;
 
 /*
@@ -22,9 +22,9 @@
 	int		*turb;
 	int		*col;
 	byte	**row;
-	static byte	*rowptr[MAXHEIGHT+(AMP2*2)];
-	static int		column[MAXWIDTH+(AMP2*2)];
 	float	wratio, hratio;
+	static byte	*rowptr[MAXHEIGHT+(AMP2*2)];
+	static int	column[MAXWIDTH+(AMP2*2)];
 
 	w = r_refdef.vrect.width;
 	h = r_refdef.vrect.height;
--- a/d_surf.c
+++ b/d_surf.c
@@ -3,12 +3,13 @@
 float		   surfscale;
 qboolean		r_cache_thrash;		 // set if surface cache is thrashing
 
-int sc_size;
-surfcache_t *sc_rover, *sc_base;
+surfcache_t *sc_rover;
 
+static surfcache_t *sc_base;
+static int sc_size;
+
 #define GUARDSIZE	   4
 
-
 int	 D_SurfaceCacheForRes (int width, int height)
 {
 	int			 size, pix;
@@ -53,7 +54,6 @@
 */
 void D_InitCaches (void *buffer, int size)
 {
-
 	if (!msg_suppress_1)
 		Con_Printf ("%dk surface cache\n", size/1024);
 
--- a/d_vars.c
+++ b/d_vars.c
@@ -20,5 +20,4 @@
 int				cachewidth;
 pixel_t			*d_viewbuffer;
 uzint			*d_pzbuffer;
-unsigned int	d_zrowbytes;
 unsigned int	d_zwidth;
--- a/d_zpoint.c
+++ /dev/null
@@ -1,23 +1,0 @@
-#include "quakedef.h"
-
-/*
-=====================
-D_DrawZPoint
-=====================
-*/
-void D_DrawZPoint (void)
-{
-	byte	*pdest;
-	uzint	*pz;
-	int		izi;
-
-	pz = d_pzbuffer + (d_zwidth * r_zpointdesc.v) + r_zpointdesc.u;
-	pdest = d_viewbuffer + d_scantable[r_zpointdesc.v] + r_zpointdesc.u;
-	izi = (int)(r_zpointdesc.zi * 0x8000);
-
-	if (*pz <= izi)
-	{
-		*pz = izi;
-		*pdest = r_zpointdesc.color;
-	}
-}
--- a/mkfile
+++ b/mkfile
@@ -33,7 +33,6 @@
 	d_sprite.$O\
 	d_surf.$O\
 	d_vars.$O\
-	d_zpoint.$O\
 	fs.$O\
 	host.$O\
 	host_cmd.$O\
--- a/r_aclip.c
+++ b/r_aclip.c
@@ -206,7 +206,7 @@
 R_AliasClipTriangle
 ================
 */
-void R_AliasClipTriangle (mtriangle_t *ptri)
+void R_AliasClipTriangle (mtriangle_t *ptri, auxvert_t *auxverts)
 {
 	int					i, k, pingpong;
 	static mtriangle_t	mtri;
@@ -238,7 +238,7 @@
 	if (clipflags & ALIAS_Z_CLIP)
 	{
 		for (i=0 ; i<3 ; i++)
-			av[i] = pauxverts[ptri->vertindex[i]];
+			av[i] = auxverts[ptri->vertindex[i]];
 
 		k = R_AliasClip (fv[0], fv[1], ALIAS_Z_CLIP, 3, R_Alias_clip_z);
 		if (k == 0)
@@ -319,7 +319,7 @@
 	{
 		mtri.vertindex[1] = i;
 		mtri.vertindex[2] = i+1;
-		D_PolysetDraw ();
+		D_PolysetDraw (currententity->colormap);
 	}
 }
 
--- a/r_alias.c
+++ b/r_alias.c
@@ -3,21 +3,15 @@
 #define LIGHT_MIN	5		// lowest light value we'll allow, to avoid the
 							//  need for inner-loop light clamping
 
-mtriangle_t		*ptriangles;
 affinetridesc_t	r_affinetridesc;
 
-void *			acolormap;	// FIXME: should go away
-
-trivertx_t		*r_apverts;
-
 // TODO: these probably will go away with optimized rasterization
-mdl_t				*pmdl;
-vec3_t				r_plightvec;
-int					r_ambientlight;
-float				r_shadelight;
-aliashdr_t			*paliashdr;
 finalvert_t			*pfinalverts;
-auxvert_t			*pauxverts;
+static mdl_t		*pmdl;
+static vec3_t		r_plightvec;
+static int			r_ambientlight;
+static float		r_shadelight;
+static aliashdr_t	*paliashdr;
 static float		ziscale;
 static model_t		*pmodel;
 
@@ -35,24 +29,19 @@
 	int	index1;
 } aedge_t;
 
-static aedge_t	aedges[12] = {
-{0, 1}, {1, 2}, {2, 3}, {3, 0},
-{4, 5}, {5, 6}, {6, 7}, {7, 4},
-{0, 5}, {1, 4}, {2, 7}, {3, 6}
+static const aedge_t aedges[12] = {
+	{0, 1}, {1, 2}, {2, 3}, {3, 0},
+	{4, 5}, {5, 6}, {6, 7}, {7, 4},
+	{0, 5}, {1, 4}, {2, 7}, {3, 6}
 };
 
-#define NUMVERTEXNORMALS	162
-
-float	r_avertexnormals[NUMVERTEXNORMALS][3] = {
+const float r_avertexnormals[NUMVERTEXNORMALS][3] = {
 #include "anorms.h"
 };
 
-void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv,
-	stvert_t *pstverts);
-void R_AliasSetUpTransform (int trivial_accept);
-void R_AliasTransformVector (vec3_t in, vec3_t out);
-void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
-	trivertx_t *pverts, stvert_t *pstverts);
+static void R_AliasSetUpTransform (int trivial_accept);
+static void R_AliasTransformVector (vec3_t in, vec3_t out);
+static void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, trivertx_t *pverts, stvert_t *pstverts);
 void R_AliasProjectFinalVert (finalvert_t *fv, auxvert_t *av);
 
 
@@ -221,7 +210,7 @@
 R_AliasTransformVector
 ================
 */
-void R_AliasTransformVector (vec3_t in, vec3_t out)
+static void R_AliasTransformVector (vec3_t in, vec3_t out)
 {
 	out[0] = DotProduct(in, aliastransform[0]) + aliastransform[0][3];
 	out[1] = DotProduct(in, aliastransform[1]) + aliastransform[1][3];
@@ -236,23 +225,23 @@
 General clipped case
 ================
 */
-void R_AliasPreparePoints (void)
+void R_AliasPreparePoints (trivertx_t *apverts, auxvert_t *auxverts, byte *colormap)
 {
 	int			i;
 	stvert_t	*pstverts;
 	finalvert_t	*fv;
-	auxvert_t	*av;
 	mtriangle_t	*ptri;
 	finalvert_t	*pfv[3];
+	auxvert_t *av;
 
 	pstverts = (stvert_t *)((byte *)paliashdr + paliashdr->stverts);
 	r_anumverts = pmdl->numverts;
  	fv = pfinalverts;
-	av = pauxverts;
+ 	av = auxverts;
 
-	for (i=0 ; i<r_anumverts ; i++, fv++, av++, r_apverts++, pstverts++)
+	for (i=0 ; i<r_anumverts ; i++, fv++, av++, apverts++, pstverts++)
 	{
-		R_AliasTransformFinalVert (fv, av, r_apverts, pstverts);
+		R_AliasTransformFinalVert (fv, av, apverts, pstverts);
 		if (av->fv[2] < ALIAS_Z_CLIP_PLANE)
 			fv->flags |= ALIAS_Z_CLIP;
 		else
@@ -288,11 +277,11 @@
 		{	// totally unclipped
 			r_affinetridesc.pfinalverts = pfinalverts;
 			r_affinetridesc.ptriangles = ptri;
-			D_PolysetDraw ();
+			D_PolysetDraw (colormap);
 		}
 		else
 		{	// partially clipped
-			R_AliasClipTriangle (ptri);
+			R_AliasClipTriangle (ptri, auxverts);
 		}
 	}
 }
@@ -303,13 +292,13 @@
 R_AliasSetUpTransform
 ================
 */
-void R_AliasSetUpTransform (int trivial_accept)
+static void R_AliasSetUpTransform (int trivial_accept)
 {
-	int				i;
-	float			rotationmatrix[3][4], t2matrix[3][4];
+	int		i;
+	float	rotationmatrix[3][4], t2matrix[3][4];
 	static float	tmatrix[3][4];
 	static float	viewmatrix[3][4];
-	vec3_t			angles;
+	vec3_t	angles;
 
 	// TODO: should really be stored with the entity instead of being reconstructed
 	// TODO: should use a look-up table
@@ -381,11 +370,10 @@
 R_AliasTransformFinalVert
 ================
 */
-void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av,
-	trivertx_t *pverts, stvert_t *pstverts)
+static void R_AliasTransformFinalVert (finalvert_t *fv, auxvert_t *av, trivertx_t *pverts, stvert_t *pstverts)
 {
 	int		temp;
-	float	lightcos, *plightnormal;
+	float	lightcos;
 
 	av->fv[0] = DotProduct_(pverts->v, aliastransform[0]) +
 			aliastransform[0][3];
@@ -400,8 +388,7 @@
 	fv->flags = pstverts->onseam;
 
 	// lighting
-	plightnormal = r_avertexnormals[pverts->lightnormalindex];
-	lightcos = DotProduct (plightnormal, r_plightvec);
+	lightcos = DotProduct(r_avertexnormals[pverts->lightnormalindex], r_plightvec);
 	temp = r_ambientlight;
 
 	if (lightcos < 0)
@@ -423,14 +410,11 @@
 R_AliasTransformAndProjectFinalVerts
 ================
 */
-void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts)
+void R_AliasTransformAndProjectFinalVerts (finalvert_t *fv, stvert_t *pstverts, trivertx_t *pverts)
 {
 	int			i, temp;
-	float		lightcos, *plightnormal, zi;
-	trivertx_t	*pverts;
+	float		lightcos, zi;
 
-	pverts = r_apverts;
-
 	for (i=0 ; i<r_anumverts ; i++, fv++, pverts++, pstverts++)
 	{
 		// transform and project
@@ -452,8 +436,7 @@
 		fv->flags = pstverts->onseam;
 
 		// lighting
-		plightnormal = r_avertexnormals[pverts->lightnormalindex];
-		lightcos = DotProduct (plightnormal, r_plightvec);
+		lightcos = DotProduct(r_avertexnormals[pverts->lightnormalindex], r_plightvec);
 		temp = r_ambientlight;
 
 		if (lightcos < 0)
@@ -495,7 +478,7 @@
 R_AliasPrepareUnclippedPoints
 ================
 */
-void R_AliasPrepareUnclippedPoints (void)
+void R_AliasPrepareUnclippedPoints (trivertx_t *pverts, byte *colormap)
 {
 	stvert_t	*pstverts;
 	finalvert_t	*fv;
@@ -505,10 +488,10 @@
 	// FIXME: just use pfinalverts directly?
 	fv = pfinalverts;
 
-	R_AliasTransformAndProjectFinalVerts (fv, pstverts);
+	R_AliasTransformAndProjectFinalVerts (fv, pstverts, pverts);
 
 	if (r_affinetridesc.drawtype)
-		D_PolysetDrawFinalVerts (fv, r_anumverts, currententity->alpha);
+		D_PolysetDrawFinalVerts (fv, r_anumverts, colormap, currententity->alpha);
 
 	r_affinetridesc.pfinalverts = pfinalverts;
 	r_affinetridesc.ptriangles = (mtriangle_t *)
@@ -515,7 +498,7 @@
 			((byte *)paliashdr + paliashdr->triangles);
 	r_affinetridesc.numtriangles = pmdl->numtris;
 
-	D_PolysetDraw ();
+	D_PolysetDraw (colormap);
 }
 
 /*
@@ -613,7 +596,7 @@
 set r_apverts
 =================
 */
-void R_AliasSetupFrame (void)
+trivertx_t *R_AliasSetupFrame (void)
 {
 	int				frame;
 	int				i, numframes;
@@ -629,9 +612,8 @@
 
 	if (paliashdr->frames[frame].type == ALIAS_SINGLE)
 	{
-		r_apverts = (trivertx_t *)
+		return (trivertx_t *)
 				((byte *)paliashdr + paliashdr->frames[frame].frame);
-		return;
 	}
 
 	paliasgroup = (maliasgroup_t *)
@@ -652,7 +634,7 @@
 			break;
 	}
 
-	r_apverts = (trivertx_t *)
+	return (trivertx_t *)
 				((byte *)paliashdr + paliasgroup->frames[i].frame);
 }
 
@@ -666,10 +648,10 @@
 {
 	static finalvert_t		finalverts[MAXALIASVERTS];
 	static auxvert_t		auxverts[MAXALIASVERTS];
+	trivertx_t *pverts;
 
 	// cache align
 	pfinalverts = finalverts;
-	pauxverts = auxverts;
 
 	paliashdr = (aliashdr_t *)Mod_Extradata (currententity->model);
 	pmdl = (mdl_t *)((byte *)paliashdr + paliashdr->model);
@@ -677,7 +659,7 @@
 	R_AliasSetupSkin ();
 	R_AliasSetUpTransform (currententity->trivial_accept);
 	R_AliasSetupLighting (plighting);
-	R_AliasSetupFrame ();
+	pverts = R_AliasSetupFrame ();
 
 	if (!currententity->colormap)
 		fatal ("R_AliasDrawModel: !currententity->colormap");
@@ -688,8 +670,6 @@
 	if (r_affinetridesc.drawtype)
 		D_PolysetUpdateTables ();		// FIXME: precalc...
 
-	acolormap = currententity->colormap;
-
 	if (currententity != &cl.viewent)
 		ziscale = (float)0x8000 * (float)0x10000;
 	else
@@ -696,7 +676,7 @@
 		ziscale = (float)0x8000 * (float)0x10000 * 3.0;
 
 	if (currententity->trivial_accept)
-		R_AliasPrepareUnclippedPoints ();
+		R_AliasPrepareUnclippedPoints (pverts, currententity->colormap);
 	else
-		R_AliasPreparePoints ();
+		R_AliasPreparePoints (pverts, auxverts, currententity->colormap);
 }
--- a/r_bsp.c
+++ b/r_bsp.c
@@ -11,9 +11,7 @@
 vec3_t			r_entorigin;	// the currently rendering entity in world
 								// coordinates
 
-float			entity_rotation[3][3];
-
-vec3_t			r_worldmodelorg;
+static float	entity_rotation[3][3];
 
 int				r_currentbkey;
 
--- a/r_draw.c
+++ b/r_draw.c
@@ -522,7 +522,6 @@
 			xcenter * surface_p->d_zistepu -
 			ycenter * surface_p->d_zistepv;
 
-	//JDC	VectorCopy (r_worldmodelorg, surface_p->modelorg);
 	surface_p++;
 
 	return 1;
@@ -639,7 +638,6 @@
 			xcenter * surface_p->d_zistepu -
 			ycenter * surface_p->d_zistepv;
 
-	//JDC	VectorCopy (r_worldmodelorg, surface_p->modelorg);
 	surface_p++;
 }
 
--- a/r_local.h
+++ b/r_local.h
@@ -101,7 +101,6 @@
 
 //=============================================================================
 
-extern int	vstartscan;
 extern int r_drawflags;
 
 
@@ -112,9 +111,7 @@
 // current entity info
 //
 extern	qboolean		insubmodel;
-extern	vec3_t			r_worldmodelorg;
 
-
 void R_DrawSprite (void);
 int R_RenderFace (msurface_t *fa, int clipflags);
 void R_RenderPoly (msurface_t *fa, int clipflags);
@@ -168,9 +165,6 @@
 								//  to the world BSP
 extern mvertex_t	*r_ptverts, *r_ptvertsmax;
 
-extern vec3_t			sbaseaxis[3], tbaseaxis[3];
-extern float			entity_rotation[3][3];
-
 extern int		reinit_surfcache;
 
 extern int		r_currentkey;
@@ -186,15 +180,10 @@
 #define MAXALIASVERTS		2000	// TODO: tune this
 #define ALIAS_Z_CLIP_PLANE	5
 
-extern int				numverts;
-extern mtriangle_t		*ptriangles;
-extern int				numtriangles;
-extern aliashdr_t		*paliashdr;
-extern mdl_t			*pmdl;
-extern float			leftclip, topclip, rightclip, bottomclip;
-extern int				r_acliptype;
+#define NUMVERTEXNORMALS	162
+extern const float r_avertexnormals[NUMVERTEXNORMALS][3];
+
 extern finalvert_t		*pfinalverts;
-extern auxvert_t		*pauxverts;
 
 qboolean R_AliasCheckBBox (void);
 
@@ -237,7 +226,7 @@
 extern mvertex_t	*r_pcurrentvertbase;
 extern int			r_maxvalidedgeoffset;
 
-void R_AliasClipTriangle (mtriangle_t *ptri);
+void R_AliasClipTriangle (mtriangle_t *ptri, auxvert_t *auxverts);
 
 extern int		r_frustum_indexes[4*6];
 extern int		r_maxsurfsseen, r_maxedgesseen, r_cnumsurfs;
--- a/r_part.c
+++ b/r_part.c
@@ -30,8 +30,6 @@
 ===============
 */
 
-#define NUMVERTEXNORMALS	162
-extern	float	r_avertexnormals[NUMVERTEXNORMALS][3];
 vec3_t	avelocities[NUMVERTEXNORMALS];
 float	beamlength = 16;
 vec3_t	avelocity = {23, 7, 3};