From e7f13faa4bb5ab02eb892ee43ee16b83a22221e1 Mon Sep 17 00:00:00 2001 From: divverent Date: Sat, 14 Feb 2009 18:14:30 +0000 Subject: [PATCH] fix multiple bugs with the limit extension git-svn-id: svn://svn.icculus.org/netradiant/trunk@191 61c419a2-8eb2-4b30-bcec-8cead039b335 --- tools/quake3/q3map2/lightmaps_ydnar.c | 6 +++--- tools/quake3/q3map2/q3map2.h | 4 ++-- tools/quake3/q3map2/writebsp.c | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index b4b6349f..9e41af4f 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -865,9 +865,9 @@ static int CompareSurfaceInfo( const void *a, const void *b ) bInfo = &surfaceInfos[ *((int*) b) ]; /* model first */ - if( aInfo->model < bInfo->model ) + if( aInfo->modelindex < bInfo->modelindex ) return 1; - else if( aInfo->model > bInfo->model ) + else if( aInfo->modelindex > bInfo->modelindex ) return -1; /* then lightmap status */ @@ -997,7 +997,7 @@ void SetupSurfaceLightmaps( void ) VectorClear( entityOrigin ); /* basic setup */ - info->model = model; + info->modelindex = i; info->lm = NULL; info->plane = NULL; info->firstSurfaceCluster = numSurfaceClusters; diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index 3224d8e9..4819ff30 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1421,7 +1421,7 @@ rawGridPoint_t; typedef struct surfaceInfo_s { - bspModel_t *model; + int modelindex; shaderInfo_t *si; rawLightmap_t *lm; int parentSurfaceNum, childSurfaceNum; @@ -2328,7 +2328,7 @@ Q_EXTERN int* bspLeafSurfaces Q_ASSIGN(NULL); Q_EXTERN int numBSPLeafBrushes Q_ASSIGN( 0 ); Q_EXTERN int allocatedBSPLeafBrushes Q_ASSIGN( 0 ); -Q_EXTERN int* bspLeafBrushes Q_ASSIGN(0); +Q_EXTERN int* bspLeafBrushes Q_ASSIGN(NULL); Q_EXTERN int numBSPBrushes Q_ASSIGN( 0 ); Q_EXTERN int allocatedBSPBrushes Q_ASSIGN( 0 ); diff --git a/tools/quake3/q3map2/writebsp.c b/tools/quake3/q3map2/writebsp.c index 70a382dd..96e8ce29 100644 --- a/tools/quake3/q3map2/writebsp.c +++ b/tools/quake3/q3map2/writebsp.c @@ -199,7 +199,7 @@ recursively emit the bsp nodes int EmitDrawNode_r( node_t *node ) { bspNode_t *n; - int i; + int i, n0; /* check for leafnode */ @@ -211,7 +211,8 @@ int EmitDrawNode_r( node_t *node ) /* emit a node */ AUTOEXPAND_BY_REALLOC_BSP(Nodes, 1024); - n = &bspNodes[ numBSPNodes ]; + n0 = numBSPNodes; + n = &bspNodes[ n0 ]; numBSPNodes++; VectorCopy (node->mins, n->mins); @@ -235,6 +236,8 @@ int EmitDrawNode_r( node_t *node ) { n->children[i] = numBSPNodes; EmitDrawNode_r (node->children[i]); + // n may have become invalid here, so... + n = &bspNodes[ n0 ]; } } -- 2.39.2