//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== unsigned AAS_HashVec( vec3_t vec ) { int x, y; x = ( MAX_MAP_BOUNDS + (int)( vec[0] + 0.5 ) ) >> VERTEX_HASH_SHIFT; y = ( MAX_MAP_BOUNDS + (int)( vec[1] + 0.5 ) ) >> VERTEX_HASH_SHIFT; if ( x < 0 || x >= VERTEX_HASH_SIZE || y < 0 || y >= VERTEX_HASH_SIZE ) { Log_Print( "WARNING! HashVec: point %f %f %f outside valid range\n", vec[0], vec[1], vec[2] ); Log_Print( "This should never happen!\n" ); return -1; } //end if return y * VERTEX_HASH_SIZE + x; } //end of the function AAS_HashVec
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== int LoadCfgFile( char *filename ) { source_t *source; token_t token; int settingsdefined; source = LoadSourceFile( filename ); if ( !source ) { Log_Print( "couldn't open cfg file %s\n", filename ); return false; } //end if settingsdefined = false; memset( &cfg, 0, sizeof( cfg_t ) ); while ( PC_ReadToken( source, &token ) ) { if ( !stricmp( token.string, "bbox" ) ) { if ( cfg.numbboxes >= AAS_MAX_BBOXES ) { SourceError( source, "too many bounding box volumes defined" ); } //end if if ( !ReadStructure( source, &bbox_struct, (char *) &cfg.bboxes[cfg.numbboxes] ) ) { FreeSource( source ); return false; } //end if cfg.allpresencetypes |= cfg.bboxes[cfg.numbboxes].presencetype; cfg.numbboxes++; } //end if else if ( !stricmp( token.string, "settings" ) ) { if ( settingsdefined ) { SourceWarning( source, "settings already defined\n" ); } //end if settingsdefined = true; if ( !ReadStructure( source, &cfg_struct, (char *) &cfg ) ) { FreeSource( source ); return false; } //end if } //end else if } //end while if ( VectorLength( cfg.phys_gravitydirection ) < 0.9 || VectorLength( cfg.phys_gravitydirection ) > 1.1 ) { SourceError( source, "invalid gravity direction specified" ); } //end if if ( cfg.numbboxes <= 0 ) { SourceError( source, "no bounding volumes specified" ); } //end if FreeSource( source ); SetCfgLibVars(); Log_Print( "using cfg file %s\n", filename ); return true; } //end of the function LoadCfgFile
/* ================ LoadMapFile ================ */ void Q2_LoadMapFile(char *filename) { int i; script_t *script; Log_Print("-- Q2_LoadMapFile --\n"); #ifdef ME //loaded map type loadedmaptype = MAPTYPE_QUAKE2; //reset the map loading ResetMapLoading(); #endif //ME script = LoadScriptFile(filename); if (!script) { Log_Print("couldn't open %s\n", filename); return; } //end if //white spaces and escape characters inside a string are not allowed SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES | SCFL_NOSTRINGESCAPECHARS | SCFL_PRIMITIVE); nummapbrushsides = 0; num_entities = 0; while (Q2_ParseMapEntity(script)) { } ClearBounds (map_mins, map_maxs); for (i=0 ; i<entities[0].numbrushes ; i++) { if (mapbrushes[i].mins[0] > 4096) continue; // no valid points AddPointToBounds (mapbrushes[i].mins, map_mins, map_maxs); AddPointToBounds (mapbrushes[i].maxs, map_mins, map_maxs); } //end for PrintMapInfo(); //free the script FreeScript(script); // TestExpandBrushes (); // Q2_CreateMapTexinfo(); } //end of the function Q2_LoadMapFile
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== int AAS_TestSplitPlane(tmp_area_t *tmparea, vec3_t normal, float dist, int *facesplits, int *groundsplits, int *epsilonfaces) { int j, side, front, back, planenum; float d, d_front, d_back; tmp_face_t *face; winding_t *w; *facesplits = *groundsplits = *epsilonfaces = 0; planenum = FindFloatPlane(normal, dist); w = AAS_SplitWinding(tmparea, planenum); if (!w) return false; FreeWinding(w); // for (face = tmparea->tmpfaces; face; face = face->next[side]) { //side of the face the area is on side = face->frontarea != tmparea; if ((face->planenum & ~1) == (planenum & ~1)) { Log_Print("AAS_TestSplitPlane: tried face plane as splitter\n"); return false; } //end if w = face->winding; //reset distance at front and back side of plane d_front = d_back = 0; //reset front and back flags front = back = 0; for (j = 0; j < w->numpoints; j++) { d = DotProduct(w->p[j], normal) - dist; if (d > d_front) d_front = d; if (d < d_back) d_back = d; if (d > 0.4) // PLANESIDE_EPSILON) front = 1; if (d < -0.4) // PLANESIDE_EPSILON) back = 1; } //end for //check for an epsilon face if ( (d_front > FACECLIP_EPSILON && d_front < FACE_EPSILON) || (d_back < -FACECLIP_EPSILON && d_back > -FACE_EPSILON) ) { (*epsilonfaces)++; } //end if //if the face has points at both sides of the plane if (front && back) { (*facesplits)++; if (face->faceflags & FACE_GROUND) { (*groundsplits)++; } //end if } //end if } //end for return true; } //end of the function AAS_TestSplitPlane
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void ThreadSetupLock( void ) { Log_Print( "Win32 multi-threading\n" ); InitializeCriticalSection( &crit ); threaded = true; //Stupid me... forgot this!!! currentnumthreads = 0; currentthreadid = 0; } //end of the function ThreadInitLock
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void QDECL ScriptWarning( script_t *script, const char *str, ... ) { char text[1024]; va_list ap; if ( script->flags & SCFL_NOWARNINGS ) { return; } va_start( ap, str ); #if !defined RTCW_ET vsprintf( text, str, ap ); #else Q_vsnprintf( text, sizeof( text ), str, ap ); #endif // RTCW_XX va_end( ap ); #ifdef BOTLIB botimport.Print( PRT_WARNING, "file %s, line %d: %s\n", script->filename, script->line, text ); #endif //BOTLIB #ifdef MEQCC printf( "warning: file %s, line %d: %s\n", script->filename, script->line, text ); #endif //MEQCC #ifdef BSPC Log_Print( "warning: file %s, line %d: %s\n", script->filename, script->line, text ); #endif //BSPC } //end of the function ScriptWarning
//=========================================================================== // Just decend the tree, and for each node that hasn't had an // area set, flood fill out from there // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void SetAreaPortalAreas_r(node_t *node) { bspbrush_t *b; entity_t *e; if(node->planenum != PLANENUM_LEAF) { SetAreaPortalAreas_r(node->children[0]); SetAreaPortalAreas_r(node->children[1]); return; } //end if if(node->contents == CONTENTS_AREAPORTAL) { if(node->area) { return; // allready set } b = node->brushlist; e = &entities[b->original->entitynum]; node->area = e->portalareas[0]; if(!e->portalareas[1]) { Log_Print("WARNING: areaportal entity %i doesn't touch two areas\n", b->original->entitynum); return; } //end if } //end if } //end of the function SetAreaPortalAreas_r
/***************************************************************************** * ContentDir_Create *****************************************************************************/ ContentDir* ContentDir_Create (void* talloc_context, UpnpClient_Handle ctrlpt_handle, IXML_Element* serviceDesc, const char* base_url) { OBJECT_SUPER_CONSTRUCT (ContentDir, Service_Create, talloc_context, ctrlpt_handle, serviceDesc, base_url); if (self == NULL) goto error; // ----------> if (CACHE_SIZE > 0 && CACHE_TIMEOUT > 0) { self->cache = Cache_Create (self, CACHE_SIZE, CACHE_TIMEOUT, cache_free_expired_data); if (self->cache == NULL) goto error; // ----------> ithread_mutex_init (&self->cache_mutex, NULL); } return self; // ----------> error: Log_Print (LOG_ERROR, "ContentDir_Create error"); if (self) talloc_free (self); return NULL; }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void ThreadSetupLock(void) { pthread_mutexattr_t mattrib; Log_Print("pthread multi-threading\n"); if (!my_mutex) { my_mutex = GetMemory(sizeof(*my_mutex)); if (pthread_mutexattr_create (&mattrib) == -1) Error ("pthread_mutex_attr_create failed"); if (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1) Error ("pthread_mutexattr_setkind_np failed"); if (pthread_mutex_init (my_mutex, mattrib) == -1) Error ("pthread_mutex_init failed"); } if (pthread_attr_create (&attrib) == -1) Error ("pthread_attr_create failed"); if (pthread_attr_setstacksize (&attrib, 0x100000) == -1) Error ("pthread_attr_setstacksize failed"); threaded = true; currentnumthreads = 0; currentthreadid = 0; } //end of the function ThreadInitLock
void AAS_CalcReachAndClusters( struct quakefile_s *qf ) { float time; Log_Print( "loading collision map...\n" ); // if ( !qf->pakfile[0] ) { strcpy( qf->pakfile, qf->filename ); } //load the map CM_LoadMap( (char *) qf, qfalse, &( *aasworld ).bspchecksum ); //get a handle to the world model worldmodel = CM_InlineModel( 0 ); // 0 = world, 1 + are bmodels //initialize bot import structure AAS_InitBotImport(); //load the BSP entity string AAS_LoadBSPFile(); //init physics settings AAS_InitSettings(); //initialize AAS link heap AAS_InitAASLinkHeap(); //initialize the AAS linked entities for the new map AAS_InitAASLinkedEntities(); //reset all reachabilities and clusters ( *aasworld ).reachabilitysize = 0; ( *aasworld ).numclusters = 0; //set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach) AAS_SetViewPortalsAsClusterPortals(); //calculate reachabilities AAS_InitReachability(); time = 0; while ( AAS_ContinueInitReachability( time ) ) time++; //calculate clusters AAS_InitClustering(); } //end of the function AAS_CalcReachAndClusters
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Q1_LoadMapFromBSP(char *filename, int offset, int length) { int i, modelnum; char *model, *classname; Log_Print("-- Q1_LoadMapFromBSP --\n"); //the loaded map type loadedmaptype = MAPTYPE_QUAKE1; // qprintf("loading map from %s at %d\n", filename, offset); //load the Half-Life BSP file Q1_LoadBSPFile(filename, offset, length); // q1_numclipbrushes = 0; //CreatePath(path); //Q1_CreateQ2WALFiles(path); //parse the entities from the BSP Q1_ParseEntities(); //clear the map mins and maxs ClearBounds(map_mins, map_maxs); // qprintf("creating Quake1 brushes\n"); if (lessbrushes) { qprintf("creating minimum number of brushes\n"); } else { qprintf("placing textures correctly\n"); } // for (i = 0; i < num_entities; i++) { entities[i].firstbrush = nummapbrushes; entities[i].numbrushes = 0; // classname = ValueForKey(&entities[i], "classname"); if (classname && !strcmp(classname, "worldspawn")) { modelnum = 0; } //end if else { // model = ValueForKey(&entities[i], "model"); if (!model || *model != '*') { continue; } model++; modelnum = atoi(model); } //end else //create map brushes for the entity Q1_CreateMapBrushes(&entities[i], modelnum); } //end for // qprintf("%5d map brushes\n", nummapbrushes); qprintf("%5d clip brushes\n", q1_numclipbrushes); } //end of the function Q1_LoadMapFromBSP
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_FlipAreaFaces(tmp_area_t *tmparea) { int side; tmp_face_t *face; plane_t *plane; vec3_t wcenter, acenter = {0, 0, 0}; //winding_t *w; float n; for (n = 0, face = tmparea->tmpfaces; face; face = face->next[side]) { if (!face->frontarea) Error("face %d has no front area\n", face->num); //side of the face the area is on side = face->frontarea != tmparea; WindingCenter(face->winding, wcenter); VectorAdd(acenter, wcenter, acenter); n++; } //end for n = 1 / n; VectorScale(acenter, n, acenter); for (face = tmparea->tmpfaces; face; face = face->next[side]) { //side of the face the area is on side = face->frontarea != tmparea; plane = &mapplanes[face->planenum ^ side]; if (DotProduct(plane->normal, acenter) - plane->dist < 0) { Log_Print("area %d face %d flipped: front area %d, back area %d\n", tmparea->areanum, face->num, face->frontarea ? face->frontarea->areanum : 0, face->backarea ? face->backarea->areanum : 0); /* face->planenum = face->planenum ^ 1; w = face->winding; face->winding = ReverseWinding(w); FreeWinding(w); */ } //end if #ifdef L_DEBUG { float dist; vec3_t normal; //check if the winding plane is the same as the face plane WindingPlane(face->winding, normal, &dist); plane = &mapplanes[face->planenum]; if (fabs(dist - plane->dist) > 0.4 || fabs(normal[0] - plane->normal[0]) > 0.0001 || fabs(normal[1] - plane->normal[1]) > 0.0001 || fabs(normal[2] - plane->normal[2]) > 0.0001) { Log_Write("area %d face %d winding plane unequal to face plane\r\n", tmparea->areanum, face->num); } //end if } #endif } //end for } //end of the function AAS_FlipAreaFaces
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void RunThreadsOn(int workcnt, qboolean showpacifier, void(*func)(int)) { int i; pthread_t work_threads[MAX_THREADS]; pthread_addr_t status; pthread_attr_t attrib; pthread_mutexattr_t mattrib; int start, end; Log_Print("pthread multi-threading\n"); start = I_FloatTime (); dispatch = 0; workcount = workcnt; oldf = -1; pacifier = showpacifier; threaded = true; if (numthreads < 1 || numthreads > MAX_THREADS) numthreads = 1; if (pacifier) setbuf (stdout, NULL); if (!my_mutex) { my_mutex = GetMemory(sizeof(*my_mutex)); if (pthread_mutexattr_create (&mattrib) == -1) Error ("pthread_mutex_attr_create failed"); if (pthread_mutexattr_setkind_np (&mattrib, MUTEX_FAST_NP) == -1) Error ("pthread_mutexattr_setkind_np failed"); if (pthread_mutex_init (my_mutex, mattrib) == -1) Error ("pthread_mutex_init failed"); } if (pthread_attr_create (&attrib) == -1) Error ("pthread_attr_create failed"); if (pthread_attr_setstacksize (&attrib, 0x100000) == -1) Error ("pthread_attr_setstacksize failed"); for (i=0 ; i<numthreads ; i++) { if (pthread_create(&work_threads[i], attrib , (pthread_startroutine_t)func, (pthread_addr_t)i) == -1) Error ("pthread_create failed"); } for (i=0 ; i<numthreads ; i++) { if (pthread_join (work_threads[i], &status) == -1) Error ("pthread_join failed"); } threaded = false; end = I_FloatTime (); if (pacifier) printf (" (%i)\n", end-start); } //end of the function RunThreadsOn
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void ThreadSetupLock( void ) { init_lock( &lck ); Log_Print( "IRIX multi-threading\n" ); threaded = true; currentnumthreads = 0; currentthreadid = 0; } //end of the function ThreadInitLock
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void ThreadSetupLock( void ) { pthread_mutexattr_t mattrib; Log_Print( "pthread multi-threading\n" ); threaded = true; currentnumthreads = 0; currentthreadid = 0; } //end of the function ThreadInitLock
/* ============= CountTriangles ============= */ void CountTriangles( void ) { int i, numTris, numPatchTris; dsurface_t *surface; numTris = numPatchTris = 0; for ( i = 0; i < q3_numDrawSurfaces; i++ ) { surface = &drawSurfaces[i]; numTris += surface->numIndexes / 3; if ( surface->patchWidth ) { numPatchTris += surface->patchWidth * surface->patchHeight * 2; } } Log_Print( "%6d triangles\n", numTris ); Log_Print( "%6d patch tris\n", numPatchTris ); }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )(int) ) { int threadid[MAX_THREADS]; HANDLE threadhandle[MAX_THREADS]; int i; int start, end; Log_Print( "Win32 multi-threading\n" ); start = I_FloatTime(); dispatch = 0; workcount = workcnt; oldf = -1; pacifier = showpacifier; threaded = true; if ( numthreads == -1 ) { ThreadSetDefault(); } if ( numthreads < 1 || numthreads > MAX_THREADS ) { numthreads = 1; } // // run threads in parallel // InitializeCriticalSection( &crit ); numwaitingthreads = 0; if ( numthreads == 1 ) { // use same thread func( 0 ); } //end if else { // printf("starting %d threads\n", numthreads); for ( i = 0; i < numthreads; i++ ) { threadhandle[i] = CreateThread( NULL, // LPSECURITY_ATTRIBUTES lpsa, 0, // DWORD cbStack, (LPTHREAD_START_ROUTINE)func, // LPTHREAD_START_ROUTINE lpStartAddr, (LPVOID)i, // LPVOID lpvThreadParm, 0, // DWORD fdwCreate, &threadid[i] ); // printf("started thread %d\n", i); } //end for for ( i = 0; i < numthreads; i++ ) WaitForSingleObject( threadhandle[i], INFINITE ); } //end else DeleteCriticalSection( &crit ); threaded = false; end = I_FloatTime(); if ( pacifier ) { printf( " (%i)\n", end - start ); } } //end of the function RunThreadsOn
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Q2_LoadMapFromBSP(char *filename, int offset, int length) { int i; Log_Print("-- Q2_LoadMapFromBSP --\n"); //loaded map type loadedmaptype = MAPTYPE_QUAKE2; Log_Print("Loading map from %s...\n", filename); //load the bsp file Q2_LoadBSPFile(filename, offset, length); //create an index from bsp planes to map planes //DPlanes2MapPlanes(); //clear brush model numbers for (i = 0; i < MAX_MAPFILE_BRUSHES; i++) brushmodelnumbers[i] = -1; nummapbrushsides = 0; num_entities = 0; Q2_ParseEntities(); // for (i = 0; i < num_entities; i++) { Q2_ParseBSPEntity(i); } //end for //get the map mins and maxs from the world model ClearBounds(map_mins, map_maxs); for (i = 0; i < entities[0].numbrushes; i++) { if (mapbrushes[i].mins[0] > 4096) { continue; //no valid points } AddPointToBounds(mapbrushes[i].mins, map_mins, map_maxs); AddPointToBounds(mapbrushes[i].maxs, map_mins, map_maxs); } //end for PrintMapInfo(); // Q2_CreateMapTexinfo(); } //end of the function Q2_LoadMapFromBSP
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Q1_FixContentsTextures(bspbrush_t *brushlist) { int i, texinfonum; bspbrush_t *brush; for (brush = brushlist; brush; brush = brush->next) { //only fix the textures of water, slime and lava brushes if (brush->side != CONTENTS_WATER && brush->side != CONTENTS_SLIME && brush->side != CONTENTS_LAVA) continue; // for (i = 0; i < brush->numsides; i++) { texinfonum = brush->sides[i].texinfo; if (Q1_TextureContents(map_texinfo[texinfonum].texture) == brush->side) break; } //end for //if no specific contents texture was found if (i >= brush->numsides) { texinfonum = -1; for (i = 0; i < map_numtexinfo; i++) { if (Q1_TextureContents(map_texinfo[i].texture) == brush->side) { texinfonum = i; break; } //end if } //end for } //end if // if (texinfonum >= 0) { //give all the brush sides this contents texture for (i = 0; i < brush->numsides; i++) { brush->sides[i].texinfo = texinfonum; } //end for } //end if else Log_Print("brush contents %d with wrong textures\n", brush->side); // } //end for /* for (brush = brushlist; brush; brush = brush->next) { //give all the brush sides this contents texture for (i = 0; i < brush->numsides; i++) { if (Q1_TextureContents(map_texinfo[texinfonum].texture) != brush->side) { Error("brush contents %d with wrong contents textures %s\n", brush->side, Q1_TextureContents(map_texinfo[texinfonum].texture)); } //end if } //end for } //end for*/ } //end of the function Q1_FixContentsTextures
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void CheckBSPBrush(bspbrush_t *brush) { int i, j; plane_t *plane1, *plane2; //check if the brush is convex... flipped planes make a brush non-convex for (i = 0; i < brush->numsides; i++) { for (j = 0; j < brush->numsides; j++) { if (i == j) continue; plane1 = &mapplanes[brush->sides[i].planenum]; plane2 = &mapplanes[brush->sides[j].planenum]; // if (WindingsNonConvex(brush->sides[i].winding, brush->sides[j].winding, plane1->normal, plane2->normal, plane1->dist, plane2->dist)) { Log_Print("non convex brush"); break; } //end if } //end for } //end for BoundBrush(brush); //check for out of bound brushes for (i = 0; i < 3; i++) { if (brush->mins[i] < -MAX_MAP_BOUNDS || brush->maxs[i] > MAX_MAP_BOUNDS) { Log_Print("brush: bounds out of range\n"); Log_Print("ob->mins[%d] = %f, ob->maxs[%d] = %f\n", i, brush->mins[i], i, brush->maxs[i]); break; } //end if if (brush->mins[i] > MAX_MAP_BOUNDS || brush->maxs[i] < -MAX_MAP_BOUNDS) { Log_Print("brush: no visible sides on brush\n"); Log_Print("ob->mins[%d] = %f, ob->maxs[%d] = %f\n", i, brush->mins[i], i, brush->maxs[i]); break; } //end if } //end for } //end of the function CheckBSPBrush
void FloodPortals_r(node_t *node, int dist) { portal_t *p; int s; // int i; Log_Print("\r%6d", ++numrec); if(node->occupied) { Error("FloodPortals_r: node already occupied\n"); } if(!node) { Error("FloodPortals_r: NULL node\n"); } //end if*/ node->occupied = dist; for(p = node->portals; p; p = p->next[s]) { s = (p->nodes[1] == node); //if the node at the other side of the portal is occupied already if(p->nodes[!s]->occupied) { continue; } //if it isn't possible to flood through this portal if(!Portal_EntityFlood(p, s)) { continue; } //flood recursively through the current portal FloodPortals_r(p->nodes[!s], dist + 1); } //end for Log_Print("\r%6d", --numrec); } //end of the function FloodPortals_r
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void MakeTreePortals( tree_t *tree ) { #ifdef ME Log_Print( "---- Node Portalization ----\n" ); c_numportalizednodes = 0; c_portalmemory = 0; qprintf( "%6d nodes portalized", c_numportalizednodes ); #endif //ME MakeHeadnodePortals( tree ); MakeTreePortals_r( tree->headnode ); #ifdef ME qprintf( "\n" ); Log_Write( "\r%6d nodes portalized\r\n", c_numportalizednodes ); Log_Print( "%6d tiny portals\r\n", c_tinyportals ); Log_Print( "%6d KB of portal memory\r\n", c_portalmemory >> 10 ); Log_Print( "%6i KB of winding memory\r\n", WindingMemory() >> 10 ); #endif //ME } //end of the function MakeTreePortals
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Tree_Free( tree_t *tree ) { //if no tree just return if ( !tree ) { return; } // freedtreemem = 0; // Tree_FreePortals_r( tree->headnode ); Tree_Free_r( tree->headnode ); #ifdef ME freedtreemem += MemorySize( tree ); #endif //ME FreeMemory( tree ); #ifdef ME Log_Print( "freed " ); PrintMemorySize( freedtreemem ); Log_Print( " of tree memory\n" ); #endif //ME } //end of the function Tree_Free
void Log_NewMessage(char* format, ...) { va_list argptr; static char string[MAX_LOG]; va_start(argptr, format); _vsnprintf(string, sizeof(string), format, argptr); va_end(argptr); Log_Print(string); }
void MakeTreePortals_r(node_t *node) { int i; #ifdef ME qprintf("\r%6d", ++c_numportalizednodes); if(cancelconversion) { return; } #endif //ME CalcNodeBounds(node); if(node->mins[0] >= node->maxs[0]) { Log_Print("WARNING: node without a volume\n"); } for(i = 0 ; i < 3 ; i++) { if(node->mins[i] < -MAX_MAP_BOUNDS || node->maxs[i] > MAX_MAP_BOUNDS) { Log_Print("WARNING: node with unbounded volume\n"); break; } } if(node->planenum == PLANENUM_LEAF) { return; } MakeNodePortal(node); SplitNodePortals(node); MakeTreePortals_r(node->children[0]); MakeTreePortals_r(node->children[1]); } //end of the function MakeTreePortals_r
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_FlipSharedFaces(void) { int i, side1, side2; tmp_area_t *tmparea1; tmp_face_t *face1, *face2; i = 0; qprintf("%6d areas checked for shared face flipping", i); for(tmparea1 = tmpaasworld.areas; tmparea1; tmparea1 = tmparea1->l_next) { if(tmparea1->invalid) { continue; } for(face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1]) { side1 = face1->frontarea != tmparea1; if(!face1->frontarea || !face1->backarea) { continue; } // for(face2 = face1->next[side1]; face2; face2 = face2->next[side2]) { side2 = face2->frontarea != tmparea1; if(!face2->frontarea || !face2->backarea) { continue; } // if(face1->frontarea == face2->backarea && face1->backarea == face2->frontarea) { AAS_FlipFace(face2); } //end if //recheck side side2 = face2->frontarea != tmparea1; } //end for } //end for qprintf("\r%6d", ++i); } //end for qprintf("\n"); Log_Print("%6d areas checked for shared face flipping\r\n", i); } //end of the function AAS_FlipSharedFaces
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_ShowNumReachabilities( int tt, char *name ) { int i, num; num = 0; for ( i = 0; i < ( *aasworld ).reachabilitysize; i++ ) { if ( ( ( *aasworld ).reachability[i].traveltype & TRAVELTYPE_MASK ) == tt ) { num++; } } //end for Log_Print( "%6d %s\n", num, name ); } //end of the function AAS_ShowNumReachabilities
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void RunThreadsOn(int workcnt, qboolean showpacifier, void (*func)(int)) { int i; pthread_t work_threads[MAX_THREADS]; void *pthread_return; pthread_attr_t attrib; pthread_mutexattr_t mattrib; int start, end; Log_Print("pthread multi-threading\n"); start = I_FloatTime(); dispatch = 0; workcount = workcnt; oldf = -1; pacifier = showpacifier; threaded = true; if (numthreads < 1 || numthreads > MAX_THREADS) { numthreads = 1; } if (pacifier) { setbuf(stdout, NULL); } for (i = 0 ; i < numthreads ; i++) { if (pthread_create(&work_threads[i], NULL, (void *)func, (void *)i) == -1) { Error("pthread_create failed"); } } for (i = 0 ; i < numthreads ; i++) { if (pthread_join(work_threads[i], &pthread_return) == -1) { Error("pthread_join failed"); } } threaded = false; end = I_FloatTime(); if (pacifier) { printf(" (%i)\n", end - start); } } //end of the function RunThreadsOn
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void FindBrushInTree( node_t *node, int brushnum ) { bspbrush_t *b; if ( node->planenum == PLANENUM_LEAF ) { for ( b = node->brushlist ; b ; b = b->next ) if ( b->original->brushnum == brushnum ) { Log_Print( "here\n" ); } return; } FindBrushInTree( node->children[0], brushnum ); FindBrushInTree( node->children[1], brushnum ); } //end of the function FindBrushInTree
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_StoreAreaSettings(tmp_areasettings_t *tmpareasettings) { aas_areasettings_t *areasettings; if (aasworld.numareasettings == 0) aasworld.numareasettings = 1; areasettings = &aasworld.areasettings[aasworld.numareasettings++]; areasettings->areaflags = tmpareasettings->areaflags; areasettings->presencetype = tmpareasettings->presencetype; areasettings->contents = tmpareasettings->contents; if (tmpareasettings->modelnum > AREACONTENTS_MAXMODELNUM) Log_Print("WARNING: more than %d mover models\n", AREACONTENTS_MAXMODELNUM); areasettings->contents |= (tmpareasettings->modelnum & AREACONTENTS_MAXMODELNUM) << AREACONTENTS_MODELNUMSHIFT; } //end of the function AAS_StoreAreaSettings