From: divverent Date: Sat, 23 May 2009 18:23:14 +0000 (+0000) Subject: fix "invalid tracenode: 0" bug X-Git-Tag: svn-r421~46 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=52098ce5f14231b9e35275f55aecd220134abba5 fix "invalid tracenode: 0" bug git-svn-id: svn://svn.icculus.org/netradiant/trunk@374 61c419a2-8eb2-4b30-bcec-8cead039b335 --- diff --git a/tools/quake3/q3map2/light_trace.c b/tools/quake3/q3map2/light_trace.c index 42613bea..ea3769a1 100644 --- a/tools/quake3/q3map2/light_trace.c +++ b/tools/quake3/q3map2/light_trace.c @@ -201,6 +201,9 @@ static int AllocTraceNode( void ) memset( &traceNodes[ numTraceNodes ], 0, sizeof( traceNode_t ) ); traceNodes[ numTraceNodes ].type = TRACE_LEAF; ClearBounds( traceNodes[ numTraceNodes ].mins, traceNodes[ numTraceNodes ].maxs ); + + /* Sys_Printf("alloc node %d\n", numTraceNodes); */ + numTraceNodes++; /* return the count */ @@ -362,7 +365,7 @@ recursively create the initial trace node structure from the bsp tree static int SetupTraceNodes_r( int bspNodeNum ) { - int i, nodeNum, bspLeafNum; + int i, nodeNum, bspLeafNum, newNode; bspPlane_t *plane; bspNode_t *bspNode; @@ -388,7 +391,10 @@ static int SetupTraceNodes_r( int bspNodeNum ) bspLeafNum = -bspNode->children[ i ] - 1; /* new code */ - traceNodes[ nodeNum ].children[ i ] = AllocTraceNode(); + newNode = AllocTraceNode(); + traceNodes[ nodeNum ].children[ i ] = newNode; + /* have to do this separately, as gcc first executes LHS, then RHS, and if a realloc took place, this fails */ + if( bspLeafs[ bspLeafNum ].cluster == -1 ) traceNodes[ traceNodes[ nodeNum ].children[ i ] ].type = TRACE_LEAF_SOLID; } @@ -397,6 +403,8 @@ static int SetupTraceNodes_r( int bspNodeNum ) else traceNodes[ nodeNum ].children[ i ] = SetupTraceNodes_r( bspNode->children[ i ] ); } + + /* Sys_Printf("node %d children: %d %d\n", nodeNum, traceNodes[ nodeNum ].children[0], traceNodes[ nodeNum ].children[1]); */ /* return node number */ return nodeNum;