X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=svbsp.c;h=1ad7fafc82248c7826c96da409514800468c1fa4;hb=73f27d62983b6af1cb9a6971d0a4cb6275b91a07;hp=c3e69371915d95ba0e5bc1107a2b342432571eb0;hpb=1a807173f3ca900bd1d4575317b010bdbe1e76d7;p=xonotic%2Fdarkplaces.git diff --git a/svbsp.c b/svbsp.c index c3e69371..1ad7fafc 100644 --- a/svbsp.c +++ b/svbsp.c @@ -1,14 +1,14 @@ -// Shadow Volume BSP code written by Forest "LordHavoc" Hale on 2003-11-06 and placed into public domain. -// Modified by LordHavoc (to make it work and other nice things like that) on 2007-01-24 and 2007-01-25 -// Optimized by LordHavoc on 2009-12-24 and 2009-12-25 +// Shadow Volume BSP code written by Ashley Rose Hale (LadyHavoc) on 2003-11-06 and placed into public domain. +// Modified by LadyHavoc (to make it work and other nice things like that) on 2007-01-24 and 2007-01-25 +// Optimized by LadyHavoc on 2009-12-24 and 2009-12-25 #include #include #include "svbsp.h" #include "polygon.h" -#define MAX_SVBSP_POLYGONPOINTS 16 +#define MAX_SVBSP_POLYGONPOINTS 64 #define SVBSP_CLIP_EPSILON (1.0f / 1024.0f) #define SVBSP_DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2]) @@ -158,7 +158,7 @@ static void SVBSP_InsertOccluderPolygonNodes(svbsp_t *b, int *parentnodenumpoint { // now we need to create up to numpoints + 1 new nodes, forming a BSP tree // describing the occluder polygon's shadow volume - int i, j, p, basenum; + int i, j, p; svbsp_node_t *node; // points and lines are valid testers but not occluders @@ -187,7 +187,6 @@ static void SVBSP_InsertOccluderPolygonNodes(svbsp_t *b, int *parentnodenumpoint // note down the first available nodenum for the *parentnodenumpointer // line which is done last to allow multithreaded queries during an // insertion - basenum = b->numnodes; for (i = 0, p = poly->numpoints - 1;i < poly->numpoints;p = i, i++) { #if 1 @@ -410,6 +409,9 @@ int SVBSP_AddPolygon(svbsp_t *b, int numpoints, const float *points, int inserto // note we still allow points and lines to be tested... if (numpoints < 1) return 0; + // if the polygon has too many points, we would crash + if (numpoints > MAX_SVBSP_POLYGONPOINTS) + return 0; poly.numpoints = numpoints; for (i = 0;i < numpoints;i++) {