Skip to content
Browse files

Convert Windows line endings to UNIX line endings.

  • Loading branch information...
1 parent 6b5cfd9 commit 796b185d25cc00e25242af809c414e80af4bd330 @bnoordhuis committed
Showing with 13,597 additions and 13,597 deletions.
  1. +75 −75 Conscript
  2. +114 −114 Makefile
  3. +390 −390 aas_areamerging.c
  4. +24 −24 aas_areamerging.h
  5. +252 −252 aas_cfg.c
  6. +73 −73 aas_cfg.h
  7. +1,142 −1,142 aas_create.c
  8. +136 −136 aas_create.h
  9. +108 −108 aas_edgemelting.c
  10. +24 −24 aas_edgemelting.h
  11. +282 −282 aas_facemerging.c
  12. +24 −24 aas_facemerging.h
  13. +549 −549 aas_file.c
  14. +25 −25 aas_file.h
  15. +656 −656 aas_gsubdiv.c
  16. +25 −25 aas_gsubdiv.h
  17. +849 −849 aas_map.c
  18. +23 −23 aas_map.h
  19. +89 −89 aas_prunenodes.c
  20. +24 −24 aas_prunenodes.h
  21. +1,082 −1,082 aas_store.c
  22. +107 −107 aas_store.h
  23. +252 −252 aasfile.h
  24. +292 −292 be_aas_bspc.c
  25. +23 −23 be_aas_bspc.h
  26. +1,871 −1,871 brushbsp.c
  27. +991 −991 bspc.c
  28. +28 −28 bspc.sln
  29. +1,381 −1,381 bspc.vcproj
  30. +84 −84 cfgq3.c
  31. +1,005 −1,005 csg.c
  32. +978 −978 faces.c
  33. +232 −232 gldraw.c
  34. +149 −149 glfile.c
  35. +180 −180 l_bsp_ent.c
  36. +58 −58 l_bsp_ent.h
Sorry, we could not display the entire diff because it was too big.
View
150 Conscript
@@ -1,75 +1,75 @@
-# bspc compile
-
-Import qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
-
-@BSPC_FILES = qw(
- aas_areamerging.c
- aas_cfg.c
- aas_create.c
- aas_edgemelting.c
- aas_facemerging.c
- aas_file.c
- aas_gsubdiv.c
- aas_map.c
- aas_prunenodes.c
- aas_store.c
- be_aas_bspc.c
- ../botlib/be_aas_bspq3.c
- ../botlib/be_aas_cluster.c
- ../botlib/be_aas_move.c
- ../botlib/be_aas_optimize.c
- ../botlib/be_aas_reach.c
- ../botlib/be_aas_sample.c
- brushbsp.c
- bspc.c
- ../qcommon/cm_load.c
- ../qcommon/cm_patch.c
- ../qcommon/cm_test.c
- ../qcommon/cm_trace.c
- csg.c
- glfile.c
- l_bsp_ent.c
- l_bsp_hl.c
- l_bsp_q1.c
- l_bsp_q2.c
- l_bsp_q3.c
- l_bsp_sin.c
- l_cmd.c
- ../botlib/l_libvar.c
- l_log.c
- l_math.c
- l_mem.c
- l_poly.c
- ../botlib/l_precomp.c
- l_qfiles.c
- ../botlib/l_script.c
- ../botlib/l_struct.c
- l_threads.c
- l_utils.c
- leakfile.c
- map.c
- map_hl.c
- map_q1.c
- map_q2.c
- map_q3.c
- map_sin.c
- ../qcommon/md4.c
- nodraw.c
- portals.c
- textures.c
- tree.c
- ../qcommon/unzip.c
- );
-$BSPC_REF = \@BSPC_FILES;
-
-$env = new cons(
- CC => $CC,
- CXX => $CXX,
- LINK => $LINK,
- CFLAGS => $BSPC_BASE_CFLAGS,
- LIBS => '-ldl -lm -lpthread'
-);
-
-Program $env 'bspc', @$BSPC_REF;
-# this should install to Q3 or something?
-Install $env $INSTALL_DIR, 'bspc';
+# bspc compile
+
+Import qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
+
+@BSPC_FILES = qw(
+ aas_areamerging.c
+ aas_cfg.c
+ aas_create.c
+ aas_edgemelting.c
+ aas_facemerging.c
+ aas_file.c
+ aas_gsubdiv.c
+ aas_map.c
+ aas_prunenodes.c
+ aas_store.c
+ be_aas_bspc.c
+ ../botlib/be_aas_bspq3.c
+ ../botlib/be_aas_cluster.c
+ ../botlib/be_aas_move.c
+ ../botlib/be_aas_optimize.c
+ ../botlib/be_aas_reach.c
+ ../botlib/be_aas_sample.c
+ brushbsp.c
+ bspc.c
+ ../qcommon/cm_load.c
+ ../qcommon/cm_patch.c
+ ../qcommon/cm_test.c
+ ../qcommon/cm_trace.c
+ csg.c
+ glfile.c
+ l_bsp_ent.c
+ l_bsp_hl.c
+ l_bsp_q1.c
+ l_bsp_q2.c
+ l_bsp_q3.c
+ l_bsp_sin.c
+ l_cmd.c
+ ../botlib/l_libvar.c
+ l_log.c
+ l_math.c
+ l_mem.c
+ l_poly.c
+ ../botlib/l_precomp.c
+ l_qfiles.c
+ ../botlib/l_script.c
+ ../botlib/l_struct.c
+ l_threads.c
+ l_utils.c
+ leakfile.c
+ map.c
+ map_hl.c
+ map_q1.c
+ map_q2.c
+ map_q3.c
+ map_sin.c
+ ../qcommon/md4.c
+ nodraw.c
+ portals.c
+ textures.c
+ tree.c
+ ../qcommon/unzip.c
+ );
+$BSPC_REF = \@BSPC_FILES;
+
+$env = new cons(
+ CC => $CC,
+ CXX => $CXX,
+ LINK => $LINK,
+ CFLAGS => $BSPC_BASE_CFLAGS,
+ LIBS => '-ldl -lm -lpthread'
+);
+
+Program $env 'bspc', @$BSPC_REF;
+# this should install to Q3 or something?
+Install $env $INSTALL_DIR, 'bspc';
View
228 Makefile
@@ -1,114 +1,114 @@
-#
-# Makefile for the BSPC tool for the Gladiator Bot
-# Intended for gcc/Linux
-#
-# TTimo 5/15/2001
-# some cleanup .. only used on i386 for GtkRadiant setups AFAIK .. removing the i386 tag
-# TODO: the intermediate object files should go into their own directory
-# specially for ../botlib and ../qcommon, the compilation flags on those might not be what you expect
-
-#ARCH=i386
-CC=gcc
-BASE_CFLAGS=-Dstricmp=strcasecmp
-
-#use these cflags to optimize it
-CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
- -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
- -malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC
-#use these when debugging
-#CFLAGS=$(BASE_CFLAGS) -g
-
-LDFLAGS=-ldl -lm -lpthread
-
-DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
-
-#############################################################################
-# SETUP AND BUILD BSPC
-#############################################################################
-
-.c.o:
- $(DO_CC)
-
-GAME_OBJS = \
- _files.o\
- aas_areamerging.o\
- aas_cfg.o\
- aas_create.o\
- aas_edgemelting.o\
- aas_facemerging.o\
- aas_file.o\
- aas_gsubdiv.o\
- aas_map.o\
- aas_prunenodes.o\
- aas_store.o\
- be_aas_bspc.o\
- ../botlib/be_aas_bspq3.o\
- ../botlib/be_aas_cluster.o\
- ../botlib/be_aas_move.o\
- ../botlib/be_aas_optimize.o\
- ../botlib/be_aas_reach.o\
- ../botlib/be_aas_sample.o\
- brushbsp.o\
- bspc.o\
- ../qcommon/cm_load.o\
- ../qcommon/cm_patch.o\
- ../qcommon/cm_test.o\
- ../qcommon/cm_trace.o\
- csg.o\
- glfile.o\
- l_bsp_ent.o\
- l_bsp_hl.o\
- l_bsp_q1.o\
- l_bsp_q2.o\
- l_bsp_q3.o\
- l_bsp_sin.o\
- l_cmd.o\
- ../botlib/l_libvar.o\
- l_log.o\
- l_math.o\
- l_mem.o\
- l_poly.o\
- ../botlib/l_precomp.o\
- l_qfiles.o\
- ../botlib/l_script.o\
- ../botlib/l_struct.o\
- l_threads.o\
- l_utils.o\
- leakfile.o\
- map.o\
- map_hl.o\
- map_q1.o\
- map_q2.o\
- map_q3.o\
- map_sin.o\
- ../qcommon/md4.o\
- nodraw.o\
- portals.o\
- textures.o\
- tree.o\
- ../qcommon/unzip.o
-
- #tetrahedron.o
-
-bspc : $(GAME_OBJS)
- $(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS)
- strip $@
-
-
-#############################################################################
-# MISC
-#############################################################################
-
-clean:
- -rm -f $(GAME_OBJS)
-
-depend:
- gcc -MM $(GAME_OBJS:.o=.c)
-
-#install:
-# cp bspci386 ..
-
-#
-# From "make depend"
-#
-
+#
+# Makefile for the BSPC tool for the Gladiator Bot
+# Intended for gcc/Linux
+#
+# TTimo 5/15/2001
+# some cleanup .. only used on i386 for GtkRadiant setups AFAIK .. removing the i386 tag
+# TODO: the intermediate object files should go into their own directory
+# specially for ../botlib and ../qcommon, the compilation flags on those might not be what you expect
+
+#ARCH=i386
+CC=gcc
+BASE_CFLAGS=-Dstricmp=strcasecmp
+
+#use these cflags to optimize it
+CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \
+ -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
+ -malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC
+#use these when debugging
+#CFLAGS=$(BASE_CFLAGS) -g
+
+LDFLAGS=-ldl -lm -lpthread
+
+DO_CC=$(CC) $(CFLAGS) -o $@ -c $<
+
+#############################################################################
+# SETUP AND BUILD BSPC
+#############################################################################
+
+.c.o:
+ $(DO_CC)
+
+GAME_OBJS = \
+ _files.o\
+ aas_areamerging.o\
+ aas_cfg.o\
+ aas_create.o\
+ aas_edgemelting.o\
+ aas_facemerging.o\
+ aas_file.o\
+ aas_gsubdiv.o\
+ aas_map.o\
+ aas_prunenodes.o\
+ aas_store.o\
+ be_aas_bspc.o\
+ ../botlib/be_aas_bspq3.o\
+ ../botlib/be_aas_cluster.o\
+ ../botlib/be_aas_move.o\
+ ../botlib/be_aas_optimize.o\
+ ../botlib/be_aas_reach.o\
+ ../botlib/be_aas_sample.o\
+ brushbsp.o\
+ bspc.o\
+ ../qcommon/cm_load.o\
+ ../qcommon/cm_patch.o\
+ ../qcommon/cm_test.o\
+ ../qcommon/cm_trace.o\
+ csg.o\
+ glfile.o\
+ l_bsp_ent.o\
+ l_bsp_hl.o\
+ l_bsp_q1.o\
+ l_bsp_q2.o\
+ l_bsp_q3.o\
+ l_bsp_sin.o\
+ l_cmd.o\
+ ../botlib/l_libvar.o\
+ l_log.o\
+ l_math.o\
+ l_mem.o\
+ l_poly.o\
+ ../botlib/l_precomp.o\
+ l_qfiles.o\
+ ../botlib/l_script.o\
+ ../botlib/l_struct.o\
+ l_threads.o\
+ l_utils.o\
+ leakfile.o\
+ map.o\
+ map_hl.o\
+ map_q1.o\
+ map_q2.o\
+ map_q3.o\
+ map_sin.o\
+ ../qcommon/md4.o\
+ nodraw.o\
+ portals.o\
+ textures.o\
+ tree.o\
+ ../qcommon/unzip.o
+
+ #tetrahedron.o
+
+bspc : $(GAME_OBJS)
+ $(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS)
+ strip $@
+
+
+#############################################################################
+# MISC
+#############################################################################
+
+clean:
+ -rm -f $(GAME_OBJS)
+
+depend:
+ gcc -MM $(GAME_OBJS:.o=.c)
+
+#install:
+# cp bspci386 ..
+
+#
+# From "make depend"
+#
+
View
780 aas_areamerging.c
@@ -1,390 +1,390 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#include "qbsp.h"
-#include "../botlib/aasfile.h"
-#include "aas_create.h"
-#include "aas_store.h"
-
-#define CONVEX_EPSILON 0.3
-
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-tmp_node_t *AAS_RefreshMergedTree_r(tmp_node_t *tmpnode)
-{
- tmp_area_t *tmparea;
-
- //if this is a solid leaf
- if (!tmpnode) return NULL;
- //if this is an area leaf
- if (tmpnode->tmparea)
- {
- tmparea = tmpnode->tmparea;
- while(tmparea->mergedarea) tmparea = tmparea->mergedarea;
- tmpnode->tmparea = tmparea;
- return tmpnode;
- } //end if
- //do the children recursively
- tmpnode->children[0] = AAS_RefreshMergedTree_r(tmpnode->children[0]);
- tmpnode->children[1] = AAS_RefreshMergedTree_r(tmpnode->children[1]);
- return tmpnode;
-} //end of the function AAS_RefreshMergedTree_r
-//===========================================================================
-// returns true if the two given faces would create a non-convex area at
-// the given sides, otherwise false is returned
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int NonConvex(tmp_face_t *face1, tmp_face_t *face2, int side1, int side2)
-{
- int i;
- winding_t *w1, *w2;
- plane_t *plane1, *plane2;
-
- w1 = face1->winding;
- w2 = face2->winding;
-
- plane1 = &mapplanes[face1->planenum ^ side1];
- plane2 = &mapplanes[face2->planenum ^ side2];
-
- //check if one of the points of face1 is at the back of the plane of face2
- for (i = 0; i < w1->numpoints; i++)
- {
- if (DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return true;
- } //end for
- //check if one of the points of face2 is at the back of the plane of face1
- for (i = 0; i < w2->numpoints; i++)
- {
- if (DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return true;
- } //end for
-
- return false;
-} //end of the function NonConvex
-//===========================================================================
-// try to merge the areas at both sides of the given face
-//
-// Parameter: seperatingface : face that seperates two areas
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_TryMergeFaceAreas(tmp_face_t *seperatingface)
-{
- int side1, side2, area1faceflags, area2faceflags;
- tmp_area_t *tmparea1, *tmparea2, *newarea;
- tmp_face_t *face1, *face2, *nextface1, *nextface2;
-
- tmparea1 = seperatingface->frontarea;
- tmparea2 = seperatingface->backarea;
-
- //areas must have the same presence type
- if (tmparea1->presencetype != tmparea2->presencetype) return false;
- //areas must have the same area contents
- if (tmparea1->contents != tmparea2->contents) return false;
- //areas must have the same bsp model inside (or both none)
- if (tmparea1->modelnum != tmparea2->modelnum) return false;
-
- area1faceflags = 0;
- area2faceflags = 0;
- for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1])
- {
- side1 = (face1->frontarea != tmparea1);
- //debug: check if the area belongs to the area
- if (face1->frontarea != tmparea1 &&
- face1->backarea != tmparea1) Error("face does not belong to area1");
- //just continue if the face is seperating the two areas
- //NOTE: a result of this is that ground and gap areas can
- // be merged if the seperating face is the gap
- if ((face1->frontarea == tmparea1 &&
- face1->backarea == tmparea2) ||
- (face1->frontarea == tmparea2 &&
- face1->backarea == tmparea1)) continue;
- //get area1 face flags
- area1faceflags |= face1->faceflags;
- if (AAS_GapFace(face1, side1)) area1faceflags |= FACE_GAP;
- //
- for (face2 = tmparea2->tmpfaces; face2; face2 = face2->next[side2])
- {
- side2 = (face2->frontarea != tmparea2);
- //debug: check if the area belongs to the area
- if (face2->frontarea != tmparea2 &&
- face2->backarea != tmparea2) Error("face does not belong to area2");
- //just continue if the face is seperating the two areas
- //NOTE: a result of this is that ground and gap areas can
- // be merged if the seperating face is the gap
- if ((face2->frontarea == tmparea1 &&
- face2->backarea == tmparea2) ||
- (face2->frontarea == tmparea2 &&
- face2->backarea == tmparea1)) continue;
- //get area2 face flags
- area2faceflags |= face2->faceflags;
- if (AAS_GapFace(face2, side2)) area2faceflags |= FACE_GAP;
- //if the two faces would create a non-convex area
- if (NonConvex(face1, face2, side1, side2)) return false;
- } //end for
- } //end for
- //if one area has gap faces (that aren't seperating the two areas)
- //and the other has ground faces (that aren't seperating the two areas),
- //the areas can't be merged
- if (((area1faceflags & FACE_GROUND) && (area2faceflags & FACE_GAP)) ||
- ((area2faceflags & FACE_GROUND) && (area1faceflags & FACE_GAP)))
- {
-// Log_Print(" can't merge: ground/gap\n");
- return false;
- } //end if
-
-// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum, numfaces);
-// return false;
- //
- //AAS_CheckArea(tmparea1);
- //AAS_CheckArea(tmparea2);
- //create the new area
- newarea = AAS_AllocTmpArea();
- newarea->presencetype = tmparea1->presencetype;
- newarea->contents = tmparea1->contents;
- newarea->modelnum = tmparea1->modelnum;
- newarea->tmpfaces = NULL;
-
- //add all the faces (except the seperating ones) from the first area
- //to the new area
- for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
- {
- side1 = (face1->frontarea != tmparea1);
- nextface1 = face1->next[side1];
- //don't add seperating faces
- if ((face1->frontarea == tmparea1 &&
- face1->backarea == tmparea2) ||
- (face1->frontarea == tmparea2 &&
- face1->backarea == tmparea1))
- {
- continue;
- } //end if
- //
- AAS_RemoveFaceFromArea(face1, tmparea1);
- AAS_AddFaceSideToArea(face1, side1, newarea);
- } //end for
- //add all the faces (except the seperating ones) from the second area
- //to the new area
- for (face2 = tmparea2->tmpfaces; face2; face2 = nextface2)
- {
- side2 = (face2->frontarea != tmparea2);
- nextface2 = face2->next[side2];
- //don't add seperating faces
- if ((face2->frontarea == tmparea1 &&
- face2->backarea == tmparea2) ||
- (face2->frontarea == tmparea2 &&
- face2->backarea == tmparea1))
- {
- continue;
- } //end if
- //
- AAS_RemoveFaceFromArea(face2, tmparea2);
- AAS_AddFaceSideToArea(face2, side2, newarea);
- } //end for
- //free all shared faces
- for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
- {
- side1 = (face1->frontarea != tmparea1);
- nextface1 = face1->next[side1];
- //
- AAS_RemoveFaceFromArea(face1, face1->frontarea);
- AAS_RemoveFaceFromArea(face1, face1->backarea);
- AAS_FreeTmpFace(face1);
- } //end for
- //
- tmparea1->mergedarea = newarea;
- tmparea1->invalid = true;
- tmparea2->mergedarea = newarea;
- tmparea2->invalid = true;
- //
- AAS_CheckArea(newarea);
- AAS_FlipAreaFaces(newarea);
-// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum);
- return true;
-} //end of the function AAS_TryMergeFaceAreas
-//===========================================================================
-// try to merge areas
-// merged areas are added to the end of the convex area list so merging
-// will be tried for those areas as well
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: tmpaasworld
-//===========================================================================
-/*
-void AAS_MergeAreas(void)
-{
- int side, nummerges;
- tmp_area_t *tmparea, *othertmparea;
- tmp_face_t *face;
-
- nummerges = 0;
- Log_Write("AAS_MergeAreas\r\n");
- qprintf("%6d areas merged", 1);
- //first merge grounded areas only
- //NOTE: this is useless because the area settings aren't available yet
- for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
- {
-// Log_Print("checking area %d\n", i);
- //if the area is invalid
- if (tmparea->invalid)
- {
-// Log_Print(" area invalid\n");
- continue;
- } //end if
- //
-// if (!(tmparea->settings->areaflags & AREA_GROUNDED)) continue;
- //
- for (face = tmparea->tmpfaces; face; face = face->next[side])
- {
- side = (face->frontarea != tmparea);
- //if the face has both a front and back area
- if (face->frontarea && face->backarea)
- {
- //
- if (face->frontarea == tmparea) othertmparea = face->backarea;
- else othertmparea = face->frontarea;
-// if (!(othertmparea->settings->areaflags & AREA_GROUNDED)) continue;
-// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
- if (AAS_TryMergeFaceAreas(face))
- {
- qprintf("\r%6d", ++nummerges);
- break;
- } //end if
- } //end if
- } //end for
- } //end for
- //merge all areas
- for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
- {
-// Log_Print("checking area %d\n", i);
- //if the area is invalid
- if (tmparea->invalid)
- {
-// Log_Print(" area invalid\n");
- continue;
- } //end if
- //
- for (face = tmparea->tmpfaces; face; face = face->next[side])
- {
- side = (face->frontarea != tmparea);
- //if the face has both a front and back area
- if (face->frontarea && face->backarea)
- {
-// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
- if (AAS_TryMergeFaceAreas(face))
- {
- qprintf("\r%6d", ++nummerges);
- break;
- } //end if
- } //end if
- } //end for
- } //end for
- Log_Print("\r%6d areas merged\n", nummerges);
- //refresh the merged tree
- AAS_RefreshMergedTree_r(tmpaasworld.nodes);
-} //end of the function AAS_MergeAreas*/
-
-int AAS_GroundArea(tmp_area_t *tmparea)
-{
- tmp_face_t *face;
- int side;
-
- for (face = tmparea->tmpfaces; face; face = face->next[side])
- {
- side = (face->frontarea != tmparea);
- if (face->faceflags & FACE_GROUND) return true;
- } //end for
- return false;
-} //end of the function AAS_GroundArea
-
-void AAS_MergeAreas(void)
-{
- int side, nummerges, merges, groundfirst;
- tmp_area_t *tmparea, *othertmparea;
- tmp_face_t *face;
-
- nummerges = 0;
- Log_Write("AAS_MergeAreas\r\n");
- qprintf("%6d areas merged", 1);
- //
- groundfirst = true;
- //for (i = 0; i < 4 || merges; i++)
- while(1)
- {
- //if (i < 2) groundfirst = true;
- //else groundfirst = false;
- //
- merges = 0;
- //first merge grounded areas only
- for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
- {
- //if the area is invalid
- if (tmparea->invalid)
- {
- continue;
- } //end if
- //
- if (groundfirst)
- {
- if (!AAS_GroundArea(tmparea)) continue;
- } //end if
- //
- for (face = tmparea->tmpfaces; face; face = face->next[side])
- {
- side = (face->frontarea != tmparea);
- //if the face has both a front and back area
- if (face->frontarea && face->backarea)
- {
- //
- if (face->frontarea == tmparea) othertmparea = face->backarea;
- else othertmparea = face->frontarea;
- //
- if (groundfirst)
- {
- if (!AAS_GroundArea(othertmparea)) continue;
- } //end if
- if (AAS_TryMergeFaceAreas(face))
- {
- qprintf("\r%6d", ++nummerges);
- merges++;
- break;
- } //end if
- } //end if
- } //end for
- } //end for
- if (!merges)
- {
- if (groundfirst) groundfirst = false;
- else break;
- } //end if
- } //end for
- qprintf("\n");
- Log_Write("%6d areas merged\r\n", nummerges);
- //refresh the merged tree
- AAS_RefreshMergedTree_r(tmpaasworld.nodes);
-} //end of the function AAS_MergeAreas
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#include "qbsp.h"
+#include "../botlib/aasfile.h"
+#include "aas_create.h"
+#include "aas_store.h"
+
+#define CONVEX_EPSILON 0.3
+
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+tmp_node_t *AAS_RefreshMergedTree_r(tmp_node_t *tmpnode)
+{
+ tmp_area_t *tmparea;
+
+ //if this is a solid leaf
+ if (!tmpnode) return NULL;
+ //if this is an area leaf
+ if (tmpnode->tmparea)
+ {
+ tmparea = tmpnode->tmparea;
+ while(tmparea->mergedarea) tmparea = tmparea->mergedarea;
+ tmpnode->tmparea = tmparea;
+ return tmpnode;
+ } //end if
+ //do the children recursively
+ tmpnode->children[0] = AAS_RefreshMergedTree_r(tmpnode->children[0]);
+ tmpnode->children[1] = AAS_RefreshMergedTree_r(tmpnode->children[1]);
+ return tmpnode;
+} //end of the function AAS_RefreshMergedTree_r
+//===========================================================================
+// returns true if the two given faces would create a non-convex area at
+// the given sides, otherwise false is returned
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int NonConvex(tmp_face_t *face1, tmp_face_t *face2, int side1, int side2)
+{
+ int i;
+ winding_t *w1, *w2;
+ plane_t *plane1, *plane2;
+
+ w1 = face1->winding;
+ w2 = face2->winding;
+
+ plane1 = &mapplanes[face1->planenum ^ side1];
+ plane2 = &mapplanes[face2->planenum ^ side2];
+
+ //check if one of the points of face1 is at the back of the plane of face2
+ for (i = 0; i < w1->numpoints; i++)
+ {
+ if (DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return true;
+ } //end for
+ //check if one of the points of face2 is at the back of the plane of face1
+ for (i = 0; i < w2->numpoints; i++)
+ {
+ if (DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return true;
+ } //end for
+
+ return false;
+} //end of the function NonConvex
+//===========================================================================
+// try to merge the areas at both sides of the given face
+//
+// Parameter: seperatingface : face that seperates two areas
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_TryMergeFaceAreas(tmp_face_t *seperatingface)
+{
+ int side1, side2, area1faceflags, area2faceflags;
+ tmp_area_t *tmparea1, *tmparea2, *newarea;
+ tmp_face_t *face1, *face2, *nextface1, *nextface2;
+
+ tmparea1 = seperatingface->frontarea;
+ tmparea2 = seperatingface->backarea;
+
+ //areas must have the same presence type
+ if (tmparea1->presencetype != tmparea2->presencetype) return false;
+ //areas must have the same area contents
+ if (tmparea1->contents != tmparea2->contents) return false;
+ //areas must have the same bsp model inside (or both none)
+ if (tmparea1->modelnum != tmparea2->modelnum) return false;
+
+ area1faceflags = 0;
+ area2faceflags = 0;
+ for (face1 = tmparea1->tmpfaces; face1; face1 = face1->next[side1])
+ {
+ side1 = (face1->frontarea != tmparea1);
+ //debug: check if the area belongs to the area
+ if (face1->frontarea != tmparea1 &&
+ face1->backarea != tmparea1) Error("face does not belong to area1");
+ //just continue if the face is seperating the two areas
+ //NOTE: a result of this is that ground and gap areas can
+ // be merged if the seperating face is the gap
+ if ((face1->frontarea == tmparea1 &&
+ face1->backarea == tmparea2) ||
+ (face1->frontarea == tmparea2 &&
+ face1->backarea == tmparea1)) continue;
+ //get area1 face flags
+ area1faceflags |= face1->faceflags;
+ if (AAS_GapFace(face1, side1)) area1faceflags |= FACE_GAP;
+ //
+ for (face2 = tmparea2->tmpfaces; face2; face2 = face2->next[side2])
+ {
+ side2 = (face2->frontarea != tmparea2);
+ //debug: check if the area belongs to the area
+ if (face2->frontarea != tmparea2 &&
+ face2->backarea != tmparea2) Error("face does not belong to area2");
+ //just continue if the face is seperating the two areas
+ //NOTE: a result of this is that ground and gap areas can
+ // be merged if the seperating face is the gap
+ if ((face2->frontarea == tmparea1 &&
+ face2->backarea == tmparea2) ||
+ (face2->frontarea == tmparea2 &&
+ face2->backarea == tmparea1)) continue;
+ //get area2 face flags
+ area2faceflags |= face2->faceflags;
+ if (AAS_GapFace(face2, side2)) area2faceflags |= FACE_GAP;
+ //if the two faces would create a non-convex area
+ if (NonConvex(face1, face2, side1, side2)) return false;
+ } //end for
+ } //end for
+ //if one area has gap faces (that aren't seperating the two areas)
+ //and the other has ground faces (that aren't seperating the two areas),
+ //the areas can't be merged
+ if (((area1faceflags & FACE_GROUND) && (area2faceflags & FACE_GAP)) ||
+ ((area2faceflags & FACE_GROUND) && (area1faceflags & FACE_GAP)))
+ {
+// Log_Print(" can't merge: ground/gap\n");
+ return false;
+ } //end if
+
+// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum, numfaces);
+// return false;
+ //
+ //AAS_CheckArea(tmparea1);
+ //AAS_CheckArea(tmparea2);
+ //create the new area
+ newarea = AAS_AllocTmpArea();
+ newarea->presencetype = tmparea1->presencetype;
+ newarea->contents = tmparea1->contents;
+ newarea->modelnum = tmparea1->modelnum;
+ newarea->tmpfaces = NULL;
+
+ //add all the faces (except the seperating ones) from the first area
+ //to the new area
+ for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
+ {
+ side1 = (face1->frontarea != tmparea1);
+ nextface1 = face1->next[side1];
+ //don't add seperating faces
+ if ((face1->frontarea == tmparea1 &&
+ face1->backarea == tmparea2) ||
+ (face1->frontarea == tmparea2 &&
+ face1->backarea == tmparea1))
+ {
+ continue;
+ } //end if
+ //
+ AAS_RemoveFaceFromArea(face1, tmparea1);
+ AAS_AddFaceSideToArea(face1, side1, newarea);
+ } //end for
+ //add all the faces (except the seperating ones) from the second area
+ //to the new area
+ for (face2 = tmparea2->tmpfaces; face2; face2 = nextface2)
+ {
+ side2 = (face2->frontarea != tmparea2);
+ nextface2 = face2->next[side2];
+ //don't add seperating faces
+ if ((face2->frontarea == tmparea1 &&
+ face2->backarea == tmparea2) ||
+ (face2->frontarea == tmparea2 &&
+ face2->backarea == tmparea1))
+ {
+ continue;
+ } //end if
+ //
+ AAS_RemoveFaceFromArea(face2, tmparea2);
+ AAS_AddFaceSideToArea(face2, side2, newarea);
+ } //end for
+ //free all shared faces
+ for (face1 = tmparea1->tmpfaces; face1; face1 = nextface1)
+ {
+ side1 = (face1->frontarea != tmparea1);
+ nextface1 = face1->next[side1];
+ //
+ AAS_RemoveFaceFromArea(face1, face1->frontarea);
+ AAS_RemoveFaceFromArea(face1, face1->backarea);
+ AAS_FreeTmpFace(face1);
+ } //end for
+ //
+ tmparea1->mergedarea = newarea;
+ tmparea1->invalid = true;
+ tmparea2->mergedarea = newarea;
+ tmparea2->invalid = true;
+ //
+ AAS_CheckArea(newarea);
+ AAS_FlipAreaFaces(newarea);
+// Log_Print("merged area %d & %d to %d with %d faces\n", tmparea1->areanum, tmparea2->areanum, newarea->areanum);
+ return true;
+} //end of the function AAS_TryMergeFaceAreas
+//===========================================================================
+// try to merge areas
+// merged areas are added to the end of the convex area list so merging
+// will be tried for those areas as well
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: tmpaasworld
+//===========================================================================
+/*
+void AAS_MergeAreas(void)
+{
+ int side, nummerges;
+ tmp_area_t *tmparea, *othertmparea;
+ tmp_face_t *face;
+
+ nummerges = 0;
+ Log_Write("AAS_MergeAreas\r\n");
+ qprintf("%6d areas merged", 1);
+ //first merge grounded areas only
+ //NOTE: this is useless because the area settings aren't available yet
+ for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
+ {
+// Log_Print("checking area %d\n", i);
+ //if the area is invalid
+ if (tmparea->invalid)
+ {
+// Log_Print(" area invalid\n");
+ continue;
+ } //end if
+ //
+// if (!(tmparea->settings->areaflags & AREA_GROUNDED)) continue;
+ //
+ for (face = tmparea->tmpfaces; face; face = face->next[side])
+ {
+ side = (face->frontarea != tmparea);
+ //if the face has both a front and back area
+ if (face->frontarea && face->backarea)
+ {
+ //
+ if (face->frontarea == tmparea) othertmparea = face->backarea;
+ else othertmparea = face->frontarea;
+// if (!(othertmparea->settings->areaflags & AREA_GROUNDED)) continue;
+// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
+ if (AAS_TryMergeFaceAreas(face))
+ {
+ qprintf("\r%6d", ++nummerges);
+ break;
+ } //end if
+ } //end if
+ } //end for
+ } //end for
+ //merge all areas
+ for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
+ {
+// Log_Print("checking area %d\n", i);
+ //if the area is invalid
+ if (tmparea->invalid)
+ {
+// Log_Print(" area invalid\n");
+ continue;
+ } //end if
+ //
+ for (face = tmparea->tmpfaces; face; face = face->next[side])
+ {
+ side = (face->frontarea != tmparea);
+ //if the face has both a front and back area
+ if (face->frontarea && face->backarea)
+ {
+// Log_Print(" checking area %d with %d\n", face->frontarea, face->backarea);
+ if (AAS_TryMergeFaceAreas(face))
+ {
+ qprintf("\r%6d", ++nummerges);
+ break;
+ } //end if
+ } //end if
+ } //end for
+ } //end for
+ Log_Print("\r%6d areas merged\n", nummerges);
+ //refresh the merged tree
+ AAS_RefreshMergedTree_r(tmpaasworld.nodes);
+} //end of the function AAS_MergeAreas*/
+
+int AAS_GroundArea(tmp_area_t *tmparea)
+{
+ tmp_face_t *face;
+ int side;
+
+ for (face = tmparea->tmpfaces; face; face = face->next[side])
+ {
+ side = (face->frontarea != tmparea);
+ if (face->faceflags & FACE_GROUND) return true;
+ } //end for
+ return false;
+} //end of the function AAS_GroundArea
+
+void AAS_MergeAreas(void)
+{
+ int side, nummerges, merges, groundfirst;
+ tmp_area_t *tmparea, *othertmparea;
+ tmp_face_t *face;
+
+ nummerges = 0;
+ Log_Write("AAS_MergeAreas\r\n");
+ qprintf("%6d areas merged", 1);
+ //
+ groundfirst = true;
+ //for (i = 0; i < 4 || merges; i++)
+ while(1)
+ {
+ //if (i < 2) groundfirst = true;
+ //else groundfirst = false;
+ //
+ merges = 0;
+ //first merge grounded areas only
+ for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next)
+ {
+ //if the area is invalid
+ if (tmparea->invalid)
+ {
+ continue;
+ } //end if
+ //
+ if (groundfirst)
+ {
+ if (!AAS_GroundArea(tmparea)) continue;
+ } //end if
+ //
+ for (face = tmparea->tmpfaces; face; face = face->next[side])
+ {
+ side = (face->frontarea != tmparea);
+ //if the face has both a front and back area
+ if (face->frontarea && face->backarea)
+ {
+ //
+ if (face->frontarea == tmparea) othertmparea = face->backarea;
+ else othertmparea = face->frontarea;
+ //
+ if (groundfirst)
+ {
+ if (!AAS_GroundArea(othertmparea)) continue;
+ } //end if
+ if (AAS_TryMergeFaceAreas(face))
+ {
+ qprintf("\r%6d", ++nummerges);
+ merges++;
+ break;
+ } //end if
+ } //end if
+ } //end for
+ } //end for
+ if (!merges)
+ {
+ if (groundfirst) groundfirst = false;
+ else break;
+ } //end if
+ } //end for
+ qprintf("\n");
+ Log_Write("%6d areas merged\r\n", nummerges);
+ //refresh the merged tree
+ AAS_RefreshMergedTree_r(tmpaasworld.nodes);
+} //end of the function AAS_MergeAreas
View
48 aas_areamerging.h
@@ -1,24 +1,24 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-void AAS_MergeAreas(void);
-
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+void AAS_MergeAreas(void);
+
View
504 aas_cfg.c
@@ -1,252 +1,252 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#include "qbsp.h"
-#include "float.h"
-#include "../botlib/aasfile.h"
-#include "aas_store.h"
-#include "aas_cfg.h"
-#include "../botlib/l_precomp.h"
-#include "../botlib/l_struct.h"
-#include "../botlib/l_libvar.h"
-
-//structure field offsets
-#define BBOX_OFS(x) (int)&(((aas_bbox_t *)0)->x)
-#define CFG_OFS(x) (int)&(((cfg_t *)0)->x)
-
-//bounding box definition
-fielddef_t bbox_fields[] =
-{
- {"presencetype", BBOX_OFS(presencetype), FT_INT},
- {"flags", BBOX_OFS(flags), FT_INT},
- {"mins", BBOX_OFS(mins), FT_FLOAT|FT_ARRAY, 3},
- {"maxs", BBOX_OFS(maxs), FT_FLOAT|FT_ARRAY, 3},
- {NULL, 0, 0, 0}
-};
-
-fielddef_t cfg_fields[] =
-{
- {"phys_gravitydirection", CFG_OFS(phys_gravitydirection), FT_FLOAT|FT_ARRAY, 3},
- {"phys_friction", CFG_OFS(phys_friction), FT_FLOAT},
- {"phys_stopspeed", CFG_OFS(phys_stopspeed), FT_FLOAT},
- {"phys_gravity", CFG_OFS(phys_gravity), FT_FLOAT},
- {"phys_waterfriction", CFG_OFS(phys_waterfriction), FT_FLOAT},
- {"phys_watergravity", CFG_OFS(phys_watergravity), FT_FLOAT},
- {"phys_maxvelocity", CFG_OFS(phys_maxvelocity), FT_FLOAT},
- {"phys_maxwalkvelocity", CFG_OFS(phys_maxwalkvelocity), FT_FLOAT},
- {"phys_maxcrouchvelocity", CFG_OFS(phys_maxcrouchvelocity), FT_FLOAT},
- {"phys_maxswimvelocity", CFG_OFS(phys_maxswimvelocity), FT_FLOAT},
- {"phys_walkaccelerate", CFG_OFS(phys_walkaccelerate), FT_FLOAT},
- {"phys_airaccelerate", CFG_OFS(phys_airaccelerate), FT_FLOAT},
- {"phys_swimaccelerate", CFG_OFS(phys_swimaccelerate), FT_FLOAT},
- {"phys_maxstep", CFG_OFS(phys_maxstep), FT_FLOAT},
- {"phys_maxsteepness", CFG_OFS(phys_maxsteepness), FT_FLOAT},
- {"phys_maxwaterjump", CFG_OFS(phys_maxwaterjump), FT_FLOAT},
- {"phys_maxbarrier", CFG_OFS(phys_maxbarrier), FT_FLOAT},
- {"phys_jumpvel", CFG_OFS(phys_jumpvel), FT_FLOAT},
- {"phys_falldelta5", CFG_OFS(phys_falldelta5), FT_FLOAT},
- {"phys_falldelta10", CFG_OFS(phys_falldelta10), FT_FLOAT},
- {"rs_waterjump", CFG_OFS(rs_waterjump), FT_FLOAT},
- {"rs_teleport", CFG_OFS(rs_teleport), FT_FLOAT},
- {"rs_barrierjump", CFG_OFS(rs_barrierjump), FT_FLOAT},
- {"rs_startcrouch", CFG_OFS(rs_startcrouch), FT_FLOAT},
- {"rs_startgrapple", CFG_OFS(rs_startgrapple), FT_FLOAT},
- {"rs_startwalkoffledge", CFG_OFS(rs_startwalkoffledge), FT_FLOAT},
- {"rs_startjump", CFG_OFS(rs_startjump), FT_FLOAT},
- {"rs_rocketjump", CFG_OFS(rs_rocketjump), FT_FLOAT},
- {"rs_bfgjump", CFG_OFS(rs_bfgjump), FT_FLOAT},
- {"rs_jumppad", CFG_OFS(rs_jumppad), FT_FLOAT},
- {"rs_aircontrolledjumppad", CFG_OFS(rs_aircontrolledjumppad), FT_FLOAT},
- {"rs_funcbob", CFG_OFS(rs_funcbob), FT_FLOAT},
- {"rs_startelevator", CFG_OFS(rs_startelevator), FT_FLOAT},
- {"rs_falldamage5", CFG_OFS(rs_falldamage5), FT_FLOAT},
- {"rs_falldamage10", CFG_OFS(rs_falldamage10), FT_FLOAT},
- {"rs_maxjumpfallheight", CFG_OFS(rs_maxjumpfallheight), FT_FLOAT},
- {NULL, 0, 0, 0}
-};
-
-structdef_t bbox_struct =
-{
- sizeof(aas_bbox_t), bbox_fields
-};
-structdef_t cfg_struct =
-{
- sizeof(cfg_t), cfg_fields
-};
-
-//global cfg
-cfg_t cfg;
-
-//===========================================================================
-// the default Q3A configuration
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-void DefaultCfg(void)
-{
- int i;
-
- // default all float values to infinite
- for (i = 0; cfg_fields[i].name; i++)
- {
- if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
- *(float *)( ((char*)&cfg) + cfg_fields[i].offset ) = FLT_MAX;
- } //end for
- //
- cfg.numbboxes = 2;
- //bbox 0
- cfg.bboxes[0].presencetype = PRESENCE_NORMAL;
- cfg.bboxes[0].flags = 0;
- cfg.bboxes[0].mins[0] = -15;
- cfg.bboxes[0].mins[1] = -15;
- cfg.bboxes[0].mins[2] = -24;
- cfg.bboxes[0].maxs[0] = 15;
- cfg.bboxes[0].maxs[1] = 15;
- cfg.bboxes[0].maxs[2] = 32;
- //bbox 1
- cfg.bboxes[1].presencetype = PRESENCE_CROUCH;
- cfg.bboxes[1].flags = 1;
- cfg.bboxes[1].mins[0] = -15;
- cfg.bboxes[1].mins[1] = -15;
- cfg.bboxes[1].mins[2] = -24;
- cfg.bboxes[1].maxs[0] = 15;
- cfg.bboxes[1].maxs[1] = 15;
- cfg.bboxes[1].maxs[2] = 16;
- //
- cfg.allpresencetypes = PRESENCE_NORMAL|PRESENCE_CROUCH;
- cfg.phys_gravitydirection[0] = 0;
- cfg.phys_gravitydirection[1] = 0;
- cfg.phys_gravitydirection[2] = -1;
- cfg.phys_maxsteepness = 0.7;
-} //end of the function DefaultCfg
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-char * QDECL va( char *format, ... )
-{
- va_list argptr;
- static char string[2][32000]; // in case va is called by nested functions
- static int index = 0;
- char *buf;
-
- buf = string[index & 1];
- index++;
-
- va_start (argptr, format);
- vsprintf (buf, format,argptr);
- va_end (argptr);
-
- return buf;
-} //end of the function va
-//===========================================================================
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-void SetCfgLibVars(void)
-{
- int i;
- float value;
-
- for (i = 0; cfg_fields[i].name; i++)
- {
- if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
- {
- value = *(float *)(((char*)&cfg) + cfg_fields[i].offset);
- if (value != FLT_MAX)
- {
- LibVarSet(cfg_fields[i].name, va("%f", value));
- } //end if
- } //end if
- } //end for
-} //end of the function SetCfgLibVars
-//===========================================================================
-//
-// 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
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#include "qbsp.h"
+#include "float.h"
+#include "../botlib/aasfile.h"
+#include "aas_store.h"
+#include "aas_cfg.h"
+#include "../botlib/l_precomp.h"
+#include "../botlib/l_struct.h"
+#include "../botlib/l_libvar.h"
+
+//structure field offsets
+#define BBOX_OFS(x) (int)&(((aas_bbox_t *)0)->x)
+#define CFG_OFS(x) (int)&(((cfg_t *)0)->x)
+
+//bounding box definition
+fielddef_t bbox_fields[] =
+{
+ {"presencetype", BBOX_OFS(presencetype), FT_INT},
+ {"flags", BBOX_OFS(flags), FT_INT},
+ {"mins", BBOX_OFS(mins), FT_FLOAT|FT_ARRAY, 3},
+ {"maxs", BBOX_OFS(maxs), FT_FLOAT|FT_ARRAY, 3},
+ {NULL, 0, 0, 0}
+};
+
+fielddef_t cfg_fields[] =
+{
+ {"phys_gravitydirection", CFG_OFS(phys_gravitydirection), FT_FLOAT|FT_ARRAY, 3},
+ {"phys_friction", CFG_OFS(phys_friction), FT_FLOAT},
+ {"phys_stopspeed", CFG_OFS(phys_stopspeed), FT_FLOAT},
+ {"phys_gravity", CFG_OFS(phys_gravity), FT_FLOAT},
+ {"phys_waterfriction", CFG_OFS(phys_waterfriction), FT_FLOAT},
+ {"phys_watergravity", CFG_OFS(phys_watergravity), FT_FLOAT},
+ {"phys_maxvelocity", CFG_OFS(phys_maxvelocity), FT_FLOAT},
+ {"phys_maxwalkvelocity", CFG_OFS(phys_maxwalkvelocity), FT_FLOAT},
+ {"phys_maxcrouchvelocity", CFG_OFS(phys_maxcrouchvelocity), FT_FLOAT},
+ {"phys_maxswimvelocity", CFG_OFS(phys_maxswimvelocity), FT_FLOAT},
+ {"phys_walkaccelerate", CFG_OFS(phys_walkaccelerate), FT_FLOAT},
+ {"phys_airaccelerate", CFG_OFS(phys_airaccelerate), FT_FLOAT},
+ {"phys_swimaccelerate", CFG_OFS(phys_swimaccelerate), FT_FLOAT},
+ {"phys_maxstep", CFG_OFS(phys_maxstep), FT_FLOAT},
+ {"phys_maxsteepness", CFG_OFS(phys_maxsteepness), FT_FLOAT},
+ {"phys_maxwaterjump", CFG_OFS(phys_maxwaterjump), FT_FLOAT},
+ {"phys_maxbarrier", CFG_OFS(phys_maxbarrier), FT_FLOAT},
+ {"phys_jumpvel", CFG_OFS(phys_jumpvel), FT_FLOAT},
+ {"phys_falldelta5", CFG_OFS(phys_falldelta5), FT_FLOAT},
+ {"phys_falldelta10", CFG_OFS(phys_falldelta10), FT_FLOAT},
+ {"rs_waterjump", CFG_OFS(rs_waterjump), FT_FLOAT},
+ {"rs_teleport", CFG_OFS(rs_teleport), FT_FLOAT},
+ {"rs_barrierjump", CFG_OFS(rs_barrierjump), FT_FLOAT},
+ {"rs_startcrouch", CFG_OFS(rs_startcrouch), FT_FLOAT},
+ {"rs_startgrapple", CFG_OFS(rs_startgrapple), FT_FLOAT},
+ {"rs_startwalkoffledge", CFG_OFS(rs_startwalkoffledge), FT_FLOAT},
+ {"rs_startjump", CFG_OFS(rs_startjump), FT_FLOAT},
+ {"rs_rocketjump", CFG_OFS(rs_rocketjump), FT_FLOAT},
+ {"rs_bfgjump", CFG_OFS(rs_bfgjump), FT_FLOAT},
+ {"rs_jumppad", CFG_OFS(rs_jumppad), FT_FLOAT},
+ {"rs_aircontrolledjumppad", CFG_OFS(rs_aircontrolledjumppad), FT_FLOAT},
+ {"rs_funcbob", CFG_OFS(rs_funcbob), FT_FLOAT},
+ {"rs_startelevator", CFG_OFS(rs_startelevator), FT_FLOAT},
+ {"rs_falldamage5", CFG_OFS(rs_falldamage5), FT_FLOAT},
+ {"rs_falldamage10", CFG_OFS(rs_falldamage10), FT_FLOAT},
+ {"rs_maxjumpfallheight", CFG_OFS(rs_maxjumpfallheight), FT_FLOAT},
+ {NULL, 0, 0, 0}
+};
+
+structdef_t bbox_struct =
+{
+ sizeof(aas_bbox_t), bbox_fields
+};
+structdef_t cfg_struct =
+{
+ sizeof(cfg_t), cfg_fields
+};
+
+//global cfg
+cfg_t cfg;
+
+//===========================================================================
+// the default Q3A configuration
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void DefaultCfg(void)
+{
+ int i;
+
+ // default all float values to infinite
+ for (i = 0; cfg_fields[i].name; i++)
+ {
+ if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
+ *(float *)( ((char*)&cfg) + cfg_fields[i].offset ) = FLT_MAX;
+ } //end for
+ //
+ cfg.numbboxes = 2;
+ //bbox 0
+ cfg.bboxes[0].presencetype = PRESENCE_NORMAL;
+ cfg.bboxes[0].flags = 0;
+ cfg.bboxes[0].mins[0] = -15;
+ cfg.bboxes[0].mins[1] = -15;
+ cfg.bboxes[0].mins[2] = -24;
+ cfg.bboxes[0].maxs[0] = 15;
+ cfg.bboxes[0].maxs[1] = 15;
+ cfg.bboxes[0].maxs[2] = 32;
+ //bbox 1
+ cfg.bboxes[1].presencetype = PRESENCE_CROUCH;
+ cfg.bboxes[1].flags = 1;
+ cfg.bboxes[1].mins[0] = -15;
+ cfg.bboxes[1].mins[1] = -15;
+ cfg.bboxes[1].mins[2] = -24;
+ cfg.bboxes[1].maxs[0] = 15;
+ cfg.bboxes[1].maxs[1] = 15;
+ cfg.bboxes[1].maxs[2] = 16;
+ //
+ cfg.allpresencetypes = PRESENCE_NORMAL|PRESENCE_CROUCH;
+ cfg.phys_gravitydirection[0] = 0;
+ cfg.phys_gravitydirection[1] = 0;
+ cfg.phys_gravitydirection[2] = -1;
+ cfg.phys_maxsteepness = 0.7;
+} //end of the function DefaultCfg
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+char * QDECL va( char *format, ... )
+{
+ va_list argptr;
+ static char string[2][32000]; // in case va is called by nested functions
+ static int index = 0;
+ char *buf;
+
+ buf = string[index & 1];
+ index++;
+
+ va_start (argptr, format);
+ vsprintf (buf, format,argptr);
+ va_end (argptr);
+
+ return buf;
+} //end of the function va
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void SetCfgLibVars(void)
+{
+ int i;
+ float value;
+
+ for (i = 0; cfg_fields[i].name; i++)
+ {
+ if ((cfg_fields[i].type & FT_TYPE) == FT_FLOAT)
+ {
+ value = *(float *)(((char*)&cfg) + cfg_fields[i].offset);
+ if (value != FLT_MAX)
+ {
+ LibVarSet(cfg_fields[i].name, va("%f", value));
+ } //end if
+ } //end if
+ } //end for
+} //end of the function SetCfgLibVars
+//===========================================================================
+//
+// 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
View
146 aas_cfg.h
@@ -1,73 +1,73 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#define BBOXFL_GROUNDED 1 //bounding box only valid when on ground
-#define BBOXFL_NOTGROUNDED 2 //bounding box only valid when NOT on ground
-
-typedef struct cfg_s
-{
- int numbboxes; //number of bounding boxes
- aas_bbox_t bboxes[AAS_MAX_BBOXES]; //all the bounding boxes
- int allpresencetypes; //or of all presence types
- // aas settings
- vec3_t phys_gravitydirection;
- float phys_friction;
- float phys_stopspeed;
- float phys_gravity;
- float phys_waterfriction;
- float phys_watergravity;
- float phys_maxvelocity;
- float phys_maxwalkvelocity;
- float phys_maxcrouchvelocity;
- float phys_maxswimvelocity;
- float phys_walkaccelerate;
- float phys_airaccelerate;
- float phys_swimaccelerate;
- float phys_maxstep;
- float phys_maxsteepness;
- float phys_maxwaterjump;
- float phys_maxbarrier;
- float phys_jumpvel;
- float phys_falldelta5;
- float phys_falldelta10;
- float rs_waterjump;
- float rs_teleport;
- float rs_barrierjump;
- float rs_startcrouch;
- float rs_startgrapple;
- float rs_startwalkoffledge;
- float rs_startjump;
- float rs_rocketjump;
- float rs_bfgjump;
- float rs_jumppad;
- float rs_aircontrolledjumppad;
- float rs_funcbob;
- float rs_startelevator;
- float rs_falldamage5;
- float rs_falldamage10;
- float rs_maxjumpfallheight;
-} cfg_t;
-
-extern cfg_t cfg;
-
-void DefaultCfg(void);
-int LoadCfgFile(char *filename);
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#define BBOXFL_GROUNDED 1 //bounding box only valid when on ground
+#define BBOXFL_NOTGROUNDED 2 //bounding box only valid when NOT on ground
+
+typedef struct cfg_s
+{
+ int numbboxes; //number of bounding boxes
+ aas_bbox_t bboxes[AAS_MAX_BBOXES]; //all the bounding boxes
+ int allpresencetypes; //or of all presence types
+ // aas settings
+ vec3_t phys_gravitydirection;
+ float phys_friction;
+ float phys_stopspeed;
+ float phys_gravity;
+ float phys_waterfriction;
+ float phys_watergravity;
+ float phys_maxvelocity;
+ float phys_maxwalkvelocity;
+ float phys_maxcrouchvelocity;
+ float phys_maxswimvelocity;
+ float phys_walkaccelerate;
+ float phys_airaccelerate;
+ float phys_swimaccelerate;
+ float phys_maxstep;
+ float phys_maxsteepness;
+ float phys_maxwaterjump;
+ float phys_maxbarrier;
+ float phys_jumpvel;
+ float phys_falldelta5;
+ float phys_falldelta10;
+ float rs_waterjump;
+ float rs_teleport;
+ float rs_barrierjump;
+ float rs_startcrouch;
+ float rs_startgrapple;
+ float rs_startwalkoffledge;
+ float rs_startjump;
+ float rs_rocketjump;
+ float rs_bfgjump;
+ float rs_jumppad;
+ float rs_aircontrolledjumppad;
+ float rs_funcbob;
+ float rs_startelevator;
+ float rs_falldamage5;
+ float rs_falldamage10;
+ float rs_maxjumpfallheight;
+} cfg_t;
+
+extern cfg_t cfg;
+
+void DefaultCfg(void);
+int LoadCfgFile(char *filename);
View
2,284 aas_create.c
1,142 additions, 1,142 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
272 aas_create.h
@@ -1,136 +1,136 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#define AREA_PORTAL 1
-
-//temporary AAS face
-typedef struct tmp_face_s
-{
- int num; //face number
- int planenum; //number of the plane the face is in
- winding_t *winding; //winding of the face
- struct tmp_area_s *frontarea; //area at the front of the face
- struct tmp_area_s *backarea; //area at the back of the face
- int faceflags; //flags of this face
- int aasfacenum; //the number of the aas face used for this face
- //double link list pointers for front and back area
- struct tmp_face_s *prev[2], *next[2];
- //links in the list with faces
- struct tmp_face_s *l_prev, *l_next;
-} tmp_face_t;
-
-//temporary AAS area settings
-typedef struct tmp_areasettings_s
-{
- //could also add all kind of statistic fields
- int contents; //contents of the area
- int modelnum; //bsp model inside this area
- int areaflags; //area flags
- int presencetype; //how a bot can be present in this area
- int numreachableareas; //number of reachable areas from this one
- int firstreachablearea; //first reachable area in the reachable area index
-} tmp_areasettings_t;
-
-//temporary AAS area
-typedef struct tmp_area_s
-{
- int areanum; //number of the area
- struct tmp_face_s *tmpfaces; //the faces of the area
- int presencetype; //presence type of the area
- int contents; //area contents
- int modelnum; //bsp model inside this area
- int invalid; //true if the area is invalid
- tmp_areasettings_t *settings; //area settings
- struct tmp_area_s *mergedarea; //points to the new area after merging
- //when mergedarea != 0 the area has only the
- //seperating face of the merged areas
- int aasareanum; //number of the aas area created for this tmp area
- //links in the list with areas
- struct tmp_area_s *l_prev, *l_next;
-} tmp_area_t;
-
-//temporary AAS node
-typedef struct tmp_node_s
-{
- int planenum; //node plane number
- struct tmp_area_s *tmparea; //points to an area if this node is an area
- struct tmp_node_s *children[2]; //child nodes of this node
-} tmp_node_t;
-
-#define NODEBUF_SIZE 128
-//node buffer
-typedef struct tmp_nodebuf_s
-{
- int numnodes;
- struct tmp_nodebuf_s *next;
- tmp_node_t nodes[NODEBUF_SIZE];
-} tmp_nodebuf_t;
-
-//the whole temorary AAS
-typedef struct tmp_aas_s
-{
- //faces
- int numfaces;
- int facenum;
- tmp_face_t *faces;
- //areas
- int numareas;
- int areanum;
- tmp_area_t *areas;
- //area settings
- int numareasettings;
- tmp_areasettings_t *areasettings;
- //nodes
- int numnodes;
- tmp_node_t *nodes;
- //node buffer
- tmp_nodebuf_t *nodebuffer;
-} tmp_aas_t;
-
-extern tmp_aas_t tmpaasworld;
-
-//creates a .AAS file with the given name from an already loaded map
-void AAS_Create(char *aasfile);
-//adds a face side to an area
-void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea);
-//remvoes a face from an area
-void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea);
-//allocate a tmp face
-tmp_face_t *AAS_AllocTmpFace(void);
-//free the tmp face
-void AAS_FreeTmpFace(tmp_face_t *tmpface);
-//allocate a tmp area
-tmp_area_t *AAS_AllocTmpArea(void);
-//free a tmp area
-void AAS_FreeTmpArea(tmp_area_t *tmparea);
-//allocate a tmp node
-tmp_node_t *AAS_AllocTmpNode(void);
-//free a tmp node
-void AAS_FreeTmpNode(tmp_node_t *node);
-//checks if an area is ok
-void AAS_CheckArea(tmp_area_t *tmparea);
-//flips the area faces where needed
-void AAS_FlipAreaFaces(tmp_area_t *tmparea);
-//returns true if the face is a gap seen from the given side
-int AAS_GapFace(tmp_face_t *tmpface, int side);
-//returns true if the face is a ground face
-int AAS_GroundFace(tmp_face_t *tmpface);
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#define AREA_PORTAL 1
+
+//temporary AAS face
+typedef struct tmp_face_s
+{
+ int num; //face number
+ int planenum; //number of the plane the face is in
+ winding_t *winding; //winding of the face
+ struct tmp_area_s *frontarea; //area at the front of the face
+ struct tmp_area_s *backarea; //area at the back of the face
+ int faceflags; //flags of this face
+ int aasfacenum; //the number of the aas face used for this face
+ //double link list pointers for front and back area
+ struct tmp_face_s *prev[2], *next[2];
+ //links in the list with faces
+ struct tmp_face_s *l_prev, *l_next;
+} tmp_face_t;
+
+//temporary AAS area settings
+typedef struct tmp_areasettings_s
+{
+ //could also add all kind of statistic fields
+ int contents; //contents of the area
+ int modelnum; //bsp model inside this area
+ int areaflags; //area flags
+ int presencetype; //how a bot can be present in this area
+ int numreachableareas; //number of reachable areas from this one
+ int firstreachablearea; //first reachable area in the reachable area index
+} tmp_areasettings_t;
+
+//temporary AAS area
+typedef struct tmp_area_s
+{
+ int areanum; //number of the area
+ struct tmp_face_s *tmpfaces; //the faces of the area
+ int presencetype; //presence type of the area
+ int contents; //area contents
+ int modelnum; //bsp model inside this area
+ int invalid; //true if the area is invalid
+ tmp_areasettings_t *settings; //area settings
+ struct tmp_area_s *mergedarea; //points to the new area after merging
+ //when mergedarea != 0 the area has only the
+ //seperating face of the merged areas
+ int aasareanum; //number of the aas area created for this tmp area
+ //links in the list with areas
+ struct tmp_area_s *l_prev, *l_next;
+} tmp_area_t;
+
+//temporary AAS node
+typedef struct tmp_node_s
+{
+ int planenum; //node plane number
+ struct tmp_area_s *tmparea; //points to an area if this node is an area
+ struct tmp_node_s *children[2]; //child nodes of this node
+} tmp_node_t;
+
+#define NODEBUF_SIZE 128
+//node buffer
+typedef struct tmp_nodebuf_s
+{
+ int numnodes;
+ struct tmp_nodebuf_s *next;
+ tmp_node_t nodes[NODEBUF_SIZE];
+} tmp_nodebuf_t;
+
+//the whole temorary AAS
+typedef struct tmp_aas_s
+{
+ //faces
+ int numfaces;
+ int facenum;
+ tmp_face_t *faces;
+ //areas
+ int numareas;
+ int areanum;
+ tmp_area_t *areas;
+ //area settings
+ int numareasettings;
+ tmp_areasettings_t *areasettings;
+ //nodes
+ int numnodes;
+ tmp_node_t *nodes;
+ //node buffer
+ tmp_nodebuf_t *nodebuffer;
+} tmp_aas_t;
+
+extern tmp_aas_t tmpaasworld;
+
+//creates a .AAS file with the given name from an already loaded map
+void AAS_Create(char *aasfile);
+//adds a face side to an area
+void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea);
+//remvoes a face from an area
+void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea);
+//allocate a tmp face
+tmp_face_t *AAS_AllocTmpFace(void);
+//free the tmp face
+void AAS_FreeTmpFace(tmp_face_t *tmpface);
+//allocate a tmp area
+tmp_area_t *AAS_AllocTmpArea(void);
+//free a tmp area
+void AAS_FreeTmpArea(tmp_area_t *tmparea);
+//allocate a tmp node
+tmp_node_t *AAS_AllocTmpNode(void);
+//free a tmp node
+void AAS_FreeTmpNode(tmp_node_t *node);
+//checks if an area is ok
+void AAS_CheckArea(tmp_area_t *tmparea);
+//flips the area faces where needed
+void AAS_FlipAreaFaces(tmp_area_t *tmparea);
+//returns true if the face is a gap seen from the given side
+int AAS_GapFace(tmp_face_t *tmpface, int side);
+//returns true if the face is a ground face
+int AAS_GroundFace(tmp_face_t *tmpface);
View
216 aas_edgemelting.c
@@ -1,108 +1,108 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#include "qbsp.h"
-#include "../botlib/aasfile.h"
-#include "aas_create.h"
-
-//===========================================================================
-// try to melt the windings of the two faces
-// FIXME: this is buggy
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2)
-{
- int i, n;
- int splits = 0;
- winding_t *w2, *neww;
- plane_t *plane1;
-
-#ifdef DEBUG
- if (!face1->winding) Error("face1 %d without winding", face1->num);
- if (!face2->winding) Error("face2 %d without winding", face2->num);
-#endif //DEBUG
- w2 = face2->winding;
- plane1 = &mapplanes[face1->planenum];
- for (i = 0; i < w2->numpoints; i++)
- {
- if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n))
- {
- neww = AddWindingPoint(face1->winding, w2->p[i], n);
- FreeWinding(face1->winding);
- face1->winding = neww;
-
- splits++;
- } //end if
- } //end for
- return splits;
-} //end of the function AAS_MeltFaceWinding
-//===========================================================================
-// melt the windings of the area faces
-//
-// Parameter: -
-// Returns: -
-// Changes Globals: -
-//===========================================================================
-int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea)
-{
- int side1, side2, num_windingsplits = 0;
- tmp_face_t *face1, *face2;
-
- for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
- {
- side1 = face1->frontarea != tmparea;
- for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2])
- {
- side2 = face2->frontarea != tmparea;
- if (face1 == face2) continue;
- num_windingsplits += AAS_MeltFaceWinding(face1, face2);
- } //end for
- } //end for
- return num_windingsplits;
-} //end of the function AAS_MeltFaceWindingsOfArea
-//===========================================================================
-// 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
-
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#include "qbsp.h"
+#include "../botlib/aasfile.h"
+#include "aas_create.h"
+
+//===========================================================================
+// try to melt the windings of the two faces
+// FIXME: this is buggy
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2)
+{
+ int i, n;
+ int splits = 0;
+ winding_t *w2, *neww;
+ plane_t *plane1;
+
+#ifdef DEBUG
+ if (!face1->winding) Error("face1 %d without winding", face1->num);
+ if (!face2->winding) Error("face2 %d without winding", face2->num);
+#endif //DEBUG
+ w2 = face2->winding;
+ plane1 = &mapplanes[face1->planenum];
+ for (i = 0; i < w2->numpoints; i++)
+ {
+ if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n))
+ {
+ neww = AddWindingPoint(face1->winding, w2->p[i], n);
+ FreeWinding(face1->winding);
+ face1->winding = neww;
+
+ splits++;
+ } //end if
+ } //end for
+ return splits;
+} //end of the function AAS_MeltFaceWinding
+//===========================================================================
+// melt the windings of the area faces
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea)
+{
+ int side1, side2, num_windingsplits = 0;
+ tmp_face_t *face1, *face2;
+
+ for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1])
+ {
+ side1 = face1->frontarea != tmparea;
+ for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2])
+ {
+ side2 = face2->frontarea != tmparea;
+ if (face1 == face2) continue;
+ num_windingsplits += AAS_MeltFaceWinding(face1, face2);
+ } //end for
+ } //end for
+ return num_windingsplits;
+} //end of the function AAS_MeltFaceWindingsOfArea
+//===========================================================================
+// 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
+
View
48 aas_edgemelting.h
@@ -1,24 +1,24 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-void AAS_MeltAreaFaceWindings(void);
-
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Foobar; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+void AAS_MeltAreaFaceWindings(void);
+
View
564 aas_facemerging.c
@@ -1,282 +1,282 @@
-/*
-===========================================================================
-Copyright (C) 1999-2005 Id Software, Inc.
-
-This file is part of Quake III Arena source code.
-
-Quake III Arena source code is free software; you can redistribute it
-and/or modify it under the terms of the GNU General Public License as
-published by the Free Software Foundation; either version 2 of the License,
-or (at your option) any later version.
-
-Quake III Arena source code is distributed in the hope that it will be
-useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with Foobar; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-===========================================================================
-*/
-
-#include "qbsp.h"
-#include "../botlib/aasfile.h"
-#include "aas_create.h"
-
-//===========================================================================
-//
-// 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
-/*