//=========================================================================== // checks the number of shared faces between the given two areas // since areas are convex they should only have ONE shared face // however due to crappy face merging there are sometimes several // shared faces // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_CheckAreaSharedFaces(tmp_area_t *tmparea1, tmp_area_t *tmparea2) { int numsharedfaces, side; tmp_face_t *face1, *sharedface; if (tmparea1->invalid || tmparea2->invalid) return; sharedface = NULL; numsharedfaces = 0; for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side]) { side = face1->frontarea != tmparea1; if (face1->backarea == tmparea2 || face1->frontarea == tmparea2) { sharedface = face1; numsharedfaces++; } //end if } //end if if (!sharedface) return; //the areas should only have one shared face if (numsharedfaces > 1) { Log_Write("---- tmp area %d and %d have %d shared faces\r\n", tmparea1->areanum, tmparea2->areanum, numsharedfaces); for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side]) { side = face1->frontarea != tmparea1; if (face1->backarea == tmparea2 || face1->frontarea == tmparea2) { Log_Write("face %d, planenum = %d, face->frontarea = %d face->backarea = %d\r\n", face1->num, face1->planenum, face1->frontarea->areanum, face1->backarea->areanum); } //end if } //end if } //end if } //end of the function AAS_CheckAreaSharedFaces
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_CreateAreas( node_t *node ) { Log_Write( "AAS_CreateAreas\r\n" ); qprintf( "%6d areas created", 0 ); tmpaasworld.nodes = AAS_CreateAreas_r( node ); qprintf( "\n" ); Log_Write( "%6d areas created\r\n", tmpaasworld.numareas ); } //end of the function AAS_CreateAreas
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_RemoveTinyFaces(void) { int side, num; tmp_face_t *face, *nextface; tmp_area_t *tmparea; //FIXME: loop over the faces instead of area->faces Log_Write("AAS_RemoveTinyFaces\r\n"); num = 0; for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) { for (face = tmparea->tmpfaces; face; face = nextface) { side = face->frontarea != tmparea; nextface = face->next[side]; // if (WindingArea(face->winding) < 1) { if (face->frontarea) AAS_RemoveFaceFromArea(face, face->frontarea); if (face->backarea) AAS_RemoveFaceFromArea(face, face->backarea); AAS_FreeTmpFace(face); //Log_Write("area %d face %d is tiny\r\n", tmparea->areanum, face->num); num++; } //end if } //end for } //end for Log_Write("%d tiny faces removed\r\n", num); } //end of the function AAS_RemoveTinyFaces
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_MergeAreaPlaneFaces( void ) { int num_facemerges = 0; int side1; tmp_area_t *tmparea, *nexttmparea; tmp_face_t *face1; Log_Write( "AAS_MergePlaneFaces\r\n" ); qprintf( "%6d plane face merges", num_facemerges ); //NOTE: first convex area is a dummy for ( tmparea = tmpaasworld.areas; tmparea; tmparea = nexttmparea ) { nexttmparea = tmparea->l_next; // if ( tmparea->invalid ) { continue; } // for ( face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1] ) { side1 = face1->frontarea != tmparea; // if ( AAS_CanMergePlaneFaces( tmparea, face1->planenum ) ) { AAS_MergePlaneFaces( tmparea, face1->planenum ); nexttmparea = tmparea; num_facemerges++; qprintf( "\r%6d", num_facemerges ); break; } //end if } //end for } //end for qprintf( "\n" ); Log_Write( "%6d plane face merges\r\n", num_facemerges ); } //end of the function AAS_MergeAreaPlaneFaces
//=========================================================================== // find a Quake2 file // returns full path in 'filename' // sets offset and length of the file // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== qboolean FindQuakeFile2( char *basedir, char *gamedir, char *filename, foundfile_t *file ) { int dir, i; //NOTE: 3 is necessary (LCC bug???) char gamedirs[3][MAX_PATH] = {"","",""}; char filedir[MAX_PATH] = ""; // if ( gamedir ) { strncpy( gamedirs[0], gamedir, MAX_PATH ); } strncpy( gamedirs[1], "baseq2", MAX_PATH ); // //find the file in the two game directories for ( dir = 0; dir < 2; dir++ ) { //check if the file is in a directory filedir[0] = 0; if ( basedir && strlen( basedir ) ) { strncpy( filedir, basedir, MAX_PATH ); AppendPathSeperator( filedir, MAX_PATH ); } //end if if ( strlen( gamedirs[dir] ) ) { strncat( filedir, gamedirs[dir], MAX_PATH - strlen( filedir ) ); AppendPathSeperator( filedir, MAX_PATH ); } //end if strncat( filedir, filename, MAX_PATH - strlen( filedir ) ); ConvertPath( filedir ); Log_Write( "accessing %s", filedir ); if ( !access( filedir, 0x04 ) ) { strcpy( file->filename, filedir ); file->length = 0; file->offset = 0; return true; } //end if //check if the file is in a pak?.pak for ( i = 0; i < 10; i++ ) { filedir[0] = 0; if ( basedir && strlen( basedir ) ) { strncpy( filedir, basedir, MAX_PATH ); AppendPathSeperator( filedir, MAX_PATH ); } //end if if ( strlen( gamedirs[dir] ) ) { strncat( filedir, gamedirs[dir], MAX_PATH - strlen( filedir ) ); AppendPathSeperator( filedir, MAX_PATH ); } //end if sprintf( &filedir[strlen( filedir )], "pak%d.pak", i ); if ( !access( filedir, 0x04 ) ) { Log_Write( "searching %s in %s", filename, filedir ); if ( FindFileInPak( filedir, filename, file ) ) { return true; } } //end if } //end for } //end for file->offset = 0; file->length = 0; return false; } //end of the function FindQuakeFile2
//=========================================================================== // NOTE: merge faces and melt edges first // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_GravitationalSubdivision( void ) { Log_Write( "AAS_GravitationalSubdivision\r\n" ); numgravitationalsubdivisions = 0; qprintf( "%6i gravitational subdivisions", numgravitationalsubdivisions ); //start with the head node AAS_GravitationalSubdivision_r( tmpaasworld.nodes ); qprintf( "\n" ); Log_Write( "%6i gravitational subdivisions\r\n", numgravitationalsubdivisions ); } //end of the function AAS_GravitationalSubdivision
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== qboolean AAS_GetFace(winding_t *w, plane_t *p, int side, int *facenum) { int edgenum, i, j; aas_face_t *face; //face zero is a dummy, because of the face index with negative numbers if ((*aasworld).numfaces == 0) { (*aasworld).numfaces = 1; } if ((*aasworld).numfaces >= max_aas.max_faces) { Error("AAS_MAX_FACES = %d", max_aas.max_faces); } //end if face = &(*aasworld).faces[(*aasworld).numfaces]; AAS_GetPlane(p->normal, p->dist, &face->planenum); face->faceflags = 0; face->firstedge = (*aasworld).edgeindexsize; face->frontarea = 0; face->backarea = 0; face->numedges = 0; for (i = 0; i < w->numpoints; i++) { if ((*aasworld).edgeindexsize >= max_aas.max_edgeindexsize) { Error("AAS_MAX_EDGEINDEXSIZE = %d", max_aas.max_edgeindexsize); } //end if j = (i + 1) % w->numpoints; AAS_GetEdge(w->p[i], w->p[j], &edgenum); //if the edge wasn't degenerate if (edgenum) { (*aasworld).edgeindex[(*aasworld).edgeindexsize++] = edgenum; face->numedges++; } //end if else if (verbose) { Log_Write("AAS_GetFace: face %d had degenerate edge %d-%d\r\n", (*aasworld).numfaces, i, j); } //end else } //end for if (face->numedges < 1 #ifdef NOTHREEVERTEXFACES || face->numedges < 3 #endif //NOTHREEVERTEXFACES ) { memset(&(*aasworld).faces[(*aasworld).numfaces], 0, sizeof(aas_face_t)); Log_Write("AAS_GetFace: face %d was tiny\r\n", (*aasworld).numfaces); return false; } //end if *facenum = (*aasworld).numfaces; (*aasworld).numfaces++; return true; } //end of the function AAS_GetFace
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_LadderSubdivision( void ) { Log_Write( "AAS_LadderSubdivision\r\n" ); numladdersubdivisions = 0; qprintf( "%6i ladder subdivisions", numladdersubdivisions ); //start with the head node AAS_LadderSubdivision_r( tmpaasworld.nodes ); // qprintf( "\n" ); Log_Write( "%6i ladder subdivisions\r\n", numladdersubdivisions ); } //end of the function AAS_LadderSubdivision
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_CheckArea(tmp_area_t *tmparea) { int side; tmp_face_t *face; plane_t *plane; vec3_t wcenter, acenter = {0, 0, 0}; vec3_t normal; float n, dist; if (tmparea->invalid) Log_Print("AAS_CheckArea: invalid area\n"); for (n = 0, face = tmparea->tmpfaces; face; face = face->next[side]) { //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; #ifdef L_DEBUG if (WindingError(face->winding)) { Log_Write("AAS_CheckArea: area %d face %d: %s\r\n", tmparea->areanum, face->num, WindingErrorString()); } //end if #endif plane = &mapplanes[face->planenum ^ side]; if (DotProduct(plane->normal, acenter) - plane->dist < 0) { Log_Print("AAS_CheckArea: area %d face %d is flipped\n", tmparea->areanum, face->num); Log_Print("AAS_CheckArea: area %d center is %f %f %f\n", tmparea->areanum, acenter[0], acenter[1], acenter[2]); } //end if //check if the winding plane is the same as the face plane WindingPlane(face->winding, normal, &dist); plane = &mapplanes[face->planenum]; #ifdef L_DEBUG 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("AAS_CheckArea: 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_CheckArea
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_CheckFaceWindingPlane(tmp_face_t *face) { float dist, sign1, sign2; vec3_t normal; plane_t *plane; winding_t *w; //check if the winding plane is the same as the face plane WindingPlane(face->winding, normal, &dist); plane = &mapplanes[face->planenum]; // sign1 = DotProduct(plane->normal, normal); // 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) { VectorInverse(normal); dist = -dist; 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("AAS_CheckFaceWindingPlane: face %d winding plane unequal to face plane\r\n", face->num); // sign2 = DotProduct(plane->normal, normal); if((sign1 < 0 && sign2 > 0) || (sign1 > 0 && sign2 < 0)) { Log_Write("AAS_CheckFaceWindingPlane: face %d winding reversed\r\n", face->num); w = face->winding; face->winding = ReverseWinding(w); FreeWinding(w); } //end if } //end if else { Log_Write("AAS_CheckFaceWindingPlane: face %d winding reversed\r\n", face->num); w = face->winding; face->winding = ReverseWinding(w); FreeWinding(w); } //end else } //end if } //end of the function AAS_CheckFaceWindingPlane
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_StoreFile( char *filename ) { AAS_AllocMaxAAS(); Log_Write( "AAS_StoreFile\r\n" ); // AAS_StoreBoundingBoxes(); // qprintf( "%6d areas stored", 0 ); //start with node 1 because node zero is a dummy AAS_StoreTree_r( tmpaasworld.nodes ); qprintf( "\n" ); Log_Write( "%6d areas stored\r\n", ( *aasworld ).numareas ); ( *aasworld ).loaded = true; } //end of the function AAS_StoreFile
void Mem_DumpLeaks() { struct memrec_s *next; unsigned int totalleak = 0; struct fileleak_s *files = NULL; int i; for (i=0; i<64; i++) { next = allocs[i]; while (next->next != allocs[i]) { struct fileleak_s *find = files; while (find && strcmp(find->name, next->next->file) != 0) { find = find->next; } if (find) { find->size += next->next->size; } else { find = malloc(sizeof(*find)); find->name = strdup(next->next->file); find->size = next->next->size; find->next = files; files = find; } Log_Write(0, "Leaked allocation, type %s\nat %s:%d\npointer %d size %d\n", next->next->objecttype, next->next->file, next->next->line, next->next->pointer, next->next->size); totalleak += next->next->size; next = next->next; } } while(files) { Log_Write(0, "Total leaked in %s: %d\n", files->name, files->size); free(files->name); files = files->next; } Log_Write(0, "Total leaked: %d\n", totalleak); }
//=========================================================================== // NOTE: the original face is invalid after splitting // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_SplitFace(tmp_face_t *face, vec3_t normal, float dist, tmp_face_t **frontface, tmp_face_t **backface) { winding_t *frontw, *backw; // *frontface = *backface = NULL; ClipWindingEpsilon(face->winding, normal, dist, FACECLIP_EPSILON, &frontw, &backw); #ifdef DEBUG // if (frontw) { if (WindingIsTiny(frontw)) { Log_Write("AAS_SplitFace: tiny back face\r\n"); FreeWinding(frontw); frontw = NULL; } //end if } //end if if (backw) { if (WindingIsTiny(backw)) { Log_Write("AAS_SplitFace: tiny back face\r\n"); FreeWinding(backw); backw = NULL; } //end if } //end if #endif //DEBUG //if the winding was split if (frontw) { //check bounds (*frontface) = AAS_AllocTmpFace(); (*frontface)->planenum = face->planenum; (*frontface)->winding = frontw; (*frontface)->faceflags = face->faceflags; } //end if if (backw) { //check bounds (*backface) = AAS_AllocTmpFace(); (*backface)->planenum = face->planenum; (*backface)->winding = backw; (*backface)->faceflags = face->faceflags; } //end if } //end of the function AAS_SplitFace
//=========================================================================== // melt the windings of the faces of all areas // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_MeltAreaFaceWindings( void ) { tmp_area_t *tmparea; int num_windingsplits = 0; Log_Write( "AAS_MeltAreaFaceWindings\r\n" ); qprintf( "%6d edges melted", num_windingsplits ); //NOTE: first convex area (zero) is a dummy for ( tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next ) { num_windingsplits += AAS_MeltFaceWindingsOfArea( tmparea ); qprintf( "\r%6d", num_windingsplits ); } //end for qprintf( "\n" ); Log_Write( "%6d edges melted\r\n", num_windingsplits ); } //end of the function AAS_MeltAreaFaceWindings
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_MergeAreaFaces(void) { int num_facemerges = 0; int side1, side2, restart; tmp_area_t *tmparea, *lasttmparea; tmp_face_t *face1, *face2; Log_Write("AAS_MergeAreaFaces\r\n"); qprintf("%6d face merges", num_facemerges); //NOTE: first convex area is a dummy lasttmparea = tmpaasworld.areas; for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) { restart = false; // if (tmparea->invalid) { continue; } // for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) { side1 = face1->frontarea != tmparea; for (face2 = face1->next[side1]; face2; face2 = face2->next[side2]) { side2 = face2->frontarea != tmparea; //if succesfully merged if (AAS_TryMergeFaces(face1, face2)) { //start over again after merging two faces restart = true; num_facemerges++; qprintf("\r%6d", num_facemerges); AAS_CheckArea(tmparea); break; } //end if } //end for if (restart) { tmparea = lasttmparea; break; } //end if } //end for lasttmparea = tmparea; } //end for qprintf("\n"); Log_Write("%6d face merges\r\n", num_facemerges); } //end of the function AAS_MergeAreaFaces
/* UNC handling * * client can pass us a SSREQ_UNC: this contains both a password and a server * name (in the form \\server\share). We make a connection to it here and * remember the connection so that we can remove it (in ss_cleanconnections) * when the client session terminates. * * We are passed the head of a FNAMELIST in which we should store the connect * name for later cleanup. We return the new head of this list. * * the client will send this request if a unc-style named scan fails * with the SSRESP_BADPASS error. */ PFNAMELIST ss_handleUNC( HANDLE hpipe, long lVersion , LPSTR password, LPSTR server, PFNAMELIST connects) { NETRESOURCE resource; int errorcode; resource.lpRemoteName = server; resource.lpLocalName = NULL; resource.dwType = RESOURCETYPE_DISK; resource.lpProvider = NULL; errorcode = (int)WNetAddConnection2(&resource, password, NULL, 0); if (errorcode == NO_ERROR) { /* remember the connection name */ connects = ss_addtolist(connects, server); /* report success */ ss_sendnewresp( hpipe, lVersion, SSRESP_END , 0, 0, 0, 0, NULL); } else { Log_Write(hlogErrors, "Connect error %d for server %s", GetLastError(), server); dprintf1(("connect error %d for server %s\n", GetLastError(), server)); /* report error */ ss_sendnewresp( hpipe, lVersion, SSRESP_ERROR , 0, 0, 0, 0, NULL); } return(connects); } /* ss_handleUNC */
//=========================================================================== // // 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_Write("%6d areas checked for shared face flipping\r\n", i); } //end of the function AAS_FlipSharedFaces
//=========================================================================== // // 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 AAS_CreateAreas( node_t *node ) { Log_Write( "AAS_CreateAreas\r\n" ); qprintf( "%6d areas created", 0 ); numGroundOnlyFreed = 0; numTinyFreed = 0; tmpaasworld.nodes = AAS_CreateAreas_r( node ); qprintf( "\n" ); // Log_Print("%6d non-grounded areas freed\n", numGroundOnlyFreed); // Log_Write("%6d non-grounded areas freed\n", numGroundOnlyFreed); // Log_Print("%6d tiny areas freed\n", numTinyFreed); // Log_Write("%6d tiny areas freed\n", numTinyFreed); Log_Write( "%6d areas created\r\n", tmpaasworld.numareas ); } //end of the function AAS_CreateAreas
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void BotDumpCharacter( bot_character_t *ch ) { int i; Log_Write( "%s", ch->filename ); Log_Write( "skill %d\n", ch->skill ); Log_Write( "{\n" ); for ( i = 0; i < MAX_CHARACTERISTICS; i++ ) { switch ( ch->c[ i ].type ) { case CT_INTEGER: Log_Write( " %4d %d\n", i, ch->c[ i ].value.integer ); break; case CT_FLOAT: Log_Write( " %4d %f\n", i, ch->c[ i ].value._float ); break; case CT_STRING: Log_Write( " %4d %s\n", i, ch->c[ i ].value.string ); break; } //end case } //end for Log_Write( "}\n" ); } //end of the function BotDumpCharacter
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_CreateAreaSettings(void) { int i, flags, side, numgrounded, numladderareas, numliquidareas; tmp_face_t *face; tmp_area_t *tmparea; numgrounded = 0; numladderareas = 0; numliquidareas = 0; Log_Write("AAS_CreateAreaSettings\r\n"); i = 0; qprintf("%6d areas provided with settings", i); for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) { //if the area is invalid there no need to create settings for it if (tmparea->invalid) continue; tmparea->settings = (tmp_areasettings_t *) GetClearedMemory(sizeof(tmp_areasettings_t)); tmparea->settings->contents = tmparea->contents; tmparea->settings->modelnum = tmparea->modelnum; flags = 0; for (face = tmparea->tmpfaces; face; face = face->next[side]) { side = face->frontarea != tmparea; flags |= face->faceflags; } //end for tmparea->settings->areaflags = 0; if (flags & FACE_GROUND) { tmparea->settings->areaflags |= AREA_GROUNDED; numgrounded++; } //end if if (flags & FACE_LADDER) { tmparea->settings->areaflags |= AREA_LADDER; numladderareas++; } //end if if (tmparea->contents & (AREACONTENTS_WATER | AREACONTENTS_SLIME | AREACONTENTS_LAVA)) { tmparea->settings->areaflags |= AREA_LIQUID; numliquidareas++; } //end if //presence type of the area tmparea->settings->presencetype = tmparea->presencetype; // qprintf("\r%6d", ++i); } //end for qprintf("\n"); #ifdef AASINFO Log_Print("%6d grounded areas\n", numgrounded); Log_Print("%6d ladder areas\n", numladderareas); Log_Print("%6d liquid areas\n", numliquidareas); #endif //AASINFO } //end of the function AAS_CreateAreaSettings
void PrintContents( int contents ) { int i; for ( i = 0; contentnames[i].value; i++ ) { if ( contents & contentnames[i].value ) { Log_Write( "%s,", contentnames[i].name ); } //end if } //end for } //end of the function PrintContents
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== int AAS_TryMergeFaces( tmp_face_t *face1, tmp_face_t *face2 ) { winding_t *neww; #ifdef DEBUG if ( !face1->winding ) { Error( "face1 %d without winding", face1->num ); } if ( !face2->winding ) { Error( "face2 %d without winding", face2->num ); } #endif //DEBUG // if ( face1->faceflags != face2->faceflags ) { return false; } //NOTE: if the front or back area is zero this doesn't mean there's //a real area. It means there's solid at that side of the face //if both faces have the same front area if ( face1->frontarea == face2->frontarea ) { //if both faces have the same back area if ( face1->backarea == face2->backarea ) { //if the faces are in the same plane if ( face1->planenum == face2->planenum ) { //if they have both a front and a back area (no solid on either side) if ( face1->frontarea && face1->backarea ) { neww = MergeWindings( face1->winding, face2->winding, mapplanes[face1->planenum].normal ); } //end if else { //this function is to be found in l_poly.c neww = TryMergeWinding( face1->winding, face2->winding, mapplanes[face1->planenum].normal ); } //end else if ( neww ) { FreeWinding( face1->winding ); face1->winding = neww; if ( face2->frontarea ) { AAS_RemoveFaceFromArea( face2, face2->frontarea ); } if ( face2->backarea ) { AAS_RemoveFaceFromArea( face2, face2->backarea ); } AAS_FreeTmpFace( face2 ); return true; } //end if } //end if else if ( ( face1->planenum & ~1 ) == ( face2->planenum & ~1 ) ) { Log_Write( "face %d and %d, same front and back area but flipped planes\r\n", face1->num, face2->num ); } //end if } //end if } //end if return false; } //end of the function AAS_TryMergeFaces
void BotDumpGoalStack( int goalstate ) { bot_goalstate_t* gs = BotGoalStateFromHandle( goalstate ); if ( !gs ) { return; } for ( int i = 1; i <= gs->goalstacktop; i++ ) { char name[ 32 ]; BotGoalName( gs->goalstack[ i ].number, name, 32 ); Log_Write( "%d: %s", i, name ); } }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void BotImport_Print(int type, char *fmt, ...) { va_list argptr; char buf[1024]; va_start(argptr, fmt); vsprintf(buf, fmt, argptr); printf(buf); if (buf[0] != '\r') Log_Write(buf); va_end(argptr); } //end of the function BotImport_Print
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Com_DPrintf(char *fmt, ...) { va_list argptr; char buf[1024]; va_start(argptr, fmt); vsprintf(buf, fmt, argptr); printf(buf); if (buf[0] != '\r') Log_Write(buf); va_end(argptr); } //end of the function Com_DPrintf
// index to find the weight function of an iteminfo static int* ItemWeightIndex( weightconfig_t* iwc, itemconfig_t* ic ) { //initialize item weight index int* index = ( int* )Mem_ClearedAlloc( sizeof ( int ) * ic->numiteminfo ); for ( int i = 0; i < ic->numiteminfo; i++ ) { index[ i ] = FindFuzzyWeight( iwc, ic->iteminfo[ i ].classname ); if ( index[ i ] < 0 ) { Log_Write( "item info %d \"%s\" has no fuzzy weight\r\n", i, ic->iteminfo[ i ].classname ); } //end if } //end for return index; }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== int AAS_UpdatePortal(int areanum, int clusternum) { int portalnum; aas_portal_t *portal; aas_cluster_t *cluster; //find the portal of the area for (portalnum = 1; portalnum < aasworld.numportals; portalnum++) { if (aasworld.portals[portalnum].areanum == areanum) break; } //end for // if (portalnum == aasworld.numportals) { AAS_Error("no portal of area %d", areanum); return qtrue; } //end if // portal = &aasworld.portals[portalnum]; //if the portal is already fully updated if (portal->frontcluster == clusternum) return qtrue; if (portal->backcluster == clusternum) return qtrue; //if the portal has no front cluster yet if (!portal->frontcluster) { portal->frontcluster = clusternum; } //end if //if the portal has no back cluster yet else if (!portal->backcluster) { portal->backcluster = clusternum; } //end else if else { //remove the cluster portal flag contents aasworld.areasettings[areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL; Log_Write("portal area %d is seperating more than two clusters\r\n", areanum); return qfalse; } //end else if (aasworld.portalindexsize >= AAS_MAX_PORTALINDEXSIZE) { AAS_Error("AAS_MAX_PORTALINDEXSIZE"); return qtrue; } //end if //set the area cluster number to the negative portal number aasworld.areasettings[areanum].cluster = -portalnum; //add the portal to the cluster using the portal index cluster = &aasworld.clusters[clusternum]; aasworld.portalindex[cluster->firstportal + cluster->numportals] = portalnum; aasworld.portalindexsize++; cluster->numportals++; return qtrue; } //end of the function AAS_UpdatePortal
void BotDumpAvoidGoals( int goalstate ) { bot_goalstate_t* gs = BotGoalStateFromHandle( goalstate ); if ( !gs ) { return; } for ( int i = 0; i < MAX_AVOIDGOALS; i++ ) { if ( gs->avoidgoaltimes[ i ] >= AAS_Time() ) { char name[ 32 ]; BotGoalName( gs->avoidgoals[ i ], name, 32 ); Log_Write( "avoid goal %s, number %d for %f seconds", name, gs->avoidgoals[ i ], gs->avoidgoaltimes[ i ] - AAS_Time() ); } } }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== int AAS_TestPortals(void) { int i; aas_portal_t *portal; for (i = 1; i < aasworld.numportals; i++) { portal = &aasworld.portals[i]; if (!portal->frontcluster) { aasworld.areasettings[portal->areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL; Log_Write("portal area %d has no front cluster\r\n", portal->areanum); return qfalse; } //end if if (!portal->backcluster) { aasworld.areasettings[portal->areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL; Log_Write("portal area %d has no back cluster\r\n", portal->areanum); return qfalse; } //end if } //end for return qtrue; } //end of the function