]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
fix "invalid tracenode: 0" bug
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Sat, 23 May 2009 18:23:14 +0000 (18:23 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Sat, 23 May 2009 18:23:14 +0000 (18:23 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@374 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/q3map2/light_trace.c

index 42613bea0f90c132e5ea460117b99b4328b1c010..ea3769a1b4d1fab59bcd0e261fc2425ca282e619 100644 (file)
@@ -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;