├── .gitignore ├── deps ├── qcommon │ ├── md4.c │ ├── vm_sparc.h │ ├── puff.h │ ├── cm_polylib.h │ ├── ioapi.h │ ├── cm_public.h │ ├── cm_patch.h │ ├── surfaceflags.h │ ├── vm_local.h │ ├── vm_powerpc_asm.h │ └── cm_local.h └── botlib │ ├── lcc.mak │ ├── be_aas_optimize.h │ ├── l_crc.h │ ├── be_ai_gen.h │ ├── be_aas_cluster.h │ ├── l_utils.h │ ├── be_aas_file.h │ ├── be_aas_routealt.h │ ├── be_aas_funcs.h │ ├── l_log.h │ ├── linux-i386.mak │ ├── be_interface.h │ ├── be_ai_char.h │ ├── be_aas_main.h │ ├── be_ea.h │ ├── be_aas_debug.h │ ├── l_libvar.h │ ├── be_aas_entity.h │ ├── l_struct.h │ ├── be_aas_reach.h │ ├── be_aas_route.h │ ├── be_aas_move.h │ ├── be_ai_weight.h │ ├── l_memory.h │ ├── be_aas_sample.h │ ├── be_aas_bsp.h │ ├── be_ai_weap.h │ ├── be_ai_gen.c │ ├── be_ai_chat.h │ ├── be_ai_goal.h │ └── l_log.c ├── aas_areamerging.h ├── aas_prunenodes.h ├── aas_edgemelting.h ├── tetrahedron.h ├── lcc.mak ├── aas_map.h ├── aas_facemerging.h ├── be_aas_bspc.h ├── aas_gsubdiv.h ├── aas_file.h ├── bspc.sln ├── nodraw.c ├── Conscript ├── l_log.h ├── l_threads.h ├── README.md ├── l_mem.h ├── l_bsp_ent.h ├── _files.c ├── aas_cfg.h ├── linux-i386.mak ├── Makefile ├── cfgq3.c ├── l_utils.h ├── l_bsp_q3.h ├── leakfile.c ├── aas_prunenodes.c ├── l_bsp_q2.h ├── l_qfiles.h ├── aas_store.h ├── l_math.h ├── glfile.c ├── l_bsp_sin.h ├── aas_edgemelting.c ├── l_bsp_ent.c ├── l_cmd.h ├── aas_create.h ├── l_poly.h └── gldraw.c /.gitignore: -------------------------------------------------------------------------------- 1 | bspc_g 2 | bspc 3 | *.log 4 | *.o 5 | -------------------------------------------------------------------------------- /deps/qcommon/md4.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoordhuis/bspc/HEAD/deps/qcommon/md4.c -------------------------------------------------------------------------------- /aas_areamerging.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | void AAS_MergeAreas(void); 24 | 25 | -------------------------------------------------------------------------------- /aas_prunenodes.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | void AAS_PruneNodes(void); 24 | 25 | -------------------------------------------------------------------------------- /aas_edgemelting.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | void AAS_MeltAreaFaceWindings(void); 24 | 25 | -------------------------------------------------------------------------------- /tetrahedron.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | void TH_AASToTetrahedrons(char *filename); 24 | 25 | -------------------------------------------------------------------------------- /lcc.mak: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the BSPC tool for the Gladiator Bot 3 | # Intended for LCC-Win32 4 | # 5 | 6 | CC=lcc 7 | CFLAGS=-DC_ONLY -o 8 | OBJS= _files.obj\ 9 | aas_areamerging.obj\ 10 | aas_cfg.obj\ 11 | aas_create.obj\ 12 | aas_edgemelting.obj\ 13 | aas_facemerging.obj\ 14 | aas_file.obj\ 15 | aas_gsubdiv.obj\ 16 | aas_map.obj\ 17 | aas_prunenodes.obj\ 18 | aas_store.obj\ 19 | brushbsp.obj\ 20 | bspc.obj\ 21 | csg.obj\ 22 | faces.obj\ 23 | glfile.obj\ 24 | l_bsp_hl.obj\ 25 | l_bsp_q1.obj\ 26 | l_bsp_q2.obj\ 27 | l_bsp_sin.obj\ 28 | l_cmd.obj\ 29 | l_log.obj\ 30 | l_math.obj\ 31 | l_mem.obj\ 32 | l_poly.obj\ 33 | l_qfiles.obj\ 34 | l_script.obj\ 35 | l_threads.obj\ 36 | l_utils.obj\ 37 | leakfile.obj\ 38 | map.obj\ 39 | map_hl.obj\ 40 | map_q1.obj\ 41 | map_q2.obj\ 42 | map_q2_new.obj\ 43 | map_sin.obj\ 44 | nodraw.obj\ 45 | portals.obj\ 46 | prtfile.obj\ 47 | textures.obj\ 48 | tree.obj\ 49 | writebsp.obj 50 | 51 | all: bspc.exe 52 | 53 | bspc.exe: $(OBJS) 54 | lcclnk 55 | 56 | clean: 57 | del *.obj bspc.exe 58 | 59 | %.obj: %.c 60 | $(CC) $(CFLAGS) $< 61 | 62 | -------------------------------------------------------------------------------- /aas_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | void AAS_CreateMapBrushes(mapbrush_t *brush, entity_t *mapent, int addbevels); 24 | -------------------------------------------------------------------------------- /aas_facemerging.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | void AAS_MergeAreaFaces(void); 24 | void AAS_MergeAreaPlaneFaces(void); 25 | -------------------------------------------------------------------------------- /be_aas_bspc.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | void AAS_CalcReachAndClusters(struct quakefile_s *qf); 24 | void AAS_InitBotImport(void); 25 | -------------------------------------------------------------------------------- /aas_gsubdiv.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | //works with the global tmpaasworld 24 | void AAS_GravitationalSubdivision(void); 25 | void AAS_LadderSubdivision(void); 26 | -------------------------------------------------------------------------------- /aas_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | qboolean AAS_WriteAASFile(char *filename); 24 | qboolean AAS_LoadAASFile(char *filename, int fpoffset, int fplength); 25 | void AAS_ShowTotals(void); 26 | -------------------------------------------------------------------------------- /deps/botlib/lcc.mak: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Gladiator Bot library: gladiator.dll 3 | # Intended for LCC-Win32 4 | # 5 | 6 | CC=lcc 7 | CFLAGS=-DC_ONLY -o 8 | OBJS= be_aas_bspq2.obj \ 9 | be_aas_bsphl.obj \ 10 | be_aas_cluster.obj \ 11 | be_aas_debug.obj \ 12 | be_aas_entity.obj \ 13 | be_aas_file.obj \ 14 | be_aas_light.obj \ 15 | be_aas_main.obj \ 16 | be_aas_move.obj \ 17 | be_aas_optimize.obj \ 18 | be_aas_reach.obj \ 19 | be_aas_route.obj \ 20 | be_aas_routealt.obj \ 21 | be_aas_sample.obj \ 22 | be_aas_sound.obj \ 23 | be_ai2_dm.obj \ 24 | be_ai2_dmnet.obj \ 25 | be_ai2_main.obj \ 26 | be_ai_char.obj \ 27 | be_ai_chat.obj \ 28 | be_ai_goal.obj \ 29 | be_ai_load.obj \ 30 | be_ai_move.obj \ 31 | be_ai_weap.obj \ 32 | be_ai_weight.obj \ 33 | be_ea.obj \ 34 | be_interface.obj \ 35 | l_crc.obj \ 36 | l_libvar.obj \ 37 | l_log.obj \ 38 | l_memory.obj \ 39 | l_precomp.obj \ 40 | l_script.obj \ 41 | l_struct.obj \ 42 | l_utils.obj \ 43 | q_shared.obj 44 | 45 | all: gladiator.dll 46 | 47 | gladiator.dll: $(OBJS) 48 | lcclnk -dll -entry GetBotAPI *.obj botlib.def -o gladiator.dll 49 | 50 | clean: 51 | del *.obj gladiator.dll 52 | 53 | %.obj: %.c 54 | $(CC) $(CFLAGS) $< 55 | 56 | -------------------------------------------------------------------------------- /bspc.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bspc", "bspc.vcproj", "{4E4EBC16-F345-4667-84E1-86633BAFDAE6}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Global 7 | GlobalSection(SourceCodeControl) = preSolution 8 | SccNumberOfProjects = 1 9 | SccProjectUniqueName0 = bspc.vcproj 10 | SccProjectName0 = \u0022$/source/code/bspc\u0022,\u0020IGAAAAAA 11 | SccLocalPath0 = . 12 | SccProvider0 = MSSCCI:Perforce\u0020SCM 13 | EndGlobalSection 14 | GlobalSection(SolutionConfiguration) = preSolution 15 | Debug = Debug 16 | Release = Release 17 | EndGlobalSection 18 | GlobalSection(ProjectConfiguration) = postSolution 19 | {4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.ActiveCfg = Debug|Win32 20 | {4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Debug.Build.0 = Debug|Win32 21 | {4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.ActiveCfg = Release|Win32 22 | {4E4EBC16-F345-4667-84E1-86633BAFDAE6}.Release.Build.0 = Release|Win32 23 | EndGlobalSection 24 | GlobalSection(ExtensibilityGlobals) = postSolution 25 | EndGlobalSection 26 | GlobalSection(ExtensibilityAddIns) = postSolution 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_optimize.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_optimize.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_optimize.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | void AAS_Optimize(void); 33 | 34 | -------------------------------------------------------------------------------- /deps/botlib/l_crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | typedef unsigned short crc_t; 24 | 25 | void CRC_Init(unsigned short *crcvalue); 26 | void CRC_ProcessByte(unsigned short *crcvalue, byte data); 27 | unsigned short CRC_Value(unsigned short crcvalue); 28 | unsigned short CRC_ProcessString(unsigned char *data, int length); 29 | void CRC_ContinueProcessString(unsigned short *crc, char *data, int length); 30 | -------------------------------------------------------------------------------- /deps/qcommon/vm_sparc.h: -------------------------------------------------------------------------------- 1 | #ifndef VM_SPARC_H 2 | #define VM_SPARC_H 3 | 4 | /* integer regs */ 5 | #define G0 0 6 | #define G1 1 7 | #define G2 2 8 | #define G3 3 9 | #define G4 4 10 | #define G5 5 11 | #define G6 6 12 | #define G7 7 13 | #define O0 8 14 | #define O1 9 15 | #define O2 10 16 | #define O3 11 17 | #define O4 12 18 | #define O5 13 19 | #define O6 14 20 | #define O7 15 21 | #define L0 16 22 | #define L1 17 23 | #define L2 18 24 | #define L3 19 25 | #define L4 20 26 | #define L5 21 27 | #define L6 22 28 | #define L7 23 29 | #define I0 24 30 | #define I1 25 31 | #define I2 26 32 | #define I3 27 33 | #define I4 28 34 | #define I5 29 35 | #define I6 30 36 | #define I7 31 37 | 38 | /* float regs */ 39 | #define F0 0 40 | #define F1 1 41 | #define F2 2 42 | #define F3 3 43 | #define F4 4 44 | #define F5 5 45 | #define F6 6 46 | #define F7 7 47 | #define F8 8 48 | #define F9 9 49 | #define F10 10 50 | #define F11 11 51 | #define F12 12 52 | #define F13 13 53 | #define F14 14 54 | #define F15 15 55 | #define F16 16 56 | #define F17 17 57 | #define F18 18 58 | #define F19 19 59 | #define F20 20 60 | #define F21 21 61 | #define F22 22 62 | #define F23 23 63 | #define F24 24 64 | #define F25 25 65 | #define F26 26 66 | #define F27 27 67 | #define F28 28 68 | #define F29 29 69 | #define F30 30 70 | #define F31 31 71 | 72 | /* state registers */ 73 | #define Y_REG 0 74 | #define CCR_REG 2 75 | #define ASI_REG 3 76 | #define FPRS_REG 6 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /nodraw.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "qbsp.h" 24 | 25 | vec3_t draw_mins, draw_maxs; 26 | qboolean drawflag; 27 | 28 | void Draw_ClearWindow (void) 29 | { 30 | } 31 | 32 | //============================================================ 33 | 34 | #define GLSERV_PORT 25001 35 | 36 | 37 | void GLS_BeginScene (void) 38 | { 39 | } 40 | 41 | void GLS_Winding (winding_t *w, int code) 42 | { 43 | } 44 | 45 | void GLS_EndScene (void) 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /deps/botlib/be_ai_gen.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | 24 | /***************************************************************************** 25 | * name: be_ai_gen.h 26 | * 27 | * desc: genetic selection 28 | * 29 | * $Archive: /source/code/botlib/be_ai_gen.h $ 30 | * 31 | *****************************************************************************/ 32 | 33 | int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child); 34 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_cluster.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_cluster.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_cluster.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | //initialize the AAS clustering 34 | void AAS_InitClustering(void); 35 | // 36 | void AAS_SetViewPortalsAsClusterPortals(void); 37 | #endif //AASINTERN 38 | 39 | -------------------------------------------------------------------------------- /deps/botlib/l_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: l_util.h 25 | * 26 | * desc: utils 27 | * 28 | * $Archive: /source/code/botlib/l_util.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #define Vector2Angles(v,a) vectoangles(v,a) 33 | #ifndef MAX_PATH 34 | #define MAX_PATH MAX_QPATH 35 | #endif 36 | #define Maximum(x,y) (x > y ? x : y) 37 | #define Minimum(x,y) (x < y ? x : y) 38 | -------------------------------------------------------------------------------- /Conscript: -------------------------------------------------------------------------------- 1 | # bspc compile 2 | 3 | Import qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK ); 4 | 5 | @BSPC_FILES = qw( 6 | aas_areamerging.c 7 | aas_cfg.c 8 | aas_create.c 9 | aas_edgemelting.c 10 | aas_facemerging.c 11 | aas_file.c 12 | aas_gsubdiv.c 13 | aas_map.c 14 | aas_prunenodes.c 15 | aas_store.c 16 | be_aas_bspc.c 17 | deps/botlib/be_aas_bspq3.c 18 | deps/botlib/be_aas_cluster.c 19 | deps/botlib/be_aas_move.c 20 | deps/botlib/be_aas_optimize.c 21 | deps/botlib/be_aas_reach.c 22 | deps/botlib/be_aas_sample.c 23 | brushbsp.c 24 | bspc.c 25 | deps/qcommon/cm_load.c 26 | deps/qcommon/cm_patch.c 27 | deps/qcommon/cm_test.c 28 | deps/qcommon/cm_trace.c 29 | csg.c 30 | glfile.c 31 | l_bsp_ent.c 32 | l_bsp_hl.c 33 | l_bsp_q1.c 34 | l_bsp_q2.c 35 | l_bsp_q3.c 36 | l_bsp_sin.c 37 | l_cmd.c 38 | deps/botlib/l_libvar.c 39 | l_log.c 40 | l_math.c 41 | l_mem.c 42 | l_poly.c 43 | deps/botlib/l_precomp.c 44 | l_qfiles.c 45 | deps/botlib/l_script.c 46 | deps/botlib/l_struct.c 47 | l_threads.c 48 | l_utils.c 49 | leakfile.c 50 | map.c 51 | map_hl.c 52 | map_q1.c 53 | map_q2.c 54 | map_q3.c 55 | map_sin.c 56 | deps/qcommon/md4.c 57 | nodraw.c 58 | portals.c 59 | textures.c 60 | tree.c 61 | deps/qcommon/unzip.c 62 | ); 63 | $BSPC_REF = \@BSPC_FILES; 64 | 65 | $env = new cons( 66 | CC => $CC, 67 | CXX => $CXX, 68 | LINK => $LINK, 69 | CFLAGS => $BSPC_BASE_CFLAGS, 70 | LIBS => '-ldl -lm -lpthread' 71 | ); 72 | 73 | Program $env 'bspc', @$BSPC_REF; 74 | # this should install to Q3 or something? 75 | Install $env $INSTALL_DIR, 'bspc'; 76 | -------------------------------------------------------------------------------- /l_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | //open a log file 24 | void Log_Open(char *filename); 25 | //close the current log file 26 | void Log_Close(void); 27 | //close log file if present 28 | void Log_Shutdown(void); 29 | //print on stdout and write to the current opened log file 30 | void Log_Print(char *fmt, ...); 31 | //write to the current opened log file 32 | void Log_Write(char *fmt, ...); 33 | //write to the current opened log file with a time stamp 34 | void Log_WriteTimeStamped(char *fmt, ...); 35 | //returns the log file structure 36 | FILE *Log_FileStruct(void); 37 | //flush log file 38 | void Log_Flush(void); 39 | 40 | #ifdef WINBSPC 41 | void WinBSPCPrint(char *str); 42 | #endif //WINBSPC 43 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_file.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_file.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | //loads the AAS file with the given name 34 | int AAS_LoadAASFile(char *filename); 35 | //writes an AAS file with the given name 36 | qboolean AAS_WriteAASFile(char *filename); 37 | //dumps the loaded AAS data 38 | void AAS_DumpAASData(void); 39 | //print AAS file information 40 | void AAS_FileInfo(void); 41 | #endif //AASINTERN 42 | 43 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_routealt.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_routealt.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_routealt.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | void AAS_InitAlternativeRouting(void); 34 | void AAS_ShutdownAlternativeRouting(void); 35 | #endif //AASINTERN 36 | 37 | 38 | int AAS_AlternativeRouteGoals(vec3_t start, int startareanum, vec3_t goal, int goalareanum, int travelflags, 39 | aas_altroutegoal_t *altroutegoals, int maxaltroutegoals, 40 | int type); 41 | -------------------------------------------------------------------------------- /deps/qcommon/puff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a modified version of Mark Adlers work, 3 | * see below for the original copyright. 4 | * 2006 - Joerg Dietrich 5 | */ 6 | 7 | /* puff.h 8 | Copyright (C) 2002, 2003 Mark Adler, all rights reserved 9 | version 1.7, 3 Mar 2002 10 | 11 | This software is provided 'as-is', without any express or implied 12 | warranty. In no event will the author be held liable for any damages 13 | arising from the use of this software. 14 | 15 | Permission is granted to anyone to use this software for any purpose, 16 | including commercial applications, and to alter it and redistribute it 17 | freely, subject to the following restrictions: 18 | 19 | 1. The origin of this software must not be misrepresented; you must not 20 | claim that you wrote the original software. If you use this software 21 | in a product, an acknowledgment in the product documentation would be 22 | appreciated but is not required. 23 | 2. Altered source versions must be plainly marked as such, and must not be 24 | misrepresented as being the original software. 25 | 3. This notice may not be removed or altered from any source distribution. 26 | 27 | Mark Adler madler@alumni.caltech.edu 28 | */ 29 | 30 | #ifndef __PUFF_H 31 | #define __PUFF_H 32 | 33 | #include "q_shared.h" /* for definitions of the types */ 34 | 35 | /* 36 | * See puff.c for purpose and usage. 37 | */ 38 | int32_t puff(uint8_t *dest, /* pointer to destination pointer */ 39 | uint32_t *destlen, /* amount of output space */ 40 | uint8_t *source, /* pointer to source data pointer */ 41 | uint32_t *sourcelen); /* amount of input available */ 42 | 43 | #endif // __PUFF_H 44 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_funcs.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_funcs.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_funcs.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifndef BSPCINCLUDE 33 | 34 | #include "be_aas_main.h" 35 | #include "be_aas_entity.h" 36 | #include "be_aas_sample.h" 37 | #include "be_aas_cluster.h" 38 | #include "be_aas_reach.h" 39 | #include "be_aas_route.h" 40 | #include "be_aas_routealt.h" 41 | #include "be_aas_debug.h" 42 | #include "be_aas_file.h" 43 | #include "be_aas_optimize.h" 44 | #include "be_aas_bsp.h" 45 | #include "be_aas_move.h" 46 | 47 | #endif //BSPCINCLUDE 48 | -------------------------------------------------------------------------------- /l_threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | extern int numthreads; 24 | 25 | void ThreadSetDefault (void); 26 | int GetThreadWork (void); 27 | void RunThreadsOnIndividual (int workcnt, qboolean showpacifier, void(*func)(int)); 28 | void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int)); 29 | 30 | //mutex 31 | void ThreadSetupLock(void); 32 | void ThreadShutdownLock(void); 33 | void ThreadLock (void); 34 | void ThreadUnlock (void); 35 | //semaphore 36 | void ThreadSetupSemaphore(void); 37 | void ThreadShutdownSemaphore(void); 38 | void ThreadSemaphoreWait(void); 39 | void ThreadSemaphoreIncrease(int count); 40 | //add/remove threads 41 | void AddThread(void (*func)(int)); 42 | void RemoveThread(int threadid); 43 | void WaitForAllThreadsFinished(void); 44 | int GetNumThreads(void); 45 | 46 | -------------------------------------------------------------------------------- /deps/botlib/l_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: l_log.h 25 | * 26 | * desc: log file 27 | * 28 | * $Archive: /source/code/botlib/l_log.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | //open a log file 33 | void Log_Open(char *filename); 34 | //close the current log file 35 | void Log_Close(void); 36 | //close log file if present 37 | void Log_Shutdown(void); 38 | //write to the current opened log file 39 | void QDECL Log_Write(char *fmt, ...); 40 | //write to the current opened log file with a time stamp 41 | void QDECL Log_WriteTimeStamped(char *fmt, ...); 42 | //returns a pointer to the log file 43 | FILE *Log_FilePointer(void); 44 | //flush log file 45 | void Log_Flush(void); 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bspc 2 | 3 | This is the [Quake III: Arena](http://www.idsoftware.com/games/quake/quake3-arena/) BSP-to-AAS compiler. 4 | 5 | ## Downloading 6 | 7 | You can download the latest version [here](https://github.com/bnoordhuis/bspc). 8 | 9 | ## Compiling 10 | 11 | Dead simple: 12 | 13 | make 14 | 15 | ## Usage 16 | 17 | Straight from the source: 18 | 19 | Usage: bspc [- [- ...]] 20 | Example 1: bspc -bsp2aas /quake3/baseq3/maps/mymap?.bsp 21 | Example 2: bspc -bsp2aas /quake3/baseq3/pak0.pk3/maps/q3dm*.bsp 22 | 23 | Switches: 24 | bsp2aas <[pakfilter/]filter.bsp> = convert BSP to AAS 25 | reach = compute reachability & clusters 26 | cluster = compute clusters 27 | aasopt = optimize aas file 28 | aasinfo = show AAS file info 29 | output = set output path 30 | threads = set number of threads to X 31 | cfg = use this cfg file 32 | optimize = enable optimization 33 | noverbose = disable verbose output 34 | breadthfirst = breadth first bsp building 35 | nobrushmerge = don't merge brushes 36 | noliquids = don't write liquids to map 37 | freetree = free the bsp tree 38 | nocsg = disables brush chopping 39 | forcesidesvisible = force all sides to be visible 40 | grapplereach = calculate grapple reachabilities 41 | 42 | ## Support 43 | 44 | [File a bug report](https://github.com/bnoordhuis/bspc/issues) if you run into issues. 45 | 46 | ## License 47 | 48 | This program is licensed under the GNU Public License v2.0 and any later version. 49 | -------------------------------------------------------------------------------- /l_mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | 24 | //============================================================================= 25 | 26 | // memory.h 27 | //#define MEMDEBUG 28 | #undef MEMDEBUG 29 | 30 | #ifndef MEMDEBUG 31 | 32 | void *GetClearedMemory(int size); 33 | void *GetMemory(unsigned long size); 34 | 35 | #else 36 | 37 | #define GetMemory(size) GetMemoryDebug(size, #size, __FILE__, __LINE__); 38 | #define GetClearedMemory(size) GetClearedMemoryDebug(size, #size, __FILE__, __LINE__); 39 | //allocate a memory block of the given size 40 | void *GetMemoryDebug(unsigned long size, char *label, char *file, int line); 41 | //allocate a memory block of the given size and clear it 42 | void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line); 43 | // 44 | void PrintMemoryLabels(void); 45 | #endif //MEMDEBUG 46 | 47 | void FreeMemory(void *ptr); 48 | int MemorySize(void *ptr); 49 | void PrintMemorySize(unsigned long size); 50 | int TotalAllocatedMemory(void); 51 | 52 | -------------------------------------------------------------------------------- /l_bsp_ent.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #ifndef MAX_MAP_ENTITIES 24 | #define MAX_MAP_ENTITIES 2048 25 | #endif 26 | 27 | typedef struct epair_s 28 | { 29 | struct epair_s *next; 30 | char *key; 31 | char *value; 32 | } epair_t; 33 | 34 | typedef struct 35 | { 36 | vec3_t origin; 37 | int firstbrush; 38 | int numbrushes; 39 | epair_t *epairs; 40 | // only valid for func_areaportals 41 | int areaportalnum; 42 | int portalareas[2]; 43 | int modelnum; //for bsp 2 map conversion 44 | qboolean wasdetail; //for SIN 45 | } entity_t; 46 | 47 | extern int num_entities; 48 | extern entity_t entities[MAX_MAP_ENTITIES]; 49 | 50 | void StripTrailing(char *e); 51 | void SetKeyValue(entity_t *ent, char *key, char *value); 52 | char *ValueForKey(entity_t *ent, char *key); // will return "" if not present 53 | vec_t FloatForKey(entity_t *ent, char *key); 54 | void GetVectorForKey(entity_t *ent, char *key, vec3_t vec); 55 | qboolean ParseEntity(script_t *script); 56 | epair_t *ParseEpair(script_t *script); 57 | void PrintEntity(entity_t *ent); 58 | 59 | -------------------------------------------------------------------------------- /deps/botlib/linux-i386.mak: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Gladiator Bot library: gladiator.so 3 | # Intended for gcc/Linux 4 | # 5 | 6 | ARCH=i386 7 | CC=gcc 8 | BASE_CFLAGS=-Dstricmp=strcasecmp 9 | 10 | #use these cflags to optimize it 11 | CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \ 12 | -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \ 13 | -malign-jumps=2 -malign-functions=2 14 | #use these when debugging 15 | #CFLAGS=$(BASE_CFLAGS) -g 16 | 17 | LDFLAGS=-ldl -lm 18 | SHLIBEXT=so 19 | SHLIBCFLAGS=-fPIC 20 | SHLIBLDFLAGS=-shared 21 | 22 | DO_CC=$(CC) $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< 23 | 24 | ############################################################################# 25 | # SETUP AND BUILD 26 | # GLADIATOR BOT 27 | ############################################################################# 28 | 29 | .c.o: 30 | $(DO_CC) 31 | 32 | GAME_OBJS = \ 33 | be_aas_bsphl.o\ 34 | be_aas_bspq2.o\ 35 | be_aas_cluster.o\ 36 | be_aas_debug.o\ 37 | be_aas_entity.o\ 38 | be_aas_file.o\ 39 | be_aas_light.o\ 40 | be_aas_main.o\ 41 | be_aas_move.o\ 42 | be_aas_optimize.o\ 43 | be_aas_reach.o\ 44 | be_aas_route.o\ 45 | be_aas_routealt.o\ 46 | be_aas_sample.o\ 47 | be_aas_sound.o\ 48 | be_ai2_dmq2.o\ 49 | be_ai2_dmhl.o\ 50 | be_ai2_dmnet.o\ 51 | be_ai2_main.o\ 52 | be_ai_char.o\ 53 | be_ai_chat.o\ 54 | be_ai_goal.o\ 55 | be_ai_load.o\ 56 | be_ai_move.o\ 57 | be_ai_weap.o\ 58 | be_ai_weight.o\ 59 | be_ea.o\ 60 | be_interface.o\ 61 | l_crc.o\ 62 | l_libvar.o\ 63 | l_log.o\ 64 | l_memory.o\ 65 | l_precomp.o\ 66 | l_script.o\ 67 | l_struct.o\ 68 | l_utils.o\ 69 | q_shared.o 70 | 71 | glad$(ARCH).$(SHLIBEXT) : $(GAME_OBJS) 72 | $(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(GAME_OBJS) 73 | 74 | 75 | ############################################################################# 76 | # MISC 77 | ############################################################################# 78 | 79 | clean: 80 | -rm -f $(GAME_OBJS) 81 | 82 | depend: 83 | gcc -MM $(GAME_OBJS:.o=.c) 84 | 85 | 86 | install: 87 | cp gladiator.so .. 88 | 89 | # 90 | # From "make depend" 91 | # 92 | 93 | -------------------------------------------------------------------------------- /deps/botlib/be_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_interface.h 25 | * 26 | * desc: botlib interface 27 | * 28 | * $Archive: /source/code/botlib/be_interface.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | //#define DEBUG //debug code 33 | #define RANDOMIZE //randomize bot behaviour 34 | 35 | //FIXME: get rid of this global structure 36 | typedef struct botlib_globals_s 37 | { 38 | int botlibsetup; //true when the bot library has been setup 39 | int maxentities; //maximum number of entities 40 | int maxclients; //maximum number of clients 41 | float time; //the global time 42 | #ifdef DEBUG 43 | qboolean debug; //true if debug is on 44 | int goalareanum; 45 | vec3_t goalorigin; 46 | int runai; 47 | #endif 48 | } botlib_globals_t; 49 | 50 | 51 | extern botlib_globals_t botlibglobals; 52 | extern botlib_import_t botimport; 53 | extern int botDeveloper; //true if developer is on 54 | 55 | // 56 | int Sys_MilliSeconds(void); 57 | 58 | -------------------------------------------------------------------------------- /deps/botlib/be_ai_char.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | 24 | /***************************************************************************** 25 | * name: be_ai_char.h 26 | * 27 | * desc: bot characters 28 | * 29 | * $Archive: /source/code/botlib/be_ai_char.h $ 30 | * 31 | *****************************************************************************/ 32 | 33 | //loads a bot character from a file 34 | int BotLoadCharacter(char *charfile, float skill); 35 | //frees a bot character 36 | void BotFreeCharacter(int character); 37 | //returns a float characteristic 38 | float Characteristic_Float(int character, int index); 39 | //returns a bounded float characteristic 40 | float Characteristic_BFloat(int character, int index, float min, float max); 41 | //returns an integer characteristic 42 | int Characteristic_Integer(int character, int index); 43 | //returns a bounded integer characteristic 44 | int Characteristic_BInteger(int character, int index, int min, int max); 45 | //returns a string characteristic 46 | void Characteristic_String(int character, int index, char *buf, int size); 47 | //free cached bot characters 48 | void BotShutdownCharacters(void); 49 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_main.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_main.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | 34 | extern aas_t aasworld; 35 | 36 | //AAS error message 37 | void QDECL AAS_Error(char *fmt, ...); 38 | //set AAS initialized 39 | void AAS_SetInitialized(void); 40 | //setup AAS with the given number of entities and clients 41 | int AAS_Setup(void); 42 | //shutdown AAS 43 | void AAS_Shutdown(void); 44 | //start a new map 45 | int AAS_LoadMap(const char *mapname); 46 | //start a new time frame 47 | int AAS_StartFrame(float time); 48 | #endif //AASINTERN 49 | 50 | //returns true if AAS is initialized 51 | int AAS_Initialized(void); 52 | //returns true if the AAS file is loaded 53 | int AAS_Loaded(void); 54 | //returns the model name from the given index 55 | char *AAS_ModelFromIndex(int index); 56 | //returns the index from the given model name 57 | int AAS_IndexFromModel(char *modelname); 58 | //returns the current time 59 | float AAS_Time(void); 60 | // 61 | void AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj ); 62 | -------------------------------------------------------------------------------- /_files.c: -------------------------------------------------------------------------------- 1 | //=========================================================================== 2 | // 3 | // Name: _files.c 4 | // Function: 5 | // Programmer: Mr Elusive 6 | // Last update: 1999-12-02 7 | // Tab Size: 4 8 | //=========================================================================== 9 | 10 | /* 11 | 12 | aas_areamerging.c //AAS area merging 13 | aas_cfg.c //AAS configuration for different games 14 | aas_create.c //AAS creating 15 | aas_edgemelting.c //AAS edge melting 16 | aas_facemerging.c //AAS face merging 17 | aas_file.c //AAS file writing 18 | aas_gsubdiv.c //AAS gravitational and ladder subdivision 19 | aas_map.c //AAS map brush creation 20 | aas_prunenodes.c //AAS node pruning 21 | aas_store.c //AAS file storing 22 | 23 | map.c //map file loading and writing 24 | map_hl.c //Half-Life map loading 25 | map_q1.c //Quake1 map loading 26 | map_q2.c //Quake2 map loading 27 | map_q3.c //Quake3 map loading 28 | map_sin.c //Sin map loading 29 | tree.c //BSP tree management + node pruning (*) 30 | brushbsp.c //brush bsp creation (*) 31 | portals.c //BSP portal creation and leaf filling (*) 32 | csg.c //Constructive Solid Geometry brush chopping (*) 33 | leakfile.c //leak file writing (*) 34 | textures.c //Quake2 BSP textures (*) 35 | 36 | l_bsp_ent.c //BSP entity parsing 37 | l_bsp_hl.c //Half-Life BSP loading and writing 38 | l_bsp_q1.c //Quake1 BSP loading and writing 39 | l_bsp_q2.c //Quake2 BSP loading and writing 40 | l_bsp_q3.c //Quake2 BSP loading and writing 41 | l_bsp_sin.c //Sin BSP loading and writing 42 | l_cmd.c //cmd library 43 | l_log.c //log file library 44 | l_math.c //math library 45 | l_mem.c //memory management library 46 | l_poly.c //polygon (winding) library 47 | l_script.c //script file parsing library 48 | l_threads.c //multi-threading library 49 | l_utils.c //utility library 50 | l_qfiles.c //loading of quake files 51 | 52 | gldraw.c //GL drawing (*) 53 | glfile.c //GL file writing (*) 54 | nodraw.c //no draw module (*) 55 | 56 | bspc.c //BSPC Win32 console version 57 | winbspc.c //WinBSPC Win32 GUI version 58 | win32_terminal.c //Win32 terminal output 59 | win32_qfiles.c //Win32 game file management (also .pak .sin) 60 | win32_font.c //Win32 fonts 61 | win32_folder.c //Win32 folder dialogs 62 | 63 | */ 64 | -------------------------------------------------------------------------------- /aas_cfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #define BBOXFL_GROUNDED 1 //bounding box only valid when on ground 24 | #define BBOXFL_NOTGROUNDED 2 //bounding box only valid when NOT on ground 25 | 26 | typedef struct cfg_s 27 | { 28 | int numbboxes; //number of bounding boxes 29 | aas_bbox_t bboxes[AAS_MAX_BBOXES]; //all the bounding boxes 30 | int allpresencetypes; //or of all presence types 31 | // aas settings 32 | vec3_t phys_gravitydirection; 33 | float phys_friction; 34 | float phys_stopspeed; 35 | float phys_gravity; 36 | float phys_waterfriction; 37 | float phys_watergravity; 38 | float phys_maxvelocity; 39 | float phys_maxwalkvelocity; 40 | float phys_maxcrouchvelocity; 41 | float phys_maxswimvelocity; 42 | float phys_walkaccelerate; 43 | float phys_airaccelerate; 44 | float phys_swimaccelerate; 45 | float phys_maxstep; 46 | float phys_maxsteepness; 47 | float phys_maxwaterjump; 48 | float phys_maxbarrier; 49 | float phys_jumpvel; 50 | float phys_falldelta5; 51 | float phys_falldelta10; 52 | float rs_waterjump; 53 | float rs_teleport; 54 | float rs_barrierjump; 55 | float rs_startcrouch; 56 | float rs_startgrapple; 57 | float rs_startwalkoffledge; 58 | float rs_startjump; 59 | float rs_rocketjump; 60 | float rs_bfgjump; 61 | float rs_jumppad; 62 | float rs_aircontrolledjumppad; 63 | float rs_funcbob; 64 | float rs_startelevator; 65 | float rs_falldamage5; 66 | float rs_falldamage10; 67 | float rs_maxjumpfallheight; 68 | } cfg_t; 69 | 70 | extern cfg_t cfg; 71 | 72 | void DefaultCfg(void); 73 | int LoadCfgFile(char *filename); 74 | -------------------------------------------------------------------------------- /deps/botlib/be_ea.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | 24 | /***************************************************************************** 25 | * name: be_ea.h 26 | * 27 | * desc: elementary actions 28 | * 29 | * $Archive: /source/code/botlib/be_ea.h $ 30 | * 31 | *****************************************************************************/ 32 | 33 | //ClientCommand elementary actions 34 | void EA_Say(int client, char *str); 35 | void EA_SayTeam(int client, char *str); 36 | void EA_Command(int client, char *command ); 37 | 38 | void EA_Action(int client, int action); 39 | void EA_Crouch(int client); 40 | void EA_Walk(int client); 41 | void EA_MoveUp(int client); 42 | void EA_MoveDown(int client); 43 | void EA_MoveForward(int client); 44 | void EA_MoveBack(int client); 45 | void EA_MoveLeft(int client); 46 | void EA_MoveRight(int client); 47 | void EA_Attack(int client); 48 | void EA_Respawn(int client); 49 | void EA_Talk(int client); 50 | void EA_Gesture(int client); 51 | void EA_Use(int client); 52 | 53 | //regular elementary actions 54 | void EA_SelectWeapon(int client, int weapon); 55 | void EA_Jump(int client); 56 | void EA_DelayedJump(int client); 57 | void EA_Move(int client, vec3_t dir, float speed); 58 | void EA_View(int client, vec3_t viewangles); 59 | 60 | //send regular input to the server 61 | void EA_EndRegular(int client, float thinktime); 62 | void EA_GetInput(int client, float thinktime, bot_input_t *input); 63 | void EA_ResetInput(int client); 64 | //setup and shutdown routines 65 | int EA_Setup(void); 66 | void EA_Shutdown(void); 67 | -------------------------------------------------------------------------------- /linux-i386.mak: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the BSPC tool for the Gladiator Bot 3 | # Intended for gcc/Linux 4 | # 5 | 6 | ARCH=i386 7 | CC=gcc 8 | BASE_CFLAGS=-Dstricmp=strcasecmp 9 | 10 | #use these cflags to optimize it 11 | CFLAGS=$(BASE_CFLAGS) -m486 -O6 -ffast-math -funroll-loops \ 12 | -fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \ 13 | -malign-jumps=2 -malign-functions=2 -DLINUX -DBSPC 14 | #use these when debugging 15 | #CFLAGS=$(BASE_CFLAGS) -g 16 | 17 | LDFLAGS=-ldl -lm -lpthread 18 | 19 | DO_CC=$(CC) $(CFLAGS) -o $@ -c $< 20 | 21 | ############################################################################# 22 | # SETUP AND BUILD BSPC 23 | ############################################################################# 24 | 25 | .c.o: 26 | $(DO_CC) 27 | 28 | GAME_OBJS = \ 29 | _files.o\ 30 | aas_areamerging.o\ 31 | aas_cfg.o\ 32 | aas_create.o\ 33 | aas_edgemelting.o\ 34 | aas_facemerging.o\ 35 | aas_file.o\ 36 | aas_gsubdiv.o\ 37 | aas_map.o\ 38 | aas_prunenodes.o\ 39 | aas_store.o\ 40 | be_aas_bspc.o\ 41 | deps/botlib/be_aas_bspq3.o\ 42 | deps/botlib/be_aas_cluster.o\ 43 | deps/botlib/be_aas_move.o\ 44 | deps/botlib/be_aas_optimize.o\ 45 | deps/botlib/be_aas_reach.o\ 46 | deps/botlib/be_aas_sample.o\ 47 | brushbsp.o\ 48 | bspc.o\ 49 | deps/qcommon/cm_load.o\ 50 | deps/qcommon/cm_patch.o\ 51 | deps/qcommon/cm_test.o\ 52 | deps/qcommon/cm_trace.o\ 53 | csg.o\ 54 | glfile.o\ 55 | l_bsp_ent.o\ 56 | l_bsp_hl.o\ 57 | l_bsp_q1.o\ 58 | l_bsp_q2.o\ 59 | l_bsp_q3.o\ 60 | l_bsp_sin.o\ 61 | l_cmd.o\ 62 | deps/botlib/l_libvar.o\ 63 | l_log.o\ 64 | l_math.o\ 65 | l_mem.o\ 66 | l_poly.o\ 67 | deps/botlib/l_precomp.o\ 68 | l_qfiles.o\ 69 | deps/botlib/l_script.o\ 70 | deps/botlib/l_struct.o\ 71 | l_threads.o\ 72 | l_utils.o\ 73 | leakfile.o\ 74 | map.o\ 75 | map_hl.o\ 76 | map_q1.o\ 77 | map_q2.o\ 78 | map_q3.o\ 79 | map_sin.o\ 80 | deps/qcommon/md4.o\ 81 | nodraw.o\ 82 | portals.o\ 83 | tetrahedron.o\ 84 | textures.o\ 85 | tree.o\ 86 | deps/qcommon/unzip.o 87 | 88 | bspc$(ARCH) : $(GAME_OBJS) 89 | $(CC) $(CFLAGS) -o $@ $(GAME_OBJS) $(LDFLAGS) 90 | 91 | 92 | ############################################################################# 93 | # MISC 94 | ############################################################################# 95 | 96 | clean: 97 | -rm -f $(GAME_OBJS) 98 | 99 | depend: 100 | gcc -MM $(GAME_OBJS:.o=.c) 101 | 102 | 103 | install: 104 | cp bspci386 .. 105 | 106 | # 107 | # From "make depend" 108 | # 109 | 110 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CFLAGS=\ 3 | -Dstricmp=strcasecmp -DCom_Memcpy=memcpy -DCom_Memset=memset \ 4 | -DMAC_STATIC= -DQDECL= -DLINUX -DBSPC -D_FORTIFY_SOURCE=2 \ 5 | -I. -Ideps -Wall 6 | 7 | RELEASE_CFLAGS=-O3 -ffast-math 8 | DEBUG_CFLAGS=-g -O0 -ffast-math 9 | LDFLAGS=-lm -lpthread 10 | 11 | DO_CC=$(CC) $(CFLAGS) -o $@ -c $< 12 | 13 | ############################################################################# 14 | # SETUP AND BUILD BSPC 15 | ############################################################################# 16 | 17 | .c.o: 18 | $(DO_CC) 19 | 20 | GAME_OBJS = \ 21 | _files.o\ 22 | aas_areamerging.o\ 23 | aas_cfg.o\ 24 | aas_create.o\ 25 | aas_edgemelting.o\ 26 | aas_facemerging.o\ 27 | aas_file.o\ 28 | aas_gsubdiv.o\ 29 | aas_map.o\ 30 | aas_prunenodes.o\ 31 | aas_store.o\ 32 | be_aas_bspc.o\ 33 | deps/botlib/be_aas_bspq3.o\ 34 | deps/botlib/be_aas_cluster.o\ 35 | deps/botlib/be_aas_move.o\ 36 | deps/botlib/be_aas_optimize.o\ 37 | deps/botlib/be_aas_reach.o\ 38 | deps/botlib/be_aas_sample.o\ 39 | brushbsp.o\ 40 | bspc.o\ 41 | deps/qcommon/cm_load.o\ 42 | deps/qcommon/cm_patch.o\ 43 | deps/qcommon/cm_test.o\ 44 | deps/qcommon/cm_trace.o\ 45 | csg.o\ 46 | glfile.o\ 47 | l_bsp_ent.o\ 48 | l_bsp_hl.o\ 49 | l_bsp_q1.o\ 50 | l_bsp_q2.o\ 51 | l_bsp_q3.o\ 52 | l_bsp_sin.o\ 53 | l_cmd.o\ 54 | deps/botlib/l_libvar.o\ 55 | l_log.o\ 56 | l_math.o\ 57 | l_mem.o\ 58 | l_poly.o\ 59 | deps/botlib/l_precomp.o\ 60 | l_qfiles.o\ 61 | deps/botlib/l_script.o\ 62 | deps/botlib/l_struct.o\ 63 | l_threads.o\ 64 | l_utils.o\ 65 | leakfile.o\ 66 | map.o\ 67 | map_hl.o\ 68 | map_q1.o\ 69 | map_q2.o\ 70 | map_q3.o\ 71 | map_sin.o\ 72 | deps/qcommon/md4.o\ 73 | nodraw.o\ 74 | portals.o\ 75 | textures.o\ 76 | tree.o\ 77 | deps/qcommon/unzip.o 78 | 79 | #tetrahedron.o 80 | 81 | EXEC = bspc 82 | 83 | all: release 84 | 85 | debug: CFLAGS += $(DEBUG_CFLAGS) 86 | debug: $(EXEC)_g 87 | 88 | release: CFLAGS += $(RELEASE_CFLAGS) 89 | release: $(EXEC) 90 | 91 | $(EXEC): $(GAME_OBJS) 92 | $(CC) -o $@ $(GAME_OBJS) $(LDFLAGS) 93 | strip $@ 94 | 95 | $(EXEC)_g: $(GAME_OBJS) 96 | $(CC) -o $@ $(GAME_OBJS) $(LDFLAGS) 97 | 98 | ############################################################################# 99 | # MISC 100 | ############################################################################# 101 | .PHONY: clean depend 102 | 103 | clean: 104 | -rm -f $(GAME_OBJS) $(EXEC) $(EXEC)_g 105 | 106 | depend: 107 | $(CC) $(CFLAGS) -MM $(GAME_OBJS:.o=.c) > .deps 108 | 109 | include .deps 110 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_debug.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_debug.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | //clear the shown debug lines 33 | void AAS_ClearShownDebugLines(void); 34 | // 35 | void AAS_ClearShownPolygons(void); 36 | //show a debug line 37 | void AAS_DebugLine(vec3_t start, vec3_t end, int color); 38 | //show a permenent line 39 | void AAS_PermanentLine(vec3_t start, vec3_t end, int color); 40 | //show a permanent cross 41 | void AAS_DrawPermanentCross(vec3_t origin, float size, int color); 42 | //draw a cross in the plane 43 | void AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color); 44 | //show a bounding box 45 | void AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs); 46 | //show a face 47 | void AAS_ShowFace(int facenum); 48 | //show an area 49 | void AAS_ShowArea(int areanum, int groundfacesonly); 50 | // 51 | void AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly); 52 | //draw a cros 53 | void AAS_DrawCross(vec3_t origin, float size, int color); 54 | //print the travel type 55 | void AAS_PrintTravelType(int traveltype); 56 | //draw an arrow 57 | void AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor); 58 | //visualize the given reachability 59 | void AAS_ShowReachability(struct aas_reachability_s *reach); 60 | //show the reachable areas from the given area 61 | void AAS_ShowReachableAreas(int areanum); 62 | 63 | -------------------------------------------------------------------------------- /deps/botlib/l_libvar.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: l_libvar.h 25 | * 26 | * desc: botlib vars 27 | * 28 | * $Archive: /source/code/botlib/l_libvar.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | //library variable 33 | typedef struct libvar_s 34 | { 35 | char *name; 36 | char *string; 37 | int flags; 38 | qboolean modified; // set each time the cvar is changed 39 | float value; 40 | struct libvar_s *next; 41 | } libvar_t; 42 | 43 | //removes all library variables 44 | void LibVarDeAllocAll(void); 45 | //gets the library variable with the given name 46 | libvar_t *LibVarGet(char *var_name); 47 | //gets the string of the library variable with the given name 48 | char *LibVarGetString(char *var_name); 49 | //gets the value of the library variable with the given name 50 | float LibVarGetValue(char *var_name); 51 | //creates the library variable if not existing already and returns it 52 | libvar_t *LibVar(char *var_name, char *value); 53 | //creates the library variable if not existing already and returns the value 54 | float LibVarValue(char *var_name, char *value); 55 | //creates the library variable if not existing already and returns the value string 56 | char *LibVarString(char *var_name, char *value); 57 | //sets the library variable 58 | void LibVarSet(char *var_name, char *value); 59 | //returns true if the library variable has been modified 60 | qboolean LibVarChanged(char *var_name); 61 | //sets the library variable to unmodified 62 | void LibVarSetNotModified(char *var_name); 63 | 64 | -------------------------------------------------------------------------------- /deps/qcommon/cm_polylib.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | // this is only used for visualization tools in cm_ debug functions 24 | 25 | typedef struct 26 | { 27 | int numpoints; 28 | vec3_t p[4]; // variable sized 29 | } winding_t; 30 | 31 | #define MAX_POINTS_ON_WINDING 64 32 | 33 | #define SIDE_FRONT 0 34 | #define SIDE_BACK 1 35 | #define SIDE_ON 2 36 | #define SIDE_CROSS 3 37 | 38 | #define CLIP_EPSILON 0.1f 39 | 40 | #define MAX_MAP_BOUNDS 65535 41 | 42 | // you can define on_epsilon in the makefile as tighter 43 | #ifndef ON_EPSILON 44 | #define ON_EPSILON 0.1f 45 | #endif 46 | 47 | winding_t *AllocWinding (int points); 48 | vec_t WindingArea (winding_t *w); 49 | void WindingCenter (winding_t *w, vec3_t center); 50 | void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, 51 | vec_t epsilon, winding_t **front, winding_t **back); 52 | winding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist); 53 | winding_t *CopyWinding (winding_t *w); 54 | winding_t *ReverseWinding (winding_t *w); 55 | winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist); 56 | void CheckWinding (winding_t *w); 57 | void WindingPlane (winding_t *w, vec3_t normal, vec_t *dist); 58 | void RemoveColinearPoints (winding_t *w); 59 | int WindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist); 60 | void FreeWinding (winding_t *w); 61 | void WindingBounds (winding_t *w, vec3_t mins, vec3_t maxs); 62 | 63 | void AddWindingToConvexHull( winding_t *w, winding_t **hull, vec3_t normal ); 64 | 65 | void ChopWindingInPlace (winding_t **w, vec3_t normal, vec_t dist, vec_t epsilon); 66 | // frees the original if clipped 67 | 68 | void pw(winding_t *w); 69 | -------------------------------------------------------------------------------- /cfgq3.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | //=========================================================================== 23 | // BSPC configuration file 24 | // Quake3 25 | //=========================================================================== 26 | 27 | #define PRESENCE_NONE 1 28 | #define PRESENCE_NORMAL 2 29 | #define PRESENCE_CROUCH 4 30 | 31 | bbox //30x30x56 32 | { 33 | presencetype PRESENCE_NORMAL 34 | flags 0x0000 35 | mins {-15, -15, -24} 36 | maxs {15, 15, 32} 37 | } //end bbox 38 | 39 | bbox //30x30x40 40 | { 41 | presencetype PRESENCE_CROUCH 42 | flags 0x0001 43 | mins {-15, -15, -24} 44 | maxs {15, 15, 16} 45 | } //end bbox 46 | 47 | settings 48 | { 49 | phys_gravitydirection {0, 0, -1} 50 | phys_friction 6 51 | phys_stopspeed 100 52 | phys_gravity 800 53 | phys_waterfriction 1 54 | phys_watergravity 400 55 | phys_maxvelocity 320 56 | phys_maxwalkvelocity 320 57 | phys_maxcrouchvelocity 100 58 | phys_maxswimvelocity 150 59 | phys_maxacceleration 2200 60 | phys_airaccelerate 0 61 | phys_maxstep 18 62 | phys_maxsteepness 0.7 63 | phys_maxwaterjump 19 64 | phys_maxbarrier 33 65 | phys_jumpvel 270 66 | phys_falldelta5 40 67 | phys_falldelta10 60 68 | rs_waterjump 400 69 | rs_teleport 50 70 | rs_barrierjump 100 71 | rs_startcrouch 300 72 | rs_startgrapple 500 73 | rs_startwalkoffledge 70 74 | rs_startjump 300 75 | rs_rocketjump 500 76 | rs_bfgjump 500 77 | rs_jumppad 250 78 | rs_aircontrolledjumppad 300 79 | rs_funcbob 300 80 | rs_startelevator 50 81 | rs_falldamage5 300 82 | rs_falldamage10 500 83 | rs_maxjumpfallheight 450 84 | } //end settings 85 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_entity.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_entity.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_entity.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | //invalidates all entity infos 34 | void AAS_InvalidateEntities(void); 35 | //unlink not updated entities 36 | void AAS_UnlinkInvalidEntities(void); 37 | //resets the entity AAS and BSP links (sets areas and leaves pointers to NULL) 38 | void AAS_ResetEntityLinks(void); 39 | //updates an entity 40 | int AAS_UpdateEntity(int ent, bot_entitystate_t *state); 41 | //gives the entity data used for collision detection 42 | void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata); 43 | #endif //AASINTERN 44 | 45 | //returns the size of the entity bounding box in mins and maxs 46 | void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs); 47 | //returns the BSP model number of the entity 48 | int AAS_EntityModelNum(int entnum); 49 | //returns the origin of an entity with the given model number 50 | int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin); 51 | //returns the best reachable area the entity is situated in 52 | int AAS_BestReachableEntityArea(int entnum); 53 | //returns the info of the given entity 54 | void AAS_EntityInfo(int entnum, aas_entityinfo_t *info); 55 | //returns the next entity 56 | int AAS_NextEntity(int entnum); 57 | //returns the origin of the entity 58 | void AAS_EntityOrigin(int entnum, vec3_t origin); 59 | //returns the entity type 60 | int AAS_EntityType(int entnum); 61 | //returns the model index of the entity 62 | int AAS_EntityModelindex(int entnum); 63 | 64 | -------------------------------------------------------------------------------- /deps/qcommon/ioapi.h: -------------------------------------------------------------------------------- 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip 2 | files using zlib + zip or unzip API 3 | 4 | Version 1.01e, February 12th, 2005 5 | 6 | Copyright (C) 1998-2005 Gilles Vollant 7 | */ 8 | 9 | #ifndef _ZLIBIOAPI_H 10 | #define _ZLIBIOAPI_H 11 | 12 | 13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) 14 | #define ZLIB_FILEFUNC_SEEK_END (2) 15 | #define ZLIB_FILEFUNC_SEEK_SET (0) 16 | 17 | #define ZLIB_FILEFUNC_MODE_READ (1) 18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) 19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) 20 | 21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) 22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) 23 | 24 | 25 | #ifndef ZCALLBACK 26 | 27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) 28 | #define ZCALLBACK CALLBACK 29 | #else 30 | #define ZCALLBACK 31 | #endif 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); 39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); 40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); 41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); 42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); 43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); 44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); 45 | 46 | typedef struct zlib_filefunc_def_s 47 | { 48 | open_file_func zopen_file; 49 | read_file_func zread_file; 50 | write_file_func zwrite_file; 51 | tell_file_func ztell_file; 52 | seek_file_func zseek_file; 53 | close_file_func zclose_file; 54 | testerror_file_func zerror_file; 55 | voidpf opaque; 56 | } zlib_filefunc_def; 57 | 58 | 59 | 60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); 61 | 62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) 63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) 64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) 65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) 66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) 67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) 68 | 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /deps/botlib/l_struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: l_struct.h 25 | * 26 | * desc: structure reading/writing 27 | * 28 | * $Archive: /source/code/botlib/l_struct.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #include 33 | 34 | #define MAX_STRINGFIELD 80 35 | //field types 36 | #define FT_CHAR 1 // char 37 | #define FT_INT 2 // int 38 | #define FT_FLOAT 3 // float 39 | #define FT_STRING 4 // char [MAX_STRINGFIELD] 40 | #define FT_STRUCT 6 // struct (sub structure) 41 | //type only mask 42 | #define FT_TYPE 0x00FF // only type, clear subtype 43 | //sub types 44 | #define FT_ARRAY 0x0100 // array of type 45 | #define FT_BOUNDED 0x0200 // bounded value 46 | #define FT_UNSIGNED 0x0400 47 | 48 | //structure field definition 49 | typedef struct fielddef_s 50 | { 51 | char *name; //name of the field 52 | size_t offset; //offset in the structure 53 | int type; //type of the field 54 | //type specific fields 55 | int maxarray; //maximum array size 56 | float floatmin, floatmax; //float min and max 57 | struct structdef_s *substruct; //sub structure 58 | } fielddef_t; 59 | 60 | //structure definition 61 | typedef struct structdef_s 62 | { 63 | int size; 64 | fielddef_t *fields; 65 | } structdef_t; 66 | 67 | //read a structure from a script 68 | int ReadStructure(source_t *source, structdef_t *def, char *structure); 69 | //write a structure to a file 70 | int WriteStructure(FILE *fp, structdef_t *def, char *structure); 71 | //writes indents 72 | int WriteIndent(FILE *fp, int indent); 73 | //writes a float without traling zeros 74 | int WriteFloat(FILE *fp, float value); 75 | 76 | 77 | -------------------------------------------------------------------------------- /l_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #ifndef MAX_PATH 24 | #define MAX_PATH 64 25 | #endif 26 | 27 | #ifndef PATH_SEPERATORSTR 28 | #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) 29 | #define PATHSEPERATOR_STR "\\" 30 | #else 31 | #define PATHSEPERATOR_STR "/" 32 | #endif 33 | #endif 34 | #ifndef PATH_SEPERATORCHAR 35 | #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) 36 | #define PATHSEPERATOR_CHAR '\\' 37 | #else 38 | #define PATHSEPERATOR_CHAR '/' 39 | #endif 40 | #endif 41 | 42 | //random in the range [0, 1] 43 | #define random() ((rand () & 0x7fff) / ((float)0x7fff)) 44 | //random in the range [-1, 1] 45 | #define crandom() (2.0 * (random() - 0.5)) 46 | //min and max 47 | #define Maximum(x,y) (x > y ? x : y) 48 | #define Minimum(x,y) (x < y ? x : y) 49 | //absolute value 50 | #define FloatAbs(x) (*(float *) &((* (int *) &(x)) & 0x7FFFFFFF)) 51 | #define IntAbs(x) (~(x)) 52 | //coordinates 53 | #define _X 0 54 | #define _Y 1 55 | #define _Z 2 56 | 57 | typedef struct foundfile_s 58 | { 59 | int offset; 60 | int length; 61 | char filename[MAX_PATH]; //screw LCC, array must be at end of struct 62 | } foundfile_t; 63 | 64 | void Vector2Angles(vec3_t value1, vec3_t angles); 65 | //set the correct path seperators 66 | void ConvertPath(char *path); 67 | //append a path seperator to the given path not exceeding the length 68 | void AppendPathSeperator(char *path, int length); 69 | //find a file in a pak file 70 | qboolean FindFileInPak(char *pakfile, char *filename, foundfile_t *file); 71 | //find a quake file 72 | #ifdef BOTLIB 73 | qboolean FindQuakeFile(char *filename, foundfile_t *file); 74 | #else //BOTLIB 75 | qboolean FindQuakeFile(char *basedir, char *gamedir, char *filename, foundfile_t *file); 76 | #endif //BOTLIB 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /l_bsp_q3.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "q3files.h" 24 | //#include "surfaceflags.h" 25 | 26 | extern int q3_nummodels; 27 | extern q3_dmodel_t *q3_dmodels;//[MAX_MAP_MODELS]; 28 | 29 | extern int q3_numShaders; 30 | extern q3_dshader_t *q3_dshaders;//[Q3_MAX_MAP_SHADERS]; 31 | 32 | extern int q3_entdatasize; 33 | extern char *q3_dentdata;//[Q3_MAX_MAP_ENTSTRING]; 34 | 35 | extern int q3_numleafs; 36 | extern q3_dleaf_t *q3_dleafs;//[Q3_MAX_MAP_LEAFS]; 37 | 38 | extern int q3_numplanes; 39 | extern q3_dplane_t *q3_dplanes;//[Q3_MAX_MAP_PLANES]; 40 | 41 | extern int q3_numnodes; 42 | extern q3_dnode_t *q3_dnodes;//[Q3_MAX_MAP_NODES]; 43 | 44 | extern int q3_numleafsurfaces; 45 | extern int *q3_dleafsurfaces;//[Q3_MAX_MAP_LEAFFACES]; 46 | 47 | extern int q3_numleafbrushes; 48 | extern int *q3_dleafbrushes;//[Q3_MAX_MAP_LEAFBRUSHES]; 49 | 50 | extern int q3_numbrushes; 51 | extern q3_dbrush_t *q3_dbrushes;//[Q3_MAX_MAP_BRUSHES]; 52 | 53 | extern int q3_numbrushsides; 54 | extern q3_dbrushside_t *q3_dbrushsides;//[Q3_MAX_MAP_BRUSHSIDES]; 55 | 56 | extern int q3_numLightBytes; 57 | extern byte *q3_lightBytes;//[Q3_MAX_MAP_LIGHTING]; 58 | 59 | extern int q3_numGridPoints; 60 | extern byte *q3_gridData;//[Q3_MAX_MAP_LIGHTGRID]; 61 | 62 | extern int q3_numVisBytes; 63 | extern byte *q3_visBytes;//[Q3_MAX_MAP_VISIBILITY]; 64 | 65 | extern int q3_numDrawVerts; 66 | extern q3_drawVert_t *q3_drawVerts;//[Q3_MAX_MAP_DRAW_VERTS]; 67 | 68 | extern int q3_numDrawIndexes; 69 | extern int *q3_drawIndexes;//[Q3_MAX_MAP_DRAW_INDEXES]; 70 | 71 | extern int q3_numDrawSurfaces; 72 | extern q3_dsurface_t *q3_drawSurfaces;//[Q3_MAX_MAP_DRAW_SURFS]; 73 | 74 | extern int q3_numFogs; 75 | extern q3_dfog_t *q3_dfogs;//[Q3_MAX_MAP_FOGS]; 76 | 77 | extern char q3_dbrushsidetextured[Q3_MAX_MAP_BRUSHSIDES]; 78 | 79 | void Q3_LoadBSPFile(struct quakefile_s *qf); 80 | void Q3_FreeMaxBSP(void); 81 | void Q3_ParseEntities (void); 82 | -------------------------------------------------------------------------------- /leakfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "qbsp.h" 24 | 25 | /* 26 | ============================================================================== 27 | 28 | LEAF FILE GENERATION 29 | 30 | Save out name.line for qe3 to read 31 | ============================================================================== 32 | */ 33 | 34 | 35 | /* 36 | ============= 37 | LeakFile 38 | 39 | Finds the shortest possible chain of portals 40 | that leads from the outside leaf to a specifically 41 | occupied leaf 42 | ============= 43 | */ 44 | void LeakFile (tree_t *tree) 45 | { 46 | vec3_t mid; 47 | FILE *linefile; 48 | char filename[1024]; 49 | node_t *node; 50 | int count; 51 | 52 | if (!tree->outside_node.occupied) 53 | return; 54 | 55 | qprintf ("--- LeakFile ---\n"); 56 | 57 | // 58 | // write the points to the file 59 | // 60 | sprintf (filename, "%s.lin", source); 61 | qprintf ("%s\n", filename); 62 | linefile = fopen (filename, "w"); 63 | if (!linefile) 64 | Error ("Couldn't open %s\n", filename); 65 | 66 | count = 0; 67 | node = &tree->outside_node; 68 | while (node->occupied > 1) 69 | { 70 | int next; 71 | portal_t *p, *nextportal; 72 | node_t *nextnode; 73 | int s; 74 | 75 | // find the best portal exit 76 | next = node->occupied; 77 | for (p=node->portals ; p ; p = p->next[!s]) 78 | { 79 | s = (p->nodes[0] == node); 80 | if (p->nodes[s]->occupied 81 | && p->nodes[s]->occupied < next) 82 | { 83 | nextportal = p; 84 | nextnode = p->nodes[s]; 85 | next = nextnode->occupied; 86 | } 87 | } 88 | node = nextnode; 89 | WindingCenter (nextportal->winding, mid); 90 | fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]); 91 | count++; 92 | } 93 | // add the occupant center 94 | GetVectorForKey (node->occupant, "origin", mid); 95 | 96 | fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]); 97 | qprintf ("%5i point linefile\n", count+1); 98 | 99 | fclose (linefile); 100 | } 101 | 102 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_reach.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_reach.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_reach.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | //initialize calculating the reachabilities 34 | void AAS_InitReachability(void); 35 | //continue calculating the reachabilities 36 | int AAS_ContinueInitReachability(float time); 37 | // 38 | int AAS_BestReachableLinkArea(aas_link_t *areas); 39 | #endif //AASINTERN 40 | 41 | //returns true if the are has reachabilities to other areas 42 | int AAS_AreaReachability(int areanum); 43 | //returns the best reachable area and goal origin for a bounding box at the given origin 44 | int AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin); 45 | //returns the best jumppad area from which the bbox at origin is reachable 46 | int AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs); 47 | //returns the next reachability using the given model 48 | int AAS_NextModelReachability(int num, int modelnum); 49 | //returns the total area of the ground faces of the given area 50 | float AAS_AreaGroundFaceArea(int areanum); 51 | //returns true if the area is crouch only 52 | int AAS_AreaCrouch(int areanum); 53 | //returns true if a player can swim in this area 54 | int AAS_AreaSwim(int areanum); 55 | //returns true if the area is filled with a liquid 56 | int AAS_AreaLiquid(int areanum); 57 | //returns true if the area contains lava 58 | int AAS_AreaLava(int areanum); 59 | //returns true if the area contains slime 60 | int AAS_AreaSlime(int areanum); 61 | //returns true if the area has one or more ground faces 62 | int AAS_AreaGrounded(int areanum); 63 | //returns true if the area has one or more ladder faces 64 | int AAS_AreaLadder(int areanum); 65 | //returns true if the area is a jump pad 66 | int AAS_AreaJumpPad(int areanum); 67 | //returns true if the area is donotenter 68 | int AAS_AreaDoNotEnter(int areanum); 69 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_route.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_route.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_route.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | //initialize the AAS routing 34 | void AAS_InitRouting(void); 35 | //free the AAS routing caches 36 | void AAS_FreeRoutingCaches(void); 37 | //returns the travel time from start to end in the given area 38 | unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end); 39 | // 40 | void AAS_CreateAllRoutingCache(void); 41 | void AAS_WriteRouteCache(void); 42 | // 43 | void AAS_RoutingInfo(void); 44 | #endif //AASINTERN 45 | 46 | //returns the travel flag for the given travel type 47 | int AAS_TravelFlagForType(int traveltype); 48 | //return the travel flag(s) for traveling through this area 49 | int AAS_AreaContentsTravelFlags(int areanum); 50 | //returns the index of the next reachability for the given area 51 | int AAS_NextAreaReachability(int areanum, int reachnum); 52 | //returns the reachability with the given index 53 | void AAS_ReachabilityFromNum(int num, struct aas_reachability_s *reach); 54 | //returns a random goal area and goal origin 55 | int AAS_RandomGoalArea(int areanum, int travelflags, int *goalareanum, vec3_t goalorigin); 56 | //enable or disable an area for routing 57 | int AAS_EnableRoutingArea(int areanum, int enable); 58 | //returns the travel time within the given area from start to end 59 | unsigned short int AAS_AreaTravelTime(int areanum, vec3_t start, vec3_t end); 60 | //returns the travel time from the area to the goal area using the given travel flags 61 | int AAS_AreaTravelTimeToGoalArea(int areanum, vec3_t origin, int goalareanum, int travelflags); 62 | //predict a route up to a stop event 63 | int AAS_PredictRoute(struct aas_predictroute_s *route, int areanum, vec3_t origin, 64 | int goalareanum, int travelflags, int maxareas, int maxtime, 65 | int stopevent, int stopcontents, int stoptfl, int stopareanum); 66 | 67 | 68 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_move.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_move.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_move.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | extern aas_settings_t aassettings; 34 | #endif //AASINTERN 35 | 36 | //movement prediction 37 | int AAS_PredictClientMovement(struct aas_clientmove_s *move, 38 | int entnum, vec3_t origin, 39 | int presencetype, int onground, 40 | vec3_t velocity, vec3_t cmdmove, 41 | int cmdframes, 42 | int maxframes, float frametime, 43 | int stopevent, int stopareanum, int visualize); 44 | //predict movement until bounding box is hit 45 | int AAS_ClientMovementHitBBox(struct aas_clientmove_s *move, 46 | int entnum, vec3_t origin, 47 | int presencetype, int onground, 48 | vec3_t velocity, vec3_t cmdmove, 49 | int cmdframes, 50 | int maxframes, float frametime, 51 | vec3_t mins, vec3_t maxs, int visualize); 52 | //returns true if on the ground at the given origin 53 | int AAS_OnGround(vec3_t origin, int presencetype, int passent); 54 | //returns true if swimming at the given origin 55 | int AAS_Swimming(vec3_t origin); 56 | //returns the jump reachability run start point 57 | void AAS_JumpReachRunStart(struct aas_reachability_s *reach, vec3_t runstart); 58 | //returns true if against a ladder at the given origin 59 | int AAS_AgainstLadder(vec3_t origin); 60 | //rocket jump Z velocity when rocket-jumping at origin 61 | float AAS_RocketJumpZVelocity(vec3_t origin); 62 | //bfg jump Z velocity when bfg-jumping at origin 63 | float AAS_BFGJumpZVelocity(vec3_t origin); 64 | //calculates the horizontal velocity needed for a jump and returns true this velocity could be calculated 65 | int AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity); 66 | // 67 | void AAS_SetMovedir(vec3_t angles, vec3_t movedir); 68 | // 69 | int AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs); 70 | // 71 | void AAS_InitSettings(void); 72 | -------------------------------------------------------------------------------- /deps/botlib/be_ai_weight.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_ai_weight.h 25 | * 26 | * desc: fuzzy weights 27 | * 28 | * $Archive: /source/code/botlib/be_ai_weight.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #define WT_BALANCE 1 33 | #define MAX_WEIGHTS 128 34 | 35 | //fuzzy seperator 36 | typedef struct fuzzyseperator_s 37 | { 38 | int index; 39 | int value; 40 | int type; 41 | float weight; 42 | float minweight; 43 | float maxweight; 44 | struct fuzzyseperator_s *child; 45 | struct fuzzyseperator_s *next; 46 | } fuzzyseperator_t; 47 | 48 | //fuzzy weight 49 | typedef struct weight_s 50 | { 51 | char *name; 52 | struct fuzzyseperator_s *firstseperator; 53 | } weight_t; 54 | 55 | //weight configuration 56 | typedef struct weightconfig_s 57 | { 58 | int numweights; 59 | weight_t weights[MAX_WEIGHTS]; 60 | char filename[MAX_QPATH]; 61 | } weightconfig_t; 62 | 63 | //reads a weight configuration 64 | weightconfig_t *ReadWeightConfig(char *filename); 65 | //free a weight configuration 66 | void FreeWeightConfig(weightconfig_t *config); 67 | //writes a weight configuration, returns true if successfull 68 | qboolean WriteWeightConfig(char *filename, weightconfig_t *config); 69 | //find the fuzzy weight with the given name 70 | int FindFuzzyWeight(weightconfig_t *wc, char *name); 71 | //returns the fuzzy weight for the given inventory and weight 72 | float FuzzyWeight(int *inventory, weightconfig_t *wc, int weightnum); 73 | float FuzzyWeightUndecided(int *inventory, weightconfig_t *wc, int weightnum); 74 | //scales the weight with the given name 75 | void ScaleWeight(weightconfig_t *config, char *name, float scale); 76 | //scale the balance range 77 | void ScaleBalanceRange(weightconfig_t *config, float scale); 78 | //evolves the weight configuration 79 | void EvolveWeightConfig(weightconfig_t *config); 80 | //interbreed the weight configurations and stores the interbreeded one in configout 81 | void InterbreedWeightConfigs(weightconfig_t *config1, weightconfig_t *config2, weightconfig_t *configout); 82 | //frees cached weight configurations 83 | void BotShutdownWeights(void); 84 | -------------------------------------------------------------------------------- /aas_prunenodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "qbsp.h" 24 | #include "botlib/aasfile.h" 25 | #include "aas_create.h" 26 | 27 | int c_numprunes; 28 | 29 | //=========================================================================== 30 | // 31 | // Parameter: - 32 | // Returns: - 33 | // Changes Globals: - 34 | //=========================================================================== 35 | tmp_node_t *AAS_PruneNodes_r(tmp_node_t *tmpnode) 36 | { 37 | tmp_area_t *tmparea1, *tmparea2; 38 | 39 | //if it is a solid leaf 40 | if (!tmpnode) return NULL; 41 | // 42 | if (tmpnode->tmparea) return tmpnode; 43 | //process the children first 44 | tmpnode->children[0] = AAS_PruneNodes_r(tmpnode->children[0]); 45 | tmpnode->children[1] = AAS_PruneNodes_r(tmpnode->children[1]); 46 | //if both children are areas 47 | if (tmpnode->children[0] && tmpnode->children[1] && 48 | tmpnode->children[0]->tmparea && tmpnode->children[1]->tmparea) 49 | { 50 | tmparea1 = tmpnode->children[0]->tmparea; 51 | while(tmparea1->mergedarea) tmparea1 = tmparea1->mergedarea; 52 | 53 | tmparea2 = tmpnode->children[1]->tmparea; 54 | while(tmparea2->mergedarea) tmparea2 = tmparea2->mergedarea; 55 | 56 | if (tmparea1 == tmparea2) 57 | { 58 | c_numprunes++; 59 | tmpnode->tmparea = tmparea1; 60 | tmpnode->planenum = 0; 61 | AAS_FreeTmpNode(tmpnode->children[0]); 62 | AAS_FreeTmpNode(tmpnode->children[1]); 63 | tmpnode->children[0] = NULL; 64 | tmpnode->children[1] = NULL; 65 | return tmpnode; 66 | } //end if 67 | } //end if 68 | //if both solid leafs 69 | if (!tmpnode->children[0] && !tmpnode->children[1]) 70 | { 71 | c_numprunes++; 72 | AAS_FreeTmpNode(tmpnode); 73 | return NULL; 74 | } //end if 75 | // 76 | return tmpnode; 77 | } //end of the function AAS_PruneNodes_r 78 | //=========================================================================== 79 | // 80 | // Parameter: - 81 | // Returns: - 82 | // Changes Globals: - 83 | //=========================================================================== 84 | void AAS_PruneNodes(void) 85 | { 86 | Log_Write("AAS_PruneNodes\r\n"); 87 | AAS_PruneNodes_r(tmpaasworld.nodes); 88 | Log_Print("%6d nodes pruned\r\n", c_numprunes); 89 | } //end of the function AAS_PruneNodes 90 | -------------------------------------------------------------------------------- /l_bsp_q2.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #ifndef ME 24 | #define ME 25 | #endif //ME 26 | 27 | extern int nummodels; 28 | extern dmodel_t *dmodels;//[MAX_MAP_MODELS]; 29 | 30 | extern int visdatasize; 31 | extern byte *dvisdata;//[MAX_MAP_VISIBILITY]; 32 | extern dvis_t *dvis; 33 | 34 | extern int lightdatasize; 35 | extern byte *dlightdata;//[MAX_MAP_LIGHTING]; 36 | 37 | extern int entdatasize; 38 | extern char *dentdata;//[MAX_MAP_ENTSTRING]; 39 | 40 | extern int numleafs; 41 | extern dleaf_t *dleafs;//[MAX_MAP_LEAFS]; 42 | 43 | extern int numplanes; 44 | extern dplane_t *dplanes;//[MAX_MAP_PLANES]; 45 | 46 | extern int numvertexes; 47 | extern dvertex_t *dvertexes;//[MAX_MAP_VERTS]; 48 | 49 | extern int numnodes; 50 | extern dnode_t *dnodes;//[MAX_MAP_NODES]; 51 | 52 | extern int numtexinfo; 53 | extern texinfo_t texinfo[MAX_MAP_TEXINFO]; 54 | 55 | extern int numfaces; 56 | extern dface_t *dfaces;//[MAX_MAP_FACES]; 57 | 58 | extern int numedges; 59 | extern dedge_t *dedges;//[MAX_MAP_EDGES]; 60 | 61 | extern int numleaffaces; 62 | extern unsigned short *dleaffaces;//[MAX_MAP_LEAFFACES]; 63 | 64 | extern int numleafbrushes; 65 | extern unsigned short *dleafbrushes;//[MAX_MAP_LEAFBRUSHES]; 66 | 67 | extern int numsurfedges; 68 | extern int *dsurfedges;//[MAX_MAP_SURFEDGES]; 69 | 70 | extern int numareas; 71 | extern darea_t *dareas;//[MAX_MAP_AREAS]; 72 | 73 | extern int numareaportals; 74 | extern dareaportal_t *dareaportals;//[MAX_MAP_AREAPORTALS]; 75 | 76 | extern int numbrushes; 77 | extern dbrush_t *dbrushes;//[MAX_MAP_BRUSHES]; 78 | 79 | extern int numbrushsides; 80 | extern dbrushside_t *dbrushsides;//[MAX_MAP_BRUSHSIDES]; 81 | 82 | extern byte dpop[256]; 83 | 84 | extern char brushsidetextured[MAX_MAP_BRUSHSIDES]; 85 | 86 | void Q2_AllocMaxBSP(void); 87 | void Q2_FreeMaxBSP(void); 88 | 89 | void Q2_DecompressVis(byte *in, byte *decompressed); 90 | int Q2_CompressVis(byte *vis, byte *dest); 91 | 92 | void Q2_LoadBSPFile(char *filename, int offset, int length); 93 | void Q2_LoadBSPFileTexinfo(char *filename); // just for qdata 94 | void Q2_WriteBSPFile(char *filename); 95 | void Q2_PrintBSPFileSizes(void); 96 | void Q2_ParseEntities(void); 97 | void Q2_UnparseEntities(void); 98 | 99 | -------------------------------------------------------------------------------- /l_qfiles.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "qcommon/unzip.h" 24 | 25 | #define QFILETYPE_UNKNOWN 0x8000 26 | #define QFILETYPE_PAK 0x0001 27 | #define QFILETYPE_PK3 0x0002 28 | #define QFILETYPE_BSP 0x0004 29 | #define QFILETYPE_MAP 0x0008 30 | #define QFILETYPE_MDL 0x0010 31 | #define QFILETYPE_MD2 0x0020 32 | #define QFILETYPE_MD3 0x0040 33 | #define QFILETYPE_WAL 0x0080 34 | #define QFILETYPE_WAV 0x0100 35 | #define QFILETYPE_AAS 0x4000 36 | 37 | #define QFILEEXT_UNKNOWN "" 38 | #define QFILEEXT_PAK ".PAK" 39 | #define QFILEEXT_PK3 ".PK3" 40 | #define QFILEEXT_SIN ".SIN" 41 | #define QFILEEXT_BSP ".BSP" 42 | #define QFILEEXT_MAP ".MAP" 43 | #define QFILEEXT_MDL ".MDL" 44 | #define QFILEEXT_MD2 ".MD2" 45 | #define QFILEEXT_MD3 ".MD3" 46 | #define QFILEEXT_WAL ".WAL" 47 | #define QFILEEXT_WAV ".WAV" 48 | #define QFILEEXT_AAS ".AAS" 49 | 50 | //maximum path length 51 | #ifndef _MAX_PATH 52 | #define _MAX_PATH 1024 53 | #endif 54 | 55 | //for Sin packs 56 | #define MAX_PAK_FILENAME_LENGTH 120 57 | #define SINPAKHEADER (('K'<<24)+('A'<<16)+('P'<<8)+'S') 58 | 59 | typedef struct 60 | { 61 | char name[MAX_PAK_FILENAME_LENGTH]; 62 | int filepos, filelen; 63 | } dsinpackfile_t; 64 | 65 | typedef struct quakefile_s 66 | { 67 | char pakfile[_MAX_PATH]; 68 | char filename[_MAX_PATH]; 69 | char origname[_MAX_PATH]; 70 | int zipfile; 71 | int type; 72 | int offset; 73 | int length; 74 | unz_s zipinfo; 75 | struct quakefile_s *next; 76 | } quakefile_t; 77 | 78 | //returns the file extension for the given type 79 | char *QuakeFileTypeExtension(int type); 80 | //returns the file type for the given extension 81 | int QuakeFileExtensionType(char *extension); 82 | //return the Quake file type for the given file 83 | int QuakeFileType(char *filename); 84 | //returns true if the filename complies to the filter 85 | int FileFilter(char *filter, char *filename, int casesensitive); 86 | //find Quake files using the given filter 87 | quakefile_t *FindQuakeFiles(char *filter); 88 | //load the given Quake file, returns the length of the file 89 | int LoadQuakeFile(quakefile_t *qf, void **bufferptr); 90 | //read part of a Quake file into the buffer 91 | int ReadQuakeFile(quakefile_t *qf, void *buffer, int offset, int length); 92 | -------------------------------------------------------------------------------- /deps/qcommon/cm_public.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "qfiles.h" 24 | 25 | 26 | void CM_LoadMap( const char *name, qboolean clientload, int *checksum); 27 | void CM_ClearMap( void ); 28 | clipHandle_t CM_InlineModel( int index ); // 0 = world, 1 + are bmodels 29 | clipHandle_t CM_TempBoxModel( const vec3_t mins, const vec3_t maxs, int capsule ); 30 | 31 | void CM_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ); 32 | 33 | int CM_NumClusters (void); 34 | int CM_NumInlineModels( void ); 35 | char *CM_EntityString (void); 36 | 37 | // returns an ORed contents mask 38 | int CM_PointContents( const vec3_t p, clipHandle_t model ); 39 | int CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles ); 40 | 41 | void CM_BoxTrace ( trace_t *results, const vec3_t start, const vec3_t end, 42 | vec3_t mins, vec3_t maxs, 43 | clipHandle_t model, int brushmask, int capsule ); 44 | void CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end, 45 | vec3_t mins, vec3_t maxs, 46 | clipHandle_t model, int brushmask, 47 | const vec3_t origin, const vec3_t angles, int capsule ); 48 | 49 | byte *CM_ClusterPVS (int cluster); 50 | 51 | int CM_PointLeafnum( const vec3_t p ); 52 | 53 | // only returns non-solid leafs 54 | // overflow if return listsize and if *lastLeaf != list[listsize-1] 55 | int CM_BoxLeafnums( const vec3_t mins, const vec3_t maxs, int *list, 56 | int listsize, int *lastLeaf ); 57 | 58 | int CM_LeafCluster (int leafnum); 59 | int CM_LeafArea (int leafnum); 60 | 61 | void CM_AdjustAreaPortalState( int area1, int area2, qboolean open ); 62 | qboolean CM_AreasConnected( int area1, int area2 ); 63 | 64 | int CM_WriteAreaBits( byte *buffer, int area ); 65 | 66 | // cm_tag.c 67 | int CM_LerpTag( orientation_t *tag, clipHandle_t model, int startFrame, int endFrame, 68 | float frac, const char *tagName ); 69 | 70 | 71 | // cm_marks.c 72 | int CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, 73 | int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); 74 | 75 | // cm_patch.c 76 | void CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, float *points) ); 77 | -------------------------------------------------------------------------------- /deps/botlib/l_memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: l_memory.h 25 | * 26 | * desc: memory management 27 | * 28 | * $Archive: /source/code/botlib/l_memory.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | //#define MEMDEBUG 33 | 34 | #ifdef MEMDEBUG 35 | #define GetMemory(size) GetMemoryDebug(size, #size, __FILE__, __LINE__); 36 | #define GetClearedMemory(size) GetClearedMemoryDebug(size, #size, __FILE__, __LINE__); 37 | //allocate a memory block of the given size 38 | void *GetMemoryDebug(unsigned long size, char *label, char *file, int line); 39 | //allocate a memory block of the given size and clear it 40 | void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line); 41 | // 42 | #define GetHunkMemory(size) GetHunkMemoryDebug(size, #size, __FILE__, __LINE__); 43 | #define GetClearedHunkMemory(size) GetClearedHunkMemoryDebug(size, #size, __FILE__, __LINE__); 44 | //allocate a memory block of the given size 45 | void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line); 46 | //allocate a memory block of the given size and clear it 47 | void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line); 48 | #else 49 | //allocate a memory block of the given size 50 | void *GetMemory(unsigned long size); 51 | //allocate a memory block of the given size and clear it 52 | void *GetClearedMemory(unsigned long size); 53 | // 54 | #ifdef BSPC 55 | #define GetHunkMemory GetMemory 56 | #define GetClearedHunkMemory GetClearedMemory 57 | #else 58 | //allocate a memory block of the given size 59 | void *GetHunkMemory(unsigned long size); 60 | //allocate a memory block of the given size and clear it 61 | void *GetClearedHunkMemory(unsigned long size); 62 | #endif 63 | #endif 64 | 65 | //free the given memory block 66 | void FreeMemory(void *ptr); 67 | //returns the amount available memory 68 | int AvailableMemory(void); 69 | //prints the total used memory size 70 | void PrintUsedMemorySize(void); 71 | //print all memory blocks with label 72 | void PrintMemoryLabels(void); 73 | //returns the size of the memory block in bytes 74 | int MemoryByteSize(void *ptr); 75 | //free all allocated memory 76 | void DumpMemory(void); 77 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_sample.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_sample.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_sample.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | void AAS_InitAASLinkHeap(void); 34 | void AAS_InitAASLinkedEntities(void); 35 | void AAS_FreeAASLinkHeap(void); 36 | void AAS_FreeAASLinkedEntities(void); 37 | aas_face_t *AAS_AreaGroundFace(int areanum, vec3_t point); 38 | aas_face_t *AAS_TraceEndFace(aas_trace_t *trace); 39 | aas_plane_t *AAS_PlaneFromNum(int planenum); 40 | aas_link_t *AAS_AASLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum); 41 | aas_link_t *AAS_LinkEntityClientBBox(vec3_t absmins, vec3_t absmaxs, int entnum, int presencetype); 42 | qboolean AAS_PointInsideFace(int facenum, vec3_t point, float epsilon); 43 | qboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float epsilon); 44 | void AAS_UnlinkFromAreas(aas_link_t *areas); 45 | #endif //AASINTERN 46 | 47 | //returns the mins and maxs of the bounding box for the given presence type 48 | void AAS_PresenceTypeBoundingBox(int presencetype, vec3_t mins, vec3_t maxs); 49 | //returns the cluster the area is in (negative portal number if the area is a portal) 50 | int AAS_AreaCluster(int areanum); 51 | //returns the presence type(s) of the area 52 | int AAS_AreaPresenceType(int areanum); 53 | //returns the presence type(s) at the given point 54 | int AAS_PointPresenceType(vec3_t point); 55 | //returns the result of the trace of a client bbox 56 | aas_trace_t AAS_TraceClientBBox(vec3_t start, vec3_t end, int presencetype, int passent); 57 | //stores the areas the trace went through and returns the number of passed areas 58 | int AAS_TraceAreas(vec3_t start, vec3_t end, int *areas, vec3_t *points, int maxareas); 59 | //returns the areas the bounding box is in 60 | int AAS_BBoxAreas(vec3_t absmins, vec3_t absmaxs, int *areas, int maxareas); 61 | //return area information 62 | int AAS_AreaInfo( int areanum, aas_areainfo_t *info ); 63 | //returns the area the point is in 64 | int AAS_PointAreaNum(vec3_t point); 65 | // 66 | int AAS_PointReachabilityAreaIndex( vec3_t point ); 67 | //returns the plane the given face is in 68 | void AAS_FacePlane(int facenum, vec3_t normal, float *dist); 69 | 70 | -------------------------------------------------------------------------------- /aas_store.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #define AAS_MAX_BBOXES 5 24 | #define AAS_MAX_VERTEXES 512000 25 | #define AAS_MAX_PLANES 65536 26 | #define AAS_MAX_EDGES 512000 27 | #define AAS_MAX_EDGEINDEXSIZE 512000 28 | #define AAS_MAX_FACES 512000 29 | #define AAS_MAX_FACEINDEXSIZE 512000 30 | #define AAS_MAX_AREAS 65536 31 | #define AAS_MAX_AREASETTINGS 65536 32 | #define AAS_MAX_REACHABILITYSIZE 65536 33 | #define AAS_MAX_NODES 256000 34 | #define AAS_MAX_PORTALS 65536 35 | #define AAS_MAX_PORTALINDEXSIZE 65536 36 | #define AAS_MAX_CLUSTERS 65536 37 | 38 | #define BSPCINCLUDE 39 | #include "botlib/be_aas.h" 40 | #include "botlib/be_aas_def.h" 41 | 42 | /* 43 | typedef struct bspc_aas_s 44 | { 45 | int loaded; 46 | int initialized; //true when AAS has been initialized 47 | int savefile; //set true when file should be saved 48 | //bounding boxes 49 | int numbboxes; 50 | aas_bbox_t *bboxes; 51 | //vertexes 52 | int numvertexes; 53 | aas_vertex_t *vertexes; 54 | //planes 55 | int numplanes; 56 | aas_plane_t *planes; 57 | //edges 58 | int numedges; 59 | aas_edge_t *edges; 60 | //edge index 61 | int edgeindexsize; 62 | aas_edgeindex_t *edgeindex; 63 | //faces 64 | int numfaces; 65 | aas_face_t *faces; 66 | //face index 67 | int faceindexsize; 68 | aas_faceindex_t *faceindex; 69 | //convex areas 70 | int numareas; 71 | aas_area_t *areas; 72 | //convex area settings 73 | int numareasettings; 74 | aas_areasettings_t *areasettings; 75 | //reachablity list 76 | int reachabilitysize; 77 | aas_reachability_t *reachability; 78 | //nodes of the bsp tree 79 | int numnodes; 80 | aas_node_t *nodes; 81 | //cluster portals 82 | int numportals; 83 | aas_portal_t *portals; 84 | //cluster portal index 85 | int portalindexsize; 86 | aas_portalindex_t *portalindex; 87 | //clusters 88 | int numclusters; 89 | aas_cluster_t *clusters; 90 | // 91 | int numreachabilityareas; 92 | float reachabilitytime; 93 | } bspc_aas_t; 94 | 95 | extern bspc_aas_t aasworld; 96 | //*/ 97 | 98 | extern aas_t aasworld; 99 | 100 | //stores the AAS file from the temporary AAS 101 | void AAS_StoreFile(char *filename); 102 | //returns a number of the given plane 103 | qboolean AAS_FindPlane(vec3_t normal, float dist, int *planenum); 104 | //allocates the maximum AAS memory for storage 105 | void AAS_AllocMaxAAS(void); 106 | //frees the maximum AAS memory for storage 107 | void AAS_FreeMaxAAS(void); 108 | -------------------------------------------------------------------------------- /l_math.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | #ifndef __MATHLIB__ 23 | #define __MATHLIB__ 24 | 25 | // mathlib.h 26 | 27 | #include 28 | 29 | #ifdef DOUBLEVEC_T 30 | typedef double vec_t; 31 | #else 32 | typedef float vec_t; 33 | #endif 34 | typedef vec_t vec3_t[3]; 35 | typedef vec_t vec4_t[4]; 36 | 37 | #define SIDE_FRONT 0 38 | #define SIDE_ON 2 39 | #define SIDE_BACK 1 40 | #define SIDE_CROSS -2 41 | 42 | #define PITCH 0 43 | #define YAW 1 44 | #define ROLL 2 45 | 46 | #define Q_PI 3.14159265358979323846 47 | 48 | #define DEG2RAD( a ) ( a * M_PI ) / 180.0F 49 | 50 | #ifndef M_PI 51 | #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h 52 | #endif 53 | 54 | extern vec3_t vec3_origin; 55 | 56 | #define EQUAL_EPSILON 0.001 57 | 58 | qboolean VectorCompare (vec3_t v1, vec3_t v2); 59 | 60 | #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) 61 | #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} 62 | #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} 63 | #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];} 64 | #define Vector4Copy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];} 65 | #define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) 66 | #define VectorClear(x) {x[0] = x[1] = x[2] = 0;} 67 | #define VectorNegate(x, y) {y[0]=-x[0];y[1]=-x[1];y[2]=-x[2];} 68 | #define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) 69 | 70 | vec_t Q_rint (vec_t in); 71 | vec_t _DotProduct (vec3_t v1, vec3_t v2); 72 | void _VectorSubtract (vec3_t va, vec3_t vb, vec3_t out); 73 | void _VectorAdd (vec3_t va, vec3_t vb, vec3_t out); 74 | void _VectorCopy (vec3_t in, vec3_t out); 75 | void _VectorScale (vec3_t v, vec_t scale, vec3_t out); 76 | void _VectorMA(vec3_t va, double scale, vec3_t vb, vec3_t vc); 77 | 78 | double VectorLength(vec3_t v); 79 | void CrossProduct(const vec3_t v1, const vec3_t v2, vec3_t cross); 80 | vec_t VectorNormalize(vec3_t inout); 81 | vec_t ColorNormalize(vec3_t in, vec3_t out); 82 | vec_t VectorNormalize2(const vec3_t v, vec3_t out); 83 | void VectorInverse (vec3_t v); 84 | 85 | void ClearBounds (vec3_t mins, vec3_t maxs); 86 | void AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs); 87 | 88 | void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); 89 | void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); 90 | void RotatePoint(vec3_t point, float matrix[3][3]); 91 | void CreateRotationMatrix(vec3_t angles, float matrix[3][3]); 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /deps/botlib/be_aas_bsp.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_aas_bsp.h 25 | * 26 | * desc: AAS 27 | * 28 | * $Archive: /source/code/botlib/be_aas_bsp.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #ifdef AASINTERN 33 | //loads the given BSP file 34 | int AAS_LoadBSPFile(void); 35 | //dump the loaded BSP data 36 | void AAS_DumpBSPData(void); 37 | //unlink the given entity from the bsp tree leaves 38 | void AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves); 39 | //link the given entity to the bsp tree leaves of the given model 40 | bsp_link_t *AAS_BSPLinkEntity(vec3_t absmins, 41 | vec3_t absmaxs, 42 | int entnum, 43 | int modelnum); 44 | 45 | //calculates collision with given entity 46 | qboolean AAS_EntityCollision(int entnum, 47 | vec3_t start, 48 | vec3_t boxmins, 49 | vec3_t boxmaxs, 50 | vec3_t end, 51 | int contentmask, 52 | bsp_trace_t *trace); 53 | //for debugging 54 | void AAS_PrintFreeBSPLinks(char *str); 55 | // 56 | #endif //AASINTERN 57 | 58 | #define MAX_EPAIRKEY 128 59 | 60 | //trace through the world 61 | bsp_trace_t AAS_Trace( vec3_t start, 62 | vec3_t mins, 63 | vec3_t maxs, 64 | vec3_t end, 65 | int passent, 66 | int contentmask); 67 | //returns the contents at the given point 68 | int AAS_PointContents(vec3_t point); 69 | //returns true when p2 is in the PVS of p1 70 | qboolean AAS_inPVS(vec3_t p1, vec3_t p2); 71 | //returns true when p2 is in the PHS of p1 72 | qboolean AAS_inPHS(vec3_t p1, vec3_t p2); 73 | //returns true if the given areas are connected 74 | qboolean AAS_AreasConnected(int area1, int area2); 75 | //creates a list with entities totally or partly within the given box 76 | int AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount); 77 | //gets the mins, maxs and origin of a BSP model 78 | void AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin); 79 | //handle to the next bsp entity 80 | int AAS_NextBSPEntity(int ent); 81 | //return the value of the BSP epair key 82 | int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size); 83 | //get a vector for the BSP epair key 84 | int AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v); 85 | //get a float for the BSP epair key 86 | int AAS_FloatForBSPEpairKey(int ent, char *key, float *value); 87 | //get an integer for the BSP epair key 88 | int AAS_IntForBSPEpairKey(int ent, char *key, int *value); 89 | 90 | -------------------------------------------------------------------------------- /glfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "qbsp.h" 24 | 25 | int c_glfaces; 26 | 27 | int PortalVisibleSides (portal_t *p) 28 | { 29 | int fcon, bcon; 30 | 31 | if (!p->onnode) 32 | return 0; // outside 33 | 34 | fcon = p->nodes[0]->contents; 35 | bcon = p->nodes[1]->contents; 36 | 37 | // same contents never create a face 38 | if (fcon == bcon) 39 | return 0; 40 | 41 | // FIXME: is this correct now? 42 | if (!fcon) 43 | return 1; 44 | if (!bcon) 45 | return 2; 46 | return 0; 47 | } 48 | 49 | void OutputWinding (winding_t *w, FILE *glview) 50 | { 51 | static int level = 128; 52 | vec_t light; 53 | int i; 54 | 55 | fprintf (glview, "%i\n", w->numpoints); 56 | level+=28; 57 | light = (level&255)/255.0; 58 | for (i=0 ; inumpoints ; i++) 59 | { 60 | fprintf (glview, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n", 61 | w->p[i][0], 62 | w->p[i][1], 63 | w->p[i][2], 64 | light, 65 | light, 66 | light); 67 | } 68 | fprintf (glview, "\n"); 69 | } 70 | 71 | /* 72 | ============= 73 | OutputPortal 74 | ============= 75 | */ 76 | void OutputPortal (portal_t *p, FILE *glview) 77 | { 78 | winding_t *w; 79 | int sides; 80 | 81 | sides = PortalVisibleSides (p); 82 | if (!sides) 83 | return; 84 | 85 | c_glfaces++; 86 | 87 | w = p->winding; 88 | 89 | if (sides == 2) // back side 90 | w = ReverseWinding (w); 91 | 92 | OutputWinding (w, glview); 93 | 94 | if (sides == 2) 95 | FreeWinding(w); 96 | } 97 | 98 | /* 99 | ============= 100 | WriteGLView_r 101 | ============= 102 | */ 103 | void WriteGLView_r (node_t *node, FILE *glview) 104 | { 105 | portal_t *p, *nextp; 106 | 107 | if (node->planenum != PLANENUM_LEAF) 108 | { 109 | WriteGLView_r (node->children[0], glview); 110 | WriteGLView_r (node->children[1], glview); 111 | return; 112 | } 113 | 114 | // write all the portals 115 | for (p=node->portals ; p ; p=nextp) 116 | { 117 | if (p->nodes[0] == node) 118 | { 119 | OutputPortal (p, glview); 120 | nextp = p->next[0]; 121 | } 122 | else 123 | nextp = p->next[1]; 124 | } 125 | } 126 | 127 | /* 128 | ============= 129 | WriteGLView 130 | ============= 131 | */ 132 | void WriteGLView (tree_t *tree, char *source) 133 | { 134 | char name[1024]; 135 | FILE *glview; 136 | 137 | c_glfaces = 0; 138 | sprintf (name, "%s%s.gl",outbase, source); 139 | printf ("Writing %s\n", name); 140 | 141 | glview = fopen (name, "w"); 142 | if (!glview) 143 | Error ("Couldn't open %s", name); 144 | WriteGLView_r (tree->headnode, glview); 145 | fclose (glview); 146 | 147 | printf ("%5i c_glfaces\n", c_glfaces); 148 | } 149 | 150 | -------------------------------------------------------------------------------- /deps/qcommon/cm_patch.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | //#define CULL_BBOX 24 | 25 | /* 26 | 27 | This file does not reference any globals, and has these entry points: 28 | 29 | void CM_ClearLevelPatches( void ); 30 | struct patchCollide_s *CM_GeneratePatchCollide( int width, int height, const vec3_t *points ); 31 | void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ); 32 | qboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ); 33 | void CM_DrawDebugSurface( void (*drawPoly)(int color, int numPoints, flaot *points) ); 34 | 35 | 36 | Issues for collision against curved surfaces: 37 | 38 | Surface edges need to be handled differently than surface planes 39 | 40 | Plane expansion causes raw surfaces to expand past expanded bounding box 41 | 42 | Position test of a volume against a surface is tricky. 43 | 44 | Position test of a point against a surface is not well defined, because the surface has no volume. 45 | 46 | 47 | Tracing leading edge points instead of volumes? 48 | Position test by tracing corner to corner? (8*7 traces -- ouch) 49 | 50 | coplanar edges 51 | triangulated patches 52 | degenerate patches 53 | 54 | endcaps 55 | degenerate 56 | 57 | WARNING: this may misbehave with meshes that have rows or columns that only 58 | degenerate a few triangles. Completely degenerate rows and columns are handled 59 | properly. 60 | */ 61 | 62 | 63 | #define MAX_FACETS 1024 64 | #define MAX_PATCH_PLANES 2048 65 | 66 | typedef struct { 67 | float plane[4]; 68 | int signbits; // signx + (signy<<1) + (signz<<2), used as lookup during collision 69 | } patchPlane_t; 70 | 71 | typedef struct { 72 | int surfacePlane; 73 | int numBorders; // 3 or four + 6 axial bevels + 4 or 3 * 4 edge bevels 74 | int borderPlanes[4+6+16]; 75 | int borderInward[4+6+16]; 76 | qboolean borderNoAdjust[4+6+16]; 77 | } facet_t; 78 | 79 | typedef struct patchCollide_s { 80 | vec3_t bounds[2]; 81 | int numPlanes; // surface planes plus edge planes 82 | patchPlane_t *planes; 83 | int numFacets; 84 | facet_t *facets; 85 | } patchCollide_t; 86 | 87 | 88 | #define MAX_GRID_SIZE 129 89 | 90 | typedef struct { 91 | int width; 92 | int height; 93 | qboolean wrapWidth; 94 | qboolean wrapHeight; 95 | vec3_t points[MAX_GRID_SIZE][MAX_GRID_SIZE]; // [width][height] 96 | } cGrid_t; 97 | 98 | #define SUBDIVIDE_DISTANCE 16 //4 // never more than this units away from curve 99 | #define PLANE_TRI_EPSILON 0.1 100 | #define WRAP_POINT_EPSILON 0.1 101 | 102 | 103 | struct patchCollide_s *CM_GeneratePatchCollide( int width, int height, vec3_t *points ); 104 | -------------------------------------------------------------------------------- /deps/botlib/be_ai_weap.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | 24 | /***************************************************************************** 25 | * name: be_ai_weap.h 26 | * 27 | * desc: weapon AI 28 | * 29 | * $Archive: /source/code/botlib/be_ai_weap.h $ 30 | * 31 | *****************************************************************************/ 32 | 33 | //projectile flags 34 | #define PFL_WINDOWDAMAGE 1 //projectile damages through window 35 | #define PFL_RETURN 2 //set when projectile returns to owner 36 | //weapon flags 37 | #define WFL_FIRERELEASED 1 //set when projectile is fired with key-up event 38 | //damage types 39 | #define DAMAGETYPE_IMPACT 1 //damage on impact 40 | #define DAMAGETYPE_RADIAL 2 //radial damage 41 | #define DAMAGETYPE_VISIBLE 4 //damage to all entities visible to the projectile 42 | 43 | typedef struct projectileinfo_s 44 | { 45 | char name[MAX_STRINGFIELD]; 46 | char model[MAX_STRINGFIELD]; 47 | int flags; 48 | float gravity; 49 | int damage; 50 | float radius; 51 | int visdamage; 52 | int damagetype; 53 | int healthinc; 54 | float push; 55 | float detonation; 56 | float bounce; 57 | float bouncefric; 58 | float bouncestop; 59 | } projectileinfo_t; 60 | 61 | typedef struct weaponinfo_s 62 | { 63 | int valid; //true if the weapon info is valid 64 | int number; //number of the weapon 65 | char name[MAX_STRINGFIELD]; 66 | char model[MAX_STRINGFIELD]; 67 | int level; 68 | int weaponindex; 69 | int flags; 70 | char projectile[MAX_STRINGFIELD]; 71 | int numprojectiles; 72 | float hspread; 73 | float vspread; 74 | float speed; 75 | float acceleration; 76 | vec3_t recoil; 77 | vec3_t offset; 78 | vec3_t angleoffset; 79 | float extrazvelocity; 80 | int ammoamount; 81 | int ammoindex; 82 | float activate; 83 | float reload; 84 | float spinup; 85 | float spindown; 86 | projectileinfo_t proj; //pointer to the used projectile 87 | } weaponinfo_t; 88 | 89 | //setup the weapon AI 90 | int BotSetupWeaponAI(void); 91 | //shut down the weapon AI 92 | void BotShutdownWeaponAI(void); 93 | //returns the best weapon to fight with 94 | int BotChooseBestFightWeapon(int weaponstate, int *inventory); 95 | //returns the information of the current weapon 96 | void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo); 97 | //loads the weapon weights 98 | int BotLoadWeaponWeights(int weaponstate, char *filename); 99 | //returns a handle to a newly allocated weapon state 100 | int BotAllocWeaponState(void); 101 | //frees the weapon state 102 | void BotFreeWeaponState(int weaponstate); 103 | //resets the whole weapon state 104 | void BotResetWeaponState(int weaponstate); 105 | -------------------------------------------------------------------------------- /deps/qcommon/surfaceflags.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | // This file must be identical in the quake and utils directories 24 | 25 | // contents flags are seperate bits 26 | // a given brush can contribute multiple content bits 27 | 28 | // these definitions also need to be in q_shared.h! 29 | 30 | #define CONTENTS_SOLID 1 // an eye is never valid in a solid 31 | #define CONTENTS_LAVA 8 32 | #define CONTENTS_SLIME 16 33 | #define CONTENTS_WATER 32 34 | #define CONTENTS_FOG 64 35 | 36 | #define CONTENTS_NOTTEAM1 0x0080 37 | #define CONTENTS_NOTTEAM2 0x0100 38 | #define CONTENTS_NOBOTCLIP 0x0200 39 | 40 | #define CONTENTS_AREAPORTAL 0x8000 41 | 42 | #define CONTENTS_PLAYERCLIP 0x10000 43 | #define CONTENTS_MONSTERCLIP 0x20000 44 | //bot specific contents types 45 | #define CONTENTS_TELEPORTER 0x40000 46 | #define CONTENTS_JUMPPAD 0x80000 47 | #define CONTENTS_CLUSTERPORTAL 0x100000 48 | #define CONTENTS_DONOTENTER 0x200000 49 | #define CONTENTS_BOTCLIP 0x400000 50 | #define CONTENTS_MOVER 0x800000 51 | 52 | #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity 53 | 54 | #define CONTENTS_BODY 0x2000000 // should never be on a brush, only in game 55 | #define CONTENTS_CORPSE 0x4000000 56 | #define CONTENTS_DETAIL 0x8000000 // brushes not used for the bsp 57 | #define CONTENTS_STRUCTURAL 0x10000000 // brushes used for the bsp 58 | #define CONTENTS_TRANSLUCENT 0x20000000 // don't consume surface fragments inside 59 | #define CONTENTS_TRIGGER 0x40000000 60 | #define CONTENTS_NODROP 0x80000000 // don't leave bodies or items (death fog, lava) 61 | 62 | #define SURF_NODAMAGE 0x1 // never give falling damage 63 | #define SURF_SLICK 0x2 // effects game physics 64 | #define SURF_SKY 0x4 // lighting from environment map 65 | #define SURF_LADDER 0x8 66 | #define SURF_NOIMPACT 0x10 // don't make missile explosions 67 | #define SURF_NOMARKS 0x20 // don't leave missile marks 68 | #define SURF_FLESH 0x40 // make flesh sounds and effects 69 | #define SURF_NODRAW 0x80 // don't generate a drawsurface at all 70 | #define SURF_HINT 0x100 // make a primary bsp splitter 71 | #define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes 72 | #define SURF_NOLIGHTMAP 0x400 // surface doesn't need a lightmap 73 | #define SURF_POINTLIGHT 0x800 // generate lighting info at vertexes 74 | #define SURF_METALSTEPS 0x1000 // clanking footsteps 75 | #define SURF_NOSTEPS 0x2000 // no footstep sounds 76 | #define SURF_NONSOLID 0x4000 // don't collide against curves with this set 77 | #define SURF_LIGHTFILTER 0x8000 // act as a light filter during q3map -light 78 | #define SURF_ALPHASHADOW 0x10000 // do per-pixel light shadow casting in q3map 79 | #define SURF_NODLIGHT 0x20000 // don't dlight even if solid (solid lava, skies) 80 | #define SURF_DUST 0x40000 // leave a dust trail when walking on this surface 81 | -------------------------------------------------------------------------------- /l_bsp_sin.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "sinfiles.h" 24 | 25 | #define SINGAME_BSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'R') //RBSP 26 | #define SINGAME_BSPVERSION 1 27 | 28 | #define SIN_BSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') //IBSP 29 | #define SIN_BSPVERSION 41 30 | 31 | 32 | extern int sin_nummodels; 33 | extern sin_dmodel_t *sin_dmodels;//[MAX_MAP_MODELS]; 34 | 35 | extern int sin_visdatasize; 36 | extern byte *sin_dvisdata;//[MAX_MAP_VISIBILITY]; 37 | extern sin_dvis_t *sin_dvis;// = (dvis_t *)sin_sin_dvisdata; 38 | 39 | extern int sin_lightdatasize; 40 | extern byte *sin_dlightdata;//[MAX_MAP_LIGHTING]; 41 | 42 | extern int sin_entdatasize; 43 | extern char *sin_dentdata;//[MAX_MAP_ENTSTRING]; 44 | 45 | extern int sin_numleafs; 46 | extern sin_dleaf_t *sin_dleafs;//[MAX_MAP_LEAFS]; 47 | 48 | extern int sin_numplanes; 49 | extern sin_dplane_t *sin_dplanes;//[MAX_MAP_PLANES]; 50 | 51 | extern int sin_numvertexes; 52 | extern sin_dvertex_t *sin_dvertexes;//[MAX_MAP_VERTS]; 53 | 54 | extern int sin_numnodes; 55 | extern sin_dnode_t *sin_dnodes;//[MAX_MAP_NODES]; 56 | 57 | extern int sin_numtexinfo; 58 | extern sin_texinfo_t *sin_texinfo;//[MAX_MAP_sin_texinfo]; 59 | 60 | extern int sin_numfaces; 61 | extern sin_dface_t *sin_dfaces;//[MAX_MAP_FACES]; 62 | 63 | extern int sin_numedges; 64 | extern sin_dedge_t *sin_dedges;//[MAX_MAP_EDGES]; 65 | 66 | extern int sin_numleaffaces; 67 | extern unsigned short *sin_dleaffaces;//[MAX_MAP_LEAFFACES]; 68 | 69 | extern int sin_numleafbrushes; 70 | extern unsigned short *sin_dleafbrushes;//[MAX_MAP_LEAFBRUSHES]; 71 | 72 | extern int sin_numsurfedges; 73 | extern int *sin_dsurfedges;//[MAX_MAP_SURFEDGES]; 74 | 75 | extern int sin_numbrushes; 76 | extern sin_dbrush_t *sin_dbrushes;//[MAX_MAP_BRUSHES]; 77 | 78 | extern int sin_numbrushsides; 79 | extern sin_dbrushside_t *sin_dbrushsides;//[MAX_MAP_BRUSHSIDES]; 80 | 81 | extern int sin_numareas; 82 | extern sin_darea_t *sin_dareas;//[MAX_MAP_AREAS]; 83 | 84 | extern int sin_numareaportals; 85 | extern sin_dareaportal_t *sin_dareaportals;//[MAX_MAP_AREAPORTALS]; 86 | 87 | extern int sin_numlightinfo; 88 | extern sin_lightvalue_t *sin_lightinfo;//[MAX_MAP_LIGHTINFO]; 89 | 90 | extern byte sin_dpop[256]; 91 | 92 | extern char sin_dbrushsidetextured[SIN_MAX_MAP_BRUSHSIDES]; 93 | 94 | void Sin_AllocMaxBSP(void); 95 | void Sin_FreeMaxBSP(void); 96 | 97 | void Sin_DecompressVis(byte *in, byte *decompressed); 98 | int Sin_CompressVis(byte *vis, byte *dest); 99 | 100 | void Sin_LoadBSPFile (char *filename, int offset, int length); 101 | void Sin_LoadBSPFileTexinfo (char *filename); // just for qdata 102 | void Sin_WriteBSPFile (char *filename); 103 | void Sin_PrintBSPFileSizes (void); 104 | void Sin_ParseEntities(void); 105 | void Sin_UnparseEntities(void); 106 | 107 | -------------------------------------------------------------------------------- /aas_edgemelting.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "qbsp.h" 24 | #include "botlib/aasfile.h" 25 | #include "aas_create.h" 26 | 27 | //=========================================================================== 28 | // try to melt the windings of the two faces 29 | // FIXME: this is buggy 30 | // 31 | // Parameter: - 32 | // Returns: - 33 | // Changes Globals: - 34 | //=========================================================================== 35 | int AAS_MeltFaceWinding(tmp_face_t *face1, tmp_face_t *face2) 36 | { 37 | int i, n; 38 | int splits = 0; 39 | winding_t *w2, *neww; 40 | plane_t *plane1; 41 | 42 | #ifdef DEBUG 43 | if (!face1->winding) Error("face1 %d without winding", face1->num); 44 | if (!face2->winding) Error("face2 %d without winding", face2->num); 45 | #endif //DEBUG 46 | w2 = face2->winding; 47 | plane1 = &mapplanes[face1->planenum]; 48 | for (i = 0; i < w2->numpoints; i++) 49 | { 50 | if (PointOnWinding(face1->winding, plane1->normal, plane1->dist, w2->p[i], &n)) 51 | { 52 | neww = AddWindingPoint(face1->winding, w2->p[i], n); 53 | FreeWinding(face1->winding); 54 | face1->winding = neww; 55 | 56 | splits++; 57 | } //end if 58 | } //end for 59 | return splits; 60 | } //end of the function AAS_MeltFaceWinding 61 | //=========================================================================== 62 | // melt the windings of the area faces 63 | // 64 | // Parameter: - 65 | // Returns: - 66 | // Changes Globals: - 67 | //=========================================================================== 68 | int AAS_MeltFaceWindingsOfArea(tmp_area_t *tmparea) 69 | { 70 | int side1, side2, num_windingsplits = 0; 71 | tmp_face_t *face1, *face2; 72 | 73 | for (face1 = tmparea->tmpfaces; face1; face1 = face1->next[side1]) 74 | { 75 | side1 = face1->frontarea != tmparea; 76 | for (face2 = tmparea->tmpfaces; face2; face2 = face2->next[side2]) 77 | { 78 | side2 = face2->frontarea != tmparea; 79 | if (face1 == face2) continue; 80 | num_windingsplits += AAS_MeltFaceWinding(face1, face2); 81 | } //end for 82 | } //end for 83 | return num_windingsplits; 84 | } //end of the function AAS_MeltFaceWindingsOfArea 85 | //=========================================================================== 86 | // melt the windings of the faces of all areas 87 | // 88 | // Parameter: - 89 | // Returns: - 90 | // Changes Globals: - 91 | //=========================================================================== 92 | void AAS_MeltAreaFaceWindings(void) 93 | { 94 | tmp_area_t *tmparea; 95 | int num_windingsplits = 0; 96 | 97 | Log_Write("AAS_MeltAreaFaceWindings\r\n"); 98 | qprintf("%6d edges melted", num_windingsplits); 99 | //NOTE: first convex area (zero) is a dummy 100 | for (tmparea = tmpaasworld.areas; tmparea; tmparea = tmparea->l_next) 101 | { 102 | num_windingsplits += AAS_MeltFaceWindingsOfArea(tmparea); 103 | qprintf("\r%6d", num_windingsplits); 104 | } //end for 105 | qprintf("\n"); 106 | Log_Write("%6d edges melted\r\n", num_windingsplits); 107 | } //end of the function AAS_MeltAreaFaceWindings 108 | 109 | -------------------------------------------------------------------------------- /deps/botlib/be_ai_gen.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: be_ai_gen.c 25 | * 26 | * desc: genetic selection 27 | * 28 | * $Archive: /MissionPack/code/botlib/be_ai_gen.c $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #include "qcommon/q_shared.h" 33 | #include "l_memory.h" 34 | #include "l_log.h" 35 | #include "l_utils.h" 36 | #include "l_script.h" 37 | #include "l_precomp.h" 38 | #include "l_struct.h" 39 | #include "aasfile.h" 40 | #include "botlib.h" 41 | #include "be_aas.h" 42 | #include "be_aas_funcs.h" 43 | #include "be_interface.h" 44 | #include "be_ai_gen.h" 45 | 46 | //=========================================================================== 47 | // 48 | // Parameter: - 49 | // Returns: - 50 | // Changes Globals: - 51 | //=========================================================================== 52 | int GeneticSelection(int numranks, float *rankings) 53 | { 54 | float sum, select; 55 | int i, index; 56 | 57 | sum = 0; 58 | for (i = 0; i < numranks; i++) 59 | { 60 | if (rankings[i] < 0) continue; 61 | sum += rankings[i]; 62 | } //end for 63 | if (sum > 0) 64 | { 65 | //select a bot where the ones with the higest rankings have 66 | //the highest chance of being selected 67 | select = random() * sum; 68 | for (i = 0; i < numranks; i++) 69 | { 70 | if (rankings[i] < 0) continue; 71 | sum -= rankings[i]; 72 | if (sum <= 0) return i; 73 | } //end for 74 | } //end if 75 | //select a bot randomly 76 | index = random() * numranks; 77 | for (i = 0; i < numranks; i++) 78 | { 79 | if (rankings[index] >= 0) return index; 80 | index = (index + 1) % numranks; 81 | } //end for 82 | return 0; 83 | } //end of the function GeneticSelection 84 | //=========================================================================== 85 | // 86 | // Parameter: - 87 | // Returns: - 88 | // Changes Globals: - 89 | //=========================================================================== 90 | int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child) 91 | { 92 | float rankings[256], max; 93 | int i; 94 | 95 | if (numranks > 256) 96 | { 97 | botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too many bots\n"); 98 | *parent1 = *parent2 = *child = 0; 99 | return qfalse; 100 | } //end if 101 | for (max = 0, i = 0; i < numranks; i++) 102 | { 103 | if (ranks[i] < 0) continue; 104 | max++; 105 | } //end for 106 | if (max < 3) 107 | { 108 | botimport.Print(PRT_WARNING, "GeneticParentsAndChildSelection: too few valid bots\n"); 109 | *parent1 = *parent2 = *child = 0; 110 | return qfalse; 111 | } //end if 112 | Com_Memcpy(rankings, ranks, sizeof(float) * numranks); 113 | //select first parent 114 | *parent1 = GeneticSelection(numranks, rankings); 115 | rankings[*parent1] = -1; 116 | //select second parent 117 | *parent2 = GeneticSelection(numranks, rankings); 118 | rankings[*parent2] = -1; 119 | //reverse the rankings 120 | max = 0; 121 | for (i = 0; i < numranks; i++) 122 | { 123 | if (rankings[i] < 0) continue; 124 | if (rankings[i] > max) max = rankings[i]; 125 | } //end for 126 | for (i = 0; i < numranks; i++) 127 | { 128 | if (rankings[i] < 0) continue; 129 | rankings[i] = max - rankings[i]; 130 | } //end for 131 | //select child 132 | *child = GeneticSelection(numranks, rankings); 133 | return qtrue; 134 | } //end of the function GeneticParentsAndChildSelection 135 | -------------------------------------------------------------------------------- /deps/qcommon/vm_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | #include "q_shared.h" 23 | #include "qcommon.h" 24 | 25 | #define OPSTACK_SIZE 256 26 | #define OPSTACK_MASK (OPSTACK_SIZE-1) 27 | 28 | // don't change 29 | // Hardcoded in q3asm an reserved at end of bss 30 | #define PROGRAM_STACK_SIZE 0x10000 31 | #define PROGRAM_STACK_MASK (PROGRAM_STACK_SIZE-1) 32 | 33 | typedef enum { 34 | OP_UNDEF, 35 | 36 | OP_IGNORE, 37 | 38 | OP_BREAK, 39 | 40 | OP_ENTER, 41 | OP_LEAVE, 42 | OP_CALL, 43 | OP_PUSH, 44 | OP_POP, 45 | 46 | OP_CONST, 47 | OP_LOCAL, 48 | 49 | OP_JUMP, 50 | 51 | //------------------- 52 | 53 | OP_EQ, 54 | OP_NE, 55 | 56 | OP_LTI, 57 | OP_LEI, 58 | OP_GTI, 59 | OP_GEI, 60 | 61 | OP_LTU, 62 | OP_LEU, 63 | OP_GTU, 64 | OP_GEU, 65 | 66 | OP_EQF, 67 | OP_NEF, 68 | 69 | OP_LTF, 70 | OP_LEF, 71 | OP_GTF, 72 | OP_GEF, 73 | 74 | //------------------- 75 | 76 | OP_LOAD1, 77 | OP_LOAD2, 78 | OP_LOAD4, 79 | OP_STORE1, 80 | OP_STORE2, 81 | OP_STORE4, // *(stack[top-1]) = stack[top] 82 | OP_ARG, 83 | 84 | OP_BLOCK_COPY, 85 | 86 | //------------------- 87 | 88 | OP_SEX8, 89 | OP_SEX16, 90 | 91 | OP_NEGI, 92 | OP_ADD, 93 | OP_SUB, 94 | OP_DIVI, 95 | OP_DIVU, 96 | OP_MODI, 97 | OP_MODU, 98 | OP_MULI, 99 | OP_MULU, 100 | 101 | OP_BAND, 102 | OP_BOR, 103 | OP_BXOR, 104 | OP_BCOM, 105 | 106 | OP_LSH, 107 | OP_RSHI, 108 | OP_RSHU, 109 | 110 | OP_NEGF, 111 | OP_ADDF, 112 | OP_SUBF, 113 | OP_DIVF, 114 | OP_MULF, 115 | 116 | OP_CVIF, 117 | OP_CVFI 118 | } opcode_t; 119 | 120 | 121 | 122 | typedef int vmptr_t; 123 | 124 | typedef struct vmSymbol_s { 125 | struct vmSymbol_s *next; 126 | int symValue; 127 | int profileCount; 128 | char symName[1]; // variable sized 129 | } vmSymbol_t; 130 | 131 | #define VM_OFFSET_PROGRAM_STACK 0 132 | #define VM_OFFSET_SYSTEM_CALL 4 133 | 134 | struct vm_s { 135 | // DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES 136 | // USED BY THE ASM CODE 137 | int programStack; // the vm may be recursively entered 138 | intptr_t (*systemCall)( intptr_t *parms ); 139 | 140 | //------------------------------------ 141 | 142 | char name[MAX_QPATH]; 143 | 144 | // for dynamic linked modules 145 | void *dllHandle; 146 | intptr_t (QDECL *entryPoint)( int callNum, ... ); 147 | void (*destroy)(vm_t* self); 148 | 149 | // for interpreted modules 150 | qboolean currentlyInterpreting; 151 | 152 | qboolean compiled; 153 | byte *codeBase; 154 | int codeLength; 155 | 156 | int *instructionPointers; 157 | int instructionCount; 158 | 159 | byte *dataBase; 160 | int dataMask; 161 | 162 | int stackBottom; // if programStack < stackBottom, error 163 | 164 | int numSymbols; 165 | struct vmSymbol_s *symbols; 166 | 167 | int callLevel; // counts recursive VM_Call 168 | int breakFunction; // increment breakCount on function entry to this 169 | int breakCount; 170 | 171 | char fqpath[MAX_QPATH+1] ; 172 | 173 | byte *jumpTableTargets; 174 | int numJumpTableTargets; 175 | }; 176 | 177 | 178 | extern vm_t *currentVM; 179 | extern int vm_debugLevel; 180 | 181 | void VM_Compile( vm_t *vm, vmHeader_t *header ); 182 | int VM_CallCompiled( vm_t *vm, int *args ); 183 | 184 | void VM_PrepareInterpreter( vm_t *vm, vmHeader_t *header ); 185 | int VM_CallInterpreted( vm_t *vm, int *args ); 186 | 187 | vmSymbol_t *VM_ValueToFunctionSymbol( vm_t *vm, int value ); 188 | int VM_SymbolToValue( vm_t *vm, const char *symbol ); 189 | const char *VM_ValueToSymbol( vm_t *vm, int value ); 190 | void VM_LogSyscalls( int *args ); 191 | -------------------------------------------------------------------------------- /l_bsp_ent.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "l_cmd.h" 24 | #include "l_math.h" 25 | #include "l_mem.h" 26 | #include "l_log.h" 27 | #include "botlib/l_script.h" 28 | #include "l_bsp_ent.h" 29 | 30 | #define MAX_KEY 32 31 | #define MAX_VALUE 1024 32 | 33 | int num_entities; 34 | entity_t entities[MAX_MAP_ENTITIES]; 35 | 36 | void StripTrailing(char *e) 37 | { 38 | char *s; 39 | 40 | s = e + strlen(e)-1; 41 | while (s >= e && *s <= 32) 42 | { 43 | *s = 0; 44 | s--; 45 | } 46 | } 47 | 48 | /* 49 | ================= 50 | ParseEpair 51 | ================= 52 | */ 53 | epair_t *ParseEpair(script_t *script) 54 | { 55 | epair_t *e; 56 | token_t token; 57 | 58 | e = GetMemory(sizeof(epair_t)); 59 | memset (e, 0, sizeof(epair_t)); 60 | 61 | PS_ExpectAnyToken(script, &token); 62 | StripDoubleQuotes(token.string); 63 | if (strlen(token.string) >= MAX_KEY-1) 64 | Error ("ParseEpair: token %s too long", token.string); 65 | e->key = copystring(token.string); 66 | PS_ExpectAnyToken(script, &token); 67 | StripDoubleQuotes(token.string); 68 | if (strlen(token.string) >= MAX_VALUE-1) 69 | Error ("ParseEpair: token %s too long", token.string); 70 | e->value = copystring(token.string); 71 | 72 | // strip trailing spaces 73 | StripTrailing(e->key); 74 | StripTrailing(e->value); 75 | 76 | return e; 77 | } //end of the function ParseEpair 78 | 79 | 80 | /* 81 | ================ 82 | ParseEntity 83 | ================ 84 | */ 85 | qboolean ParseEntity(script_t *script) 86 | { 87 | epair_t *e; 88 | entity_t *mapent; 89 | token_t token; 90 | 91 | if (!PS_ReadToken(script, &token)) 92 | return false; 93 | 94 | if (strcmp(token.string, "{")) 95 | Error ("ParseEntity: { not found"); 96 | 97 | if (num_entities == MAX_MAP_ENTITIES) 98 | Error ("num_entities == MAX_MAP_ENTITIES"); 99 | 100 | mapent = &entities[num_entities]; 101 | num_entities++; 102 | 103 | do 104 | { 105 | if (!PS_ReadToken(script, &token)) 106 | Error ("ParseEntity: EOF without closing brace"); 107 | if (!strcmp(token.string, "}") ) 108 | break; 109 | PS_UnreadLastToken(script); 110 | e = ParseEpair(script); 111 | e->next = mapent->epairs; 112 | mapent->epairs = e; 113 | } while (1); 114 | 115 | return true; 116 | } //end of the function ParseEntity 117 | 118 | void PrintEntity (entity_t *ent) 119 | { 120 | epair_t *ep; 121 | 122 | printf ("------- entity %p -------\n", ent); 123 | for (ep=ent->epairs ; ep ; ep=ep->next) 124 | { 125 | printf ("%s = %s\n", ep->key, ep->value); 126 | } 127 | 128 | } 129 | 130 | void SetKeyValue (entity_t *ent, char *key, char *value) 131 | { 132 | epair_t *ep; 133 | 134 | for (ep=ent->epairs ; ep ; ep=ep->next) 135 | if (!strcmp (ep->key, key) ) 136 | { 137 | FreeMemory(ep->value); 138 | ep->value = copystring(value); 139 | return; 140 | } 141 | ep = GetMemory(sizeof(*ep)); 142 | ep->next = ent->epairs; 143 | ent->epairs = ep; 144 | ep->key = copystring(key); 145 | ep->value = copystring(value); 146 | } 147 | 148 | char *ValueForKey (entity_t *ent, char *key) 149 | { 150 | epair_t *ep; 151 | 152 | for (ep=ent->epairs ; ep ; ep=ep->next) 153 | if (!strcmp (ep->key, key) ) 154 | return ep->value; 155 | return ""; 156 | } 157 | 158 | vec_t FloatForKey (entity_t *ent, char *key) 159 | { 160 | char *k; 161 | 162 | k = ValueForKey (ent, key); 163 | return atof(k); 164 | } 165 | 166 | void GetVectorForKey (entity_t *ent, char *key, vec3_t vec) 167 | { 168 | char *k; 169 | double v1, v2, v3; 170 | 171 | k = ValueForKey (ent, key); 172 | // scanf into doubles, then assign, so it is vec_t size independent 173 | v1 = v2 = v3 = 0; 174 | sscanf (k, "%lf %lf %lf", &v1, &v2, &v3); 175 | vec[0] = v1; 176 | vec[1] = v2; 177 | vec[2] = v3; 178 | } 179 | 180 | 181 | -------------------------------------------------------------------------------- /l_cmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // cmdlib.h 23 | 24 | #ifndef SIN 25 | #define SIN 26 | #endif //SIN 27 | 28 | #ifndef __CMDLIB__ 29 | #define __CMDLIB__ 30 | 31 | #ifdef _WIN32 32 | #pragma warning(disable : 4244) // MIPS 33 | #pragma warning(disable : 4136) // X86 34 | #pragma warning(disable : 4051) // ALPHA 35 | 36 | #pragma warning(disable : 4018) // signed/unsigned mismatch 37 | #pragma warning(disable : 4305) // truncate from double to float 38 | #endif 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #ifndef __BYTEBOOL__ 49 | #define __BYTEBOOL__ 50 | typedef enum {false, true} qboolean; 51 | typedef unsigned char byte; 52 | #endif 53 | 54 | // the dec offsetof macro doesnt work very well... 55 | #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) 56 | 57 | 58 | // set these before calling CheckParm 59 | extern int myargc; 60 | extern char **myargv; 61 | 62 | char *strupr (char *in); 63 | char *strlower (char *in); 64 | int Q_strncasecmp (char *s1, char *s2, int n); 65 | int Q_strcasecmp (char *s1, char *s2); 66 | void Q_strncpyz( char *dest, const char *src, int destsize ); 67 | void Q_getwd (char *out, size_t size); 68 | 69 | int Q_filelength (FILE *f); 70 | int FileTime (char *path); 71 | 72 | void Q_mkdir (char *path); 73 | 74 | extern char qdir[1024]; 75 | extern char gamedir[1024]; 76 | void SetQdirFromPath (char *path); 77 | char *ExpandArg (char *path); // from cmd line 78 | char *ExpandPath (char *path); // from scripts 79 | char *ExpandPathAndArchive (char *path); 80 | 81 | 82 | double I_FloatTime (void); 83 | 84 | void Error(char *error, ...); 85 | void Warning(char *warning, ...); 86 | 87 | int CheckParm (char *check); 88 | 89 | FILE *SafeOpenWrite (char *filename); 90 | FILE *SafeOpenRead (char *filename); 91 | void SafeRead (FILE *f, void *buffer, int count); 92 | void SafeWrite (FILE *f, void *buffer, int count); 93 | 94 | int LoadFile (char *filename, void **bufferptr, int offset, int length); 95 | int TryLoadFile (char *filename, void **bufferptr); 96 | void SaveFile (char *filename, void *buffer, int count); 97 | qboolean FileExists (char *filename); 98 | 99 | void DefaultExtension (char *path, char *extension); 100 | void DefaultPath (char *path, char *basepath); 101 | void StripFilename (char *path); 102 | void StripExtension (char *path); 103 | 104 | void ExtractFilePath (char *path, char *dest); 105 | void ExtractFileBase (char *path, char *dest); 106 | void ExtractFileExtension (char *path, char *dest); 107 | 108 | int ParseNum (char *str); 109 | 110 | short BigShort (short l); 111 | short LittleShort (short l); 112 | int BigLong (int l); 113 | int LittleLong (int l); 114 | float BigFloat (float l); 115 | float LittleFloat (float l); 116 | 117 | #ifdef SIN 118 | unsigned short BigUnsignedShort (unsigned short l); 119 | unsigned short LittleUnsignedShort (unsigned short l); 120 | unsigned BigUnsigned (unsigned l); 121 | unsigned LittleUnsigned (unsigned l); 122 | #endif 123 | 124 | 125 | char *COM_Parse (char *data); 126 | 127 | extern char com_token[1024]; 128 | extern qboolean com_eof; 129 | 130 | char *copystring(char *s); 131 | 132 | 133 | void CRC_Init(unsigned short *crcvalue); 134 | void CRC_ProcessByte(unsigned short *crcvalue, byte data); 135 | unsigned short CRC_Value(unsigned short crcvalue); 136 | 137 | void CreatePath (char *path); 138 | void QCopyFile (char *from, char *to); 139 | 140 | extern qboolean archive; 141 | extern char archivedir[1024]; 142 | 143 | 144 | extern qboolean verbose; 145 | void qprintf (char *format, ...); 146 | 147 | void ExpandWildcards (int *argc, char ***argv); 148 | 149 | 150 | // for compression routines 151 | typedef struct 152 | { 153 | byte *data; 154 | int count; 155 | } cblock_t; 156 | 157 | #endif 158 | 159 | -------------------------------------------------------------------------------- /deps/botlib/be_ai_chat.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | /***************************************************************************** 24 | * name: be_ai_chat.h 25 | * 26 | * desc: char AI 27 | * 28 | * $Archive: /source/code/botlib/be_ai_chat.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #define MAX_MESSAGE_SIZE 256 33 | #define MAX_CHATTYPE_NAME 32 34 | #define MAX_MATCHVARIABLES 8 35 | 36 | #define CHAT_GENDERLESS 0 37 | #define CHAT_GENDERFEMALE 1 38 | #define CHAT_GENDERMALE 2 39 | 40 | #define CHAT_ALL 0 41 | #define CHAT_TEAM 1 42 | #define CHAT_TELL 2 43 | 44 | //a console message 45 | typedef struct bot_consolemessage_s 46 | { 47 | int handle; 48 | float time; //message time 49 | int type; //message type 50 | char message[MAX_MESSAGE_SIZE]; //message 51 | struct bot_consolemessage_s *prev, *next; //prev and next in list 52 | } bot_consolemessage_t; 53 | 54 | //match variable 55 | typedef struct bot_matchvariable_s 56 | { 57 | char offset; 58 | int length; 59 | } bot_matchvariable_t; 60 | //returned to AI when a match is found 61 | typedef struct bot_match_s 62 | { 63 | char string[MAX_MESSAGE_SIZE]; 64 | int type; 65 | int subtype; 66 | bot_matchvariable_t variables[MAX_MATCHVARIABLES]; 67 | } bot_match_t; 68 | 69 | //setup the chat AI 70 | int BotSetupChatAI(void); 71 | //shutdown the chat AI 72 | void BotShutdownChatAI(void); 73 | //returns the handle to a newly allocated chat state 74 | int BotAllocChatState(void); 75 | //frees the chatstate 76 | void BotFreeChatState(int handle); 77 | //adds a console message to the chat state 78 | void BotQueueConsoleMessage(int chatstate, int type, char *message); 79 | //removes the console message from the chat state 80 | void BotRemoveConsoleMessage(int chatstate, int handle); 81 | //returns the next console message from the state 82 | int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm); 83 | //returns the number of console messages currently stored in the state 84 | int BotNumConsoleMessages(int chatstate); 85 | //selects a chat message of the given type 86 | void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); 87 | //returns the number of initial chat messages of the given type 88 | int BotNumInitialChats(int chatstate, char *type); 89 | //find and select a reply for the given message 90 | int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7); 91 | //returns the length of the currently selected chat message 92 | int BotChatLength(int chatstate); 93 | //enters the selected chat message 94 | void BotEnterChat(int chatstate, int clientto, int sendto); 95 | //get the chat message ready to be output 96 | void BotGetChatMessage(int chatstate, char *buf, int size); 97 | //checks if the first string contains the second one, returns index into first string or -1 if not found 98 | int StringContains(char *str1, char *str2, int casesensitive); 99 | //finds a match for the given string using the match templates 100 | int BotFindMatch(char *str, bot_match_t *match, unsigned long int context); 101 | //returns a variable from a match 102 | void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size); 103 | //unify all the white spaces in the string 104 | void UnifyWhiteSpaces(char *string); 105 | //replace all the context related synonyms in the string 106 | void BotReplaceSynonyms(char *string, unsigned long int context); 107 | //loads a chat file for the chat state 108 | int BotLoadChatFile(int chatstate, char *chatfile, char *chatname); 109 | //store the gender of the bot in the chat state 110 | void BotSetChatGender(int chatstate, int gender); 111 | //store the bot name in the chat state 112 | void BotSetChatName(int chatstate, char *name, int client); 113 | 114 | -------------------------------------------------------------------------------- /aas_create.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #define AREA_PORTAL 1 24 | 25 | //temporary AAS face 26 | typedef struct tmp_face_s 27 | { 28 | int num; //face number 29 | int planenum; //number of the plane the face is in 30 | winding_t *winding; //winding of the face 31 | struct tmp_area_s *frontarea; //area at the front of the face 32 | struct tmp_area_s *backarea; //area at the back of the face 33 | int faceflags; //flags of this face 34 | int aasfacenum; //the number of the aas face used for this face 35 | //double link list pointers for front and back area 36 | struct tmp_face_s *prev[2], *next[2]; 37 | //links in the list with faces 38 | struct tmp_face_s *l_prev, *l_next; 39 | } tmp_face_t; 40 | 41 | //temporary AAS area settings 42 | typedef struct tmp_areasettings_s 43 | { 44 | //could also add all kind of statistic fields 45 | int contents; //contents of the area 46 | int modelnum; //bsp model inside this area 47 | int areaflags; //area flags 48 | int presencetype; //how a bot can be present in this area 49 | int numreachableareas; //number of reachable areas from this one 50 | int firstreachablearea; //first reachable area in the reachable area index 51 | } tmp_areasettings_t; 52 | 53 | //temporary AAS area 54 | typedef struct tmp_area_s 55 | { 56 | int areanum; //number of the area 57 | struct tmp_face_s *tmpfaces; //the faces of the area 58 | int presencetype; //presence type of the area 59 | int contents; //area contents 60 | int modelnum; //bsp model inside this area 61 | int invalid; //true if the area is invalid 62 | tmp_areasettings_t *settings; //area settings 63 | struct tmp_area_s *mergedarea; //points to the new area after merging 64 | //when mergedarea != 0 the area has only the 65 | //seperating face of the merged areas 66 | int aasareanum; //number of the aas area created for this tmp area 67 | //links in the list with areas 68 | struct tmp_area_s *l_prev, *l_next; 69 | } tmp_area_t; 70 | 71 | //temporary AAS node 72 | typedef struct tmp_node_s 73 | { 74 | int planenum; //node plane number 75 | struct tmp_area_s *tmparea; //points to an area if this node is an area 76 | struct tmp_node_s *children[2]; //child nodes of this node 77 | } tmp_node_t; 78 | 79 | #define NODEBUF_SIZE 128 80 | //node buffer 81 | typedef struct tmp_nodebuf_s 82 | { 83 | int numnodes; 84 | struct tmp_nodebuf_s *next; 85 | tmp_node_t nodes[NODEBUF_SIZE]; 86 | } tmp_nodebuf_t; 87 | 88 | //the whole temorary AAS 89 | typedef struct tmp_aas_s 90 | { 91 | //faces 92 | int numfaces; 93 | int facenum; 94 | tmp_face_t *faces; 95 | //areas 96 | int numareas; 97 | int areanum; 98 | tmp_area_t *areas; 99 | //area settings 100 | int numareasettings; 101 | tmp_areasettings_t *areasettings; 102 | //nodes 103 | int numnodes; 104 | tmp_node_t *nodes; 105 | //node buffer 106 | tmp_nodebuf_t *nodebuffer; 107 | } tmp_aas_t; 108 | 109 | extern tmp_aas_t tmpaasworld; 110 | 111 | //creates a .AAS file with the given name from an already loaded map 112 | void AAS_Create(char *aasfile); 113 | //adds a face side to an area 114 | void AAS_AddFaceSideToArea(tmp_face_t *tmpface, int side, tmp_area_t *tmparea); 115 | //remvoes a face from an area 116 | void AAS_RemoveFaceFromArea(tmp_face_t *tmpface, tmp_area_t *tmparea); 117 | //allocate a tmp face 118 | tmp_face_t *AAS_AllocTmpFace(void); 119 | //free the tmp face 120 | void AAS_FreeTmpFace(tmp_face_t *tmpface); 121 | //allocate a tmp area 122 | tmp_area_t *AAS_AllocTmpArea(void); 123 | //free a tmp area 124 | void AAS_FreeTmpArea(tmp_area_t *tmparea); 125 | //allocate a tmp node 126 | tmp_node_t *AAS_AllocTmpNode(void); 127 | //free a tmp node 128 | void AAS_FreeTmpNode(tmp_node_t *node); 129 | //checks if an area is ok 130 | void AAS_CheckArea(tmp_area_t *tmparea); 131 | //flips the area faces where needed 132 | void AAS_FlipAreaFaces(tmp_area_t *tmparea); 133 | //returns true if the face is a gap seen from the given side 134 | int AAS_GapFace(tmp_face_t *tmpface, int side); 135 | //returns true if the face is a ground face 136 | int AAS_GroundFace(tmp_face_t *tmpface); 137 | -------------------------------------------------------------------------------- /deps/botlib/be_ai_goal.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | // 23 | /***************************************************************************** 24 | * name: be_ai_goal.h 25 | * 26 | * desc: goal AI 27 | * 28 | * $Archive: /source/code/botlib/be_ai_goal.h $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #define MAX_AVOIDGOALS 256 33 | #define MAX_GOALSTACK 8 34 | 35 | #define GFL_NONE 0 36 | #define GFL_ITEM 1 37 | #define GFL_ROAM 2 38 | #define GFL_DROPPED 4 39 | 40 | //a bot goal 41 | typedef struct bot_goal_s 42 | { 43 | vec3_t origin; //origin of the goal 44 | int areanum; //area number of the goal 45 | vec3_t mins, maxs; //mins and maxs of the goal 46 | int entitynum; //number of the goal entity 47 | int number; //goal number 48 | int flags; //goal flags 49 | int iteminfo; //item information 50 | } bot_goal_t; 51 | 52 | //reset the whole goal state, but keep the item weights 53 | void BotResetGoalState(int goalstate); 54 | //reset avoid goals 55 | void BotResetAvoidGoals(int goalstate); 56 | //remove the goal with the given number from the avoid goals 57 | void BotRemoveFromAvoidGoals(int goalstate, int number); 58 | //push a goal onto the goal stack 59 | void BotPushGoal(int goalstate, bot_goal_t *goal); 60 | //pop a goal from the goal stack 61 | void BotPopGoal(int goalstate); 62 | //empty the bot's goal stack 63 | void BotEmptyGoalStack(int goalstate); 64 | //dump the avoid goals 65 | void BotDumpAvoidGoals(int goalstate); 66 | //dump the goal stack 67 | void BotDumpGoalStack(int goalstate); 68 | //get the name name of the goal with the given number 69 | void BotGoalName(int number, char *name, int size); 70 | //get the top goal from the stack 71 | int BotGetTopGoal(int goalstate, bot_goal_t *goal); 72 | //get the second goal on the stack 73 | int BotGetSecondGoal(int goalstate, bot_goal_t *goal); 74 | //choose the best long term goal item for the bot 75 | int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags); 76 | //choose the best nearby goal item for the bot 77 | //the item may not be further away from the current bot position than maxtime 78 | //also the travel time from the nearby goal towards the long term goal may not 79 | //be larger than the travel time towards the long term goal from the current bot position 80 | int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags, 81 | bot_goal_t *ltg, float maxtime); 82 | //returns true if the bot touches the goal 83 | int BotTouchingGoal(vec3_t origin, bot_goal_t *goal); 84 | //returns true if the goal should be visible but isn't 85 | int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal); 86 | //search for a goal for the given classname, the index can be used 87 | //as a start point for the search when multiple goals are available with that same classname 88 | int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal); 89 | //get the next camp spot in the map 90 | int BotGetNextCampSpotGoal(int num, bot_goal_t *goal); 91 | //get the map location with the given name 92 | int BotGetMapLocationGoal(char *name, bot_goal_t *goal); 93 | //returns the avoid goal time 94 | float BotAvoidGoalTime(int goalstate, int number); 95 | //set the avoid goal time 96 | void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime); 97 | //initializes the items in the level 98 | void BotInitLevelItems(void); 99 | //regularly update dynamic entity items (dropped weapons, flags etc.) 100 | void BotUpdateEntityItems(void); 101 | //interbreed the goal fuzzy logic 102 | void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child); 103 | //save the goal fuzzy logic to disk 104 | void BotSaveGoalFuzzyLogic(int goalstate, char *filename); 105 | //mutate the goal fuzzy logic 106 | void BotMutateGoalFuzzyLogic(int goalstate, float range); 107 | //loads item weights for the bot 108 | int BotLoadItemWeights(int goalstate, char *filename); 109 | //frees the item weights of the bot 110 | void BotFreeItemWeights(int goalstate); 111 | //returns the handle of a newly allocated goal state 112 | int BotAllocGoalState(int client); 113 | //free the given goal state 114 | void BotFreeGoalState(int handle); 115 | //setup the goal AI 116 | int BotSetupGoalAI(void); 117 | //shut down the goal AI 118 | void BotShutdownGoalAI(void); 119 | -------------------------------------------------------------------------------- /l_poly.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | //a winding gives the bounding points of a convex polygon 24 | typedef struct 25 | { 26 | int numpoints; 27 | vec3_t p[4]; //variable sized 28 | } winding_t; 29 | 30 | #define MAX_POINTS_ON_WINDING 96 31 | 32 | //you can define on_epsilon in the makefile as tighter 33 | #ifndef ON_EPSILON 34 | #define ON_EPSILON 0.1 35 | #endif 36 | //winding errors 37 | #define WE_NONE 0 38 | #define WE_NOTENOUGHPOINTS 1 39 | #define WE_SMALLAREA 2 40 | #define WE_POINTBOGUSRANGE 3 41 | #define WE_POINTOFFPLANE 4 42 | #define WE_DEGENERATEEDGE 5 43 | #define WE_NONCONVEX 6 44 | 45 | //allocates a winding 46 | winding_t *AllocWinding (int points); 47 | //returns the area of the winding 48 | vec_t WindingArea (winding_t *w); 49 | //gives the center of the winding 50 | void WindingCenter (winding_t *w, vec3_t center); 51 | //clips the given winding to the given plane and gives the front 52 | //and back part of the clipped winding 53 | void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, 54 | vec_t epsilon, winding_t **front, winding_t **back); 55 | //returns the fragment of the given winding that is on the front 56 | //side of the cliping plane. The original is freed. 57 | winding_t *ChopWinding (winding_t *in, vec3_t normal, vec_t dist); 58 | //returns a copy of the given winding 59 | winding_t *CopyWinding (winding_t *w); 60 | //returns the reversed winding of the given one 61 | winding_t *ReverseWinding (winding_t *w); 62 | //returns a base winding for the given plane 63 | winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist); 64 | //checks the winding for errors 65 | void CheckWinding (winding_t *w); 66 | //returns the plane normal and dist the winding is in 67 | void WindingPlane(winding_t *w, vec3_t normal, vec_t *dist); 68 | //removes colinear points from the winding 69 | void RemoveColinearPoints(winding_t *w); 70 | //returns on which side of the plane the winding is situated 71 | int WindingOnPlaneSide(winding_t *w, vec3_t normal, vec_t dist); 72 | //frees the winding 73 | void FreeWinding(winding_t *w); 74 | //gets the bounds of the winding 75 | void WindingBounds(winding_t *w, vec3_t mins, vec3_t maxs); 76 | //chops the winding with the given plane, the original winding is freed if clipped 77 | void ChopWindingInPlace (winding_t **w, vec3_t normal, vec_t dist, vec_t epsilon); 78 | //prints the winding points on STDOUT 79 | void pw(winding_t *w); 80 | //try to merge the two windings which are in the given plane 81 | //the original windings are undisturbed 82 | //the merged winding is returned when merging was possible 83 | //NULL is returned otherwise 84 | winding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal); 85 | //brute force winding merging... creates a convex winding out of 86 | //the two whatsoever 87 | winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal); 88 | 89 | //#ifdef ME 90 | void ResetWindings(void); 91 | //returns the amount of winding memory 92 | int WindingMemory(void); 93 | int WindingPeakMemory(void); 94 | int ActiveWindings(void); 95 | //returns the winding error string 96 | char *WindingErrorString(void); 97 | //returns one of the WE_ flags when the winding has errors 98 | int WindingError(winding_t *w); 99 | //removes equal points from the winding 100 | void RemoveEqualPoints(winding_t *w, float epsilon); 101 | //returns a winding with a point added at the given spot to the 102 | //given winding, original winding is NOT freed 103 | winding_t *AddWindingPoint(winding_t *w, vec3_t point, int spot); 104 | //returns true if the point is on one of the winding 'edges' 105 | //when the point is on one of the edged the number of the first 106 | //point of the edge is stored in 'spot' 107 | int PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *spot); 108 | //find a plane seperating the two windings 109 | //true is returned when the windings area adjacent 110 | //the seperating plane normal and distance area stored in 'normal' and 'dist' 111 | //this plane will contain both the piece of common edge of the two windings 112 | //and the vector 'dir' 113 | int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, 114 | vec3_t normal, float *dist); 115 | // 116 | int WindingsNonConvex(winding_t *w1, winding_t *w2, 117 | vec3_t normal1, vec3_t normal2, 118 | float dist1, float dist2); 119 | //#endif //ME 120 | 121 | -------------------------------------------------------------------------------- /deps/qcommon/vm_powerpc_asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 2008 Przemyslaw Iskra 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #ifndef VM_POWERPC_ASM_H 24 | #define VM_POWERPC_ASM_H 25 | 26 | /* 27 | * Register information according to: 28 | * http://refspecs.freestandards.org/elf/elfspec_ppc.pdf 29 | */ 30 | 31 | #define r0 0 // volatile 32 | #define r1 1 // caller safe ( stack pointer ) 33 | #define r2 2 // reserved 34 | #define r3 3 // callee safe 35 | #define r4 4 // callee safe 36 | #define r5 5 // callee safe 37 | #define r6 6 // callee safe 38 | #define r7 7 // callee safe 39 | #define r8 8 // callee safe 40 | #define r9 9 // callee safe 41 | #define r10 10 // callee safe 42 | #define r11 11 // volatile 43 | #define r12 12 // volatile 44 | #define r13 13 // reserved ( small data area ) 45 | #define r14 14 // caller safe 46 | #define r15 15 // caller safe 47 | #define r16 16 // caller safe 48 | #define r17 17 // caller safe 49 | #define r18 18 // caller safe 50 | #define r19 19 // caller safe 51 | #define r20 20 // caller safe 52 | #define r21 21 // caller safe 53 | #define r22 22 // caller safe 54 | #define r23 23 // caller safe 55 | #define r24 24 // caller safe 56 | #define r25 25 // caller safe 57 | #define r26 26 // caller safe 58 | #define r27 27 // caller safe 59 | #define r28 28 // caller safe 60 | #define r29 29 // caller safe 61 | #define r30 30 // caller safe 62 | #define r31 31 // caller safe ( environment pointers ) 63 | 64 | #define f0 0 // callee safe 65 | #define f1 1 // callee safe 66 | #define f2 2 // callee safe 67 | #define f3 3 // callee safe 68 | #define f4 4 // callee safe 69 | #define f5 5 // callee safe 70 | #define f6 6 // callee safe 71 | #define f7 7 // callee safe 72 | #define f8 8 // callee safe 73 | #define f9 9 // callee safe 74 | #define f10 10 // callee safe 75 | #define f11 11 // callee safe 76 | #define f12 12 // callee safe 77 | #define f13 13 // callee safe 78 | #define f14 14 // caller safe 79 | #define f15 15 // caller safe 80 | #define f16 16 // caller safe 81 | #define f17 17 // caller safe 82 | #define f18 18 // caller safe 83 | #define f19 19 // caller safe 84 | #define f20 20 // caller safe 85 | #define f21 21 // caller safe 86 | #define f22 22 // caller safe 87 | #define f23 23 // caller safe 88 | #define f24 24 // caller safe 89 | #define f25 25 // caller safe 90 | #define f26 26 // caller safe 91 | #define f27 27 // caller safe 92 | #define f28 28 // caller safe 93 | #define f29 29 // caller safe 94 | #define f30 30 // caller safe 95 | #define f31 31 // caller safe 96 | 97 | #define cr0 0 // volatile 98 | #define cr1 1 // volatile 99 | #define cr2 2 // caller safe 100 | #define cr3 3 // caller safe 101 | #define cr4 4 // caller safe 102 | #define cr5 5 // volatile 103 | #define cr6 6 // volatile 104 | #define cr7 7 // volatile 105 | 106 | #define lt 0 107 | #define gt 1 108 | #define eq 2 109 | #define so 3 110 | 111 | // branch bo field values 112 | #define branchLikely 1 113 | #define branchFalse 4 114 | #define branchTrue 12 115 | #define branchAlways 20 116 | 117 | // branch extensions (change branch type) 118 | #define branchExtLink 0x0001 119 | 120 | 121 | /* 122 | * This list must match exactly the powerpc_opcodes list from vm_powerpc_asm.c 123 | * If you're changing the original list remember to regenerate this one. You 124 | * may do so using this perl script: 125 | perl -p -e 'BEGIN{%t=("-"=>m=>"+"=>p=>"."=>d=>);$l=""}$o=0 if/^}/; 126 | if($o && s/^{ "(.*?)([\.+-])?".+/i\U$1\E$t{$2}/s){$_.="_" while$l{$_}; 127 | $l{$_}=1;if(length $l.$_ > 70){$s=$_;$_="\t$l\n";$l="$s,"}else 128 | {$l.=" $_,";$_=undef}}else{$o=1 if/powerpc_opcodes.*=/;$_=undef}; 129 | END{print "\t$l\n"}' < vm_powerpc_asm.c 130 | */ 131 | 132 | typedef enum powerpc_iname { 133 | iCMPLWI, iCMPWI, iCMPW, iCMPLW, iFCMPU, iLI, iLIS, iADDI, iADDIS, 134 | iBLTm, iBC, iBCL, iB, iBL, iBLR, iBCTR, iBCTRL, iRLWINM, iNOP, iORI, 135 | iXORIS, iLDX, iLWZX, iSLW, iAND, iSUB, iLBZX, iNEG, iNOT, iSTWX, iSTBX, 136 | iMULLW, iADD, iLHZX, iXOR, iMFLR, iSTHX, iMR, iOR, iDIVWU, iMTLR, 137 | iMTCTR, iDIVW, iLFSX, iSRW, iSTFSX, iSRAW, iEXTSH, iEXTSB, iLWZ, iLBZ, 138 | iSTW, iSTWU, iSTB, iLHZ, iSTH, iLFS, iLFD, iSTFS, iSTFD, iLD, iFDIVS, 139 | iFSUBS, iFADDS, iFMULS, iSTD, iSTDU, iFRSP, iFCTIWZ, iFSUB, iFNEG, 140 | } powerpc_iname_t; 141 | 142 | #include 143 | 144 | typedef uint32_t ppc_instruction_t; 145 | 146 | extern ppc_instruction_t 147 | asm_instruction( powerpc_iname_t, const int, const long int * ); 148 | 149 | #define IN( inst, args... ) \ 150 | ({\ 151 | const long int argv[] = { args };\ 152 | const int argc = sizeof( argv ) / sizeof( argv[0] ); \ 153 | asm_instruction( inst, argc, argv );\ 154 | }) 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /gldraw.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "qbsp.h" 29 | 30 | // can't use the glvertex3fv functions, because the vec3_t fields 31 | // could be either floats or doubles, depending on DOUBLEVEC_T 32 | 33 | qboolean drawflag; 34 | vec3_t draw_mins, draw_maxs; 35 | 36 | 37 | #define WIN_SIZE 512 38 | 39 | void InitWindow (void) 40 | { 41 | auxInitDisplayMode (AUX_SINGLE | AUX_RGB); 42 | auxInitPosition (0, 0, WIN_SIZE, WIN_SIZE); 43 | auxInitWindow ("qcsg"); 44 | } 45 | 46 | void Draw_ClearWindow (void) 47 | { 48 | static int init; 49 | int w, h, g; 50 | vec_t mx, my; 51 | 52 | if (!drawflag) 53 | return; 54 | 55 | if (!init) 56 | { 57 | init = true; 58 | InitWindow (); 59 | } 60 | 61 | glClearColor (1,0.8,0.8,0); 62 | glClear (GL_COLOR_BUFFER_BIT); 63 | 64 | w = (draw_maxs[0] - draw_mins[0]); 65 | h = (draw_maxs[1] - draw_mins[1]); 66 | 67 | mx = draw_mins[0] + w/2; 68 | my = draw_mins[1] + h/2; 69 | 70 | g = w > h ? w : h; 71 | 72 | glLoadIdentity (); 73 | gluPerspective (90, 1, 2, 16384); 74 | gluLookAt (mx, my, draw_maxs[2] + g/2, mx , my, draw_maxs[2], 0, 1, 0); 75 | 76 | glColor3f (0,0,0); 77 | // glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 78 | glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 79 | glDisable (GL_DEPTH_TEST); 80 | glEnable (GL_BLEND); 81 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 82 | 83 | #if 0 84 | glColor4f (1,0,0,0.5); 85 | glBegin (GL_POLYGON); 86 | 87 | glVertex3f (0, 500, 0); 88 | glVertex3f (0, 900, 0); 89 | glVertex3f (0, 900, 100); 90 | glVertex3f (0, 500, 100); 91 | 92 | glEnd (); 93 | #endif 94 | 95 | glFlush (); 96 | 97 | } 98 | 99 | void Draw_SetRed (void) 100 | { 101 | if (!drawflag) 102 | return; 103 | 104 | glColor3f (1,0,0); 105 | } 106 | 107 | void Draw_SetGrey (void) 108 | { 109 | if (!drawflag) 110 | return; 111 | 112 | glColor3f (0.5,0.5,0.5); 113 | } 114 | 115 | void Draw_SetBlack (void) 116 | { 117 | if (!drawflag) 118 | return; 119 | 120 | glColor3f (0,0,0); 121 | } 122 | 123 | void DrawWinding (winding_t *w) 124 | { 125 | int i; 126 | 127 | if (!drawflag) 128 | return; 129 | 130 | glColor4f (0,0,0,0.5); 131 | glBegin (GL_LINE_LOOP); 132 | for (i=0 ; inumpoints ; i++) 133 | glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); 134 | glEnd (); 135 | 136 | glColor4f (0,1,0,0.3); 137 | glBegin (GL_POLYGON); 138 | for (i=0 ; inumpoints ; i++) 139 | glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); 140 | glEnd (); 141 | 142 | glFlush (); 143 | } 144 | 145 | void DrawAuxWinding (winding_t *w) 146 | { 147 | int i; 148 | 149 | if (!drawflag) 150 | return; 151 | 152 | glColor4f (0,0,0,0.5); 153 | glBegin (GL_LINE_LOOP); 154 | for (i=0 ; inumpoints ; i++) 155 | glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); 156 | glEnd (); 157 | 158 | glColor4f (1,0,0,0.3); 159 | glBegin (GL_POLYGON); 160 | for (i=0 ; inumpoints ; i++) 161 | glVertex3f (w->p[i][0],w->p[i][1],w->p[i][2] ); 162 | glEnd (); 163 | 164 | glFlush (); 165 | } 166 | 167 | //============================================================ 168 | 169 | #define GLSERV_PORT 25001 170 | 171 | qboolean wins_init; 172 | int draw_socket; 173 | 174 | void GLS_BeginScene (void) 175 | { 176 | WSADATA winsockdata; 177 | WORD wVersionRequested; 178 | struct sockaddr_in address; 179 | int r; 180 | 181 | if (!wins_init) 182 | { 183 | wins_init = true; 184 | 185 | wVersionRequested = MAKEWORD(1, 1); 186 | 187 | r = WSAStartup (MAKEWORD(1, 1), &winsockdata); 188 | 189 | if (r) 190 | Error ("Winsock initialization failed."); 191 | 192 | } 193 | 194 | // connect a socket to the server 195 | 196 | draw_socket = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); 197 | if (draw_socket == -1) 198 | Error ("draw_socket failed"); 199 | 200 | address.sin_family = AF_INET; 201 | address.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 202 | address.sin_port = GLSERV_PORT; 203 | r = connect (draw_socket, (struct sockaddr *)&address, sizeof(address)); 204 | if (r == -1) 205 | { 206 | closesocket (draw_socket); 207 | draw_socket = 0; 208 | } 209 | } 210 | 211 | void GLS_Winding (winding_t *w, int code) 212 | { 213 | byte buf[1024]; 214 | int i, j; 215 | 216 | if (!draw_socket) 217 | return; 218 | 219 | ((int *)buf)[0] = w->numpoints; 220 | ((int *)buf)[1] = code; 221 | for (i=0 ; inumpoints ; i++) 222 | for (j=0 ; j<3 ; j++) 223 | ((float *)buf)[2+i*3+j] = w->p[i][j]; 224 | 225 | send (draw_socket, buf, w->numpoints*12+8, 0); 226 | } 227 | 228 | void GLS_EndScene (void) 229 | { 230 | closesocket (draw_socket); 231 | draw_socket = 0; 232 | } 233 | -------------------------------------------------------------------------------- /deps/botlib/l_log.c: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Foobar; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | /***************************************************************************** 24 | * name: l_log.c 25 | * 26 | * desc: log file 27 | * 28 | * $Archive: /MissionPack/CODE/botlib/l_log.c $ 29 | * 30 | *****************************************************************************/ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "qcommon/q_shared.h" 37 | #include "botlib.h" 38 | #include "be_interface.h" //for botimport.Print 39 | #include "l_libvar.h" 40 | 41 | #define MAX_LOGFILENAMESIZE 1024 42 | 43 | typedef struct logfile_s 44 | { 45 | char filename[MAX_LOGFILENAMESIZE]; 46 | FILE *fp; 47 | int numwrites; 48 | } logfile_t; 49 | 50 | static logfile_t logfile; 51 | 52 | //=========================================================================== 53 | // 54 | // Parameter: - 55 | // Returns: - 56 | // Changes Globals: - 57 | //=========================================================================== 58 | void Log_Open(char *filename) 59 | { 60 | if (!LibVarValue("log", "0")) return; 61 | if (!filename || !strlen(filename)) 62 | { 63 | botimport.Print(PRT_MESSAGE, "openlog \n"); 64 | return; 65 | } //end if 66 | if (logfile.fp) 67 | { 68 | botimport.Print(PRT_ERROR, "log file %s is already opened\n", logfile.filename); 69 | return; 70 | } //end if 71 | logfile.fp = fopen(filename, "wb"); 72 | if (!logfile.fp) 73 | { 74 | botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename); 75 | return; 76 | } //end if 77 | strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE); 78 | botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename); 79 | } //end of the function Log_Create 80 | //=========================================================================== 81 | // 82 | // Parameter: - 83 | // Returns: - 84 | // Changes Globals: - 85 | //=========================================================================== 86 | void Log_Close(void) 87 | { 88 | if (!logfile.fp) return; 89 | if (fclose(logfile.fp)) 90 | { 91 | botimport.Print(PRT_ERROR, "can't close log file %s\n", logfile.filename); 92 | return; 93 | } //end if 94 | logfile.fp = NULL; 95 | botimport.Print(PRT_MESSAGE, "Closed log %s\n", logfile.filename); 96 | } //end of the function Log_Close 97 | //=========================================================================== 98 | // 99 | // Parameter: - 100 | // Returns: - 101 | // Changes Globals: - 102 | //=========================================================================== 103 | void Log_Shutdown(void) 104 | { 105 | if (logfile.fp) Log_Close(); 106 | } //end of the function Log_Shutdown 107 | //=========================================================================== 108 | // 109 | // Parameter: - 110 | // Returns: - 111 | // Changes Globals: - 112 | //=========================================================================== 113 | void QDECL Log_Write(char *fmt, ...) 114 | { 115 | va_list ap; 116 | 117 | if (!logfile.fp) return; 118 | va_start(ap, fmt); 119 | vfprintf(logfile.fp, fmt, ap); 120 | va_end(ap); 121 | //fprintf(logfile.fp, "\r\n"); 122 | fflush(logfile.fp); 123 | } //end of the function Log_Write 124 | //=========================================================================== 125 | // 126 | // Parameter: - 127 | // Returns: - 128 | // Changes Globals: - 129 | //=========================================================================== 130 | void QDECL Log_WriteTimeStamped(char *fmt, ...) 131 | { 132 | va_list ap; 133 | 134 | if (!logfile.fp) return; 135 | fprintf(logfile.fp, "%d %02d:%02d:%02d:%02d ", 136 | logfile.numwrites, 137 | (int) (botlibglobals.time / 60 / 60), 138 | (int) (botlibglobals.time / 60), 139 | (int) (botlibglobals.time), 140 | (int) ((int) (botlibglobals.time * 100)) - 141 | ((int) botlibglobals.time) * 100); 142 | va_start(ap, fmt); 143 | vfprintf(logfile.fp, fmt, ap); 144 | va_end(ap); 145 | fprintf(logfile.fp, "\r\n"); 146 | logfile.numwrites++; 147 | fflush(logfile.fp); 148 | } //end of the function Log_Write 149 | //=========================================================================== 150 | // 151 | // Parameter: - 152 | // Returns: - 153 | // Changes Globals: - 154 | //=========================================================================== 155 | FILE *Log_FilePointer(void) 156 | { 157 | return logfile.fp; 158 | } //end of the function Log_FilePointer 159 | //=========================================================================== 160 | // 161 | // Parameter: - 162 | // Returns: - 163 | // Changes Globals: - 164 | //=========================================================================== 165 | void Log_Flush(void) 166 | { 167 | if (logfile.fp) fflush(logfile.fp); 168 | } //end of the function Log_Flush 169 | 170 | -------------------------------------------------------------------------------- /deps/qcommon/cm_local.h: -------------------------------------------------------------------------------- 1 | /* 2 | =========================================================================== 3 | Copyright (C) 1999-2005 Id Software, Inc. 4 | 5 | This file is part of Quake III Arena source code. 6 | 7 | Quake III Arena source code is free software; you can redistribute it 8 | and/or modify it under the terms of the GNU General Public License as 9 | published by the Free Software Foundation; either version 2 of the License, 10 | or (at your option) any later version. 11 | 12 | Quake III Arena source code is distributed in the hope that it will be 13 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with Quake III Arena source code; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | =========================================================================== 21 | */ 22 | 23 | #include "q_shared.h" 24 | #include "qcommon.h" 25 | #include "cm_polylib.h" 26 | 27 | #define MAX_SUBMODELS 256 28 | #define BOX_MODEL_HANDLE 255 29 | #define CAPSULE_MODEL_HANDLE 254 30 | 31 | 32 | typedef struct { 33 | cplane_t *plane; 34 | int children[2]; // negative numbers are leafs 35 | } cNode_t; 36 | 37 | typedef struct { 38 | int cluster; 39 | int area; 40 | 41 | int firstLeafBrush; 42 | int numLeafBrushes; 43 | 44 | int firstLeafSurface; 45 | int numLeafSurfaces; 46 | } cLeaf_t; 47 | 48 | typedef struct cmodel_s { 49 | vec3_t mins, maxs; 50 | cLeaf_t leaf; // submodels don't reference the main tree 51 | } cmodel_t; 52 | 53 | typedef struct { 54 | cplane_t *plane; 55 | int surfaceFlags; 56 | int shaderNum; 57 | } cbrushside_t; 58 | 59 | typedef struct { 60 | int shaderNum; // the shader that determined the contents 61 | int contents; 62 | vec3_t bounds[2]; 63 | int numsides; 64 | cbrushside_t *sides; 65 | int checkcount; // to avoid repeated testings 66 | } cbrush_t; 67 | 68 | 69 | typedef struct { 70 | int checkcount; // to avoid repeated testings 71 | int surfaceFlags; 72 | int contents; 73 | struct patchCollide_s *pc; 74 | } cPatch_t; 75 | 76 | 77 | typedef struct { 78 | int floodnum; 79 | int floodvalid; 80 | } cArea_t; 81 | 82 | typedef struct { 83 | char name[MAX_QPATH]; 84 | 85 | int numShaders; 86 | dshader_t *shaders; 87 | 88 | int numBrushSides; 89 | cbrushside_t *brushsides; 90 | 91 | int numPlanes; 92 | cplane_t *planes; 93 | 94 | int numNodes; 95 | cNode_t *nodes; 96 | 97 | int numLeafs; 98 | cLeaf_t *leafs; 99 | 100 | int numLeafBrushes; 101 | int *leafbrushes; 102 | 103 | int numLeafSurfaces; 104 | int *leafsurfaces; 105 | 106 | int numSubModels; 107 | cmodel_t *cmodels; 108 | 109 | int numBrushes; 110 | cbrush_t *brushes; 111 | 112 | int numClusters; 113 | int clusterBytes; 114 | byte *visibility; 115 | qboolean vised; // if false, visibility is just a single cluster of ffs 116 | 117 | int numEntityChars; 118 | char *entityString; 119 | 120 | int numAreas; 121 | cArea_t *areas; 122 | int *areaPortals; // [ numAreas*numAreas ] reference counts 123 | 124 | int numSurfaces; 125 | cPatch_t **surfaces; // non-patches will be NULL 126 | 127 | int floodvalid; 128 | int checkcount; // incremented on each trace 129 | } clipMap_t; 130 | 131 | 132 | // keep 1/8 unit away to keep the position valid before network snapping 133 | // and to avoid various numeric issues 134 | #define SURFACE_CLIP_EPSILON (0.125) 135 | 136 | extern clipMap_t cm; 137 | extern int c_pointcontents; 138 | extern int c_traces, c_brush_traces, c_patch_traces; 139 | extern cvar_t *cm_noAreas; 140 | extern cvar_t *cm_noCurves; 141 | extern cvar_t *cm_playerCurveClip; 142 | 143 | // cm_test.c 144 | 145 | // Used for oriented capsule collision detection 146 | typedef struct 147 | { 148 | qboolean use; 149 | float radius; 150 | float halfheight; 151 | vec3_t offset; 152 | } sphere_t; 153 | 154 | typedef struct { 155 | vec3_t start; 156 | vec3_t end; 157 | vec3_t size[2]; // size of the box being swept through the model 158 | vec3_t offsets[8]; // [signbits][x] = either size[0][x] or size[1][x] 159 | float maxOffset; // longest corner length from origin 160 | vec3_t extents; // greatest of abs(size[0]) and abs(size[1]) 161 | vec3_t bounds[2]; // enclosing box of start and end surrounding by size 162 | vec3_t modelOrigin;// origin of the model tracing through 163 | int contents; // ored contents of the model tracing through 164 | qboolean isPoint; // optimized case 165 | trace_t trace; // returned from trace call 166 | sphere_t sphere; // sphere for oriendted capsule collision 167 | } traceWork_t; 168 | 169 | typedef struct leafList_s { 170 | int count; 171 | int maxcount; 172 | qboolean overflowed; 173 | int *list; 174 | vec3_t bounds[2]; 175 | int lastLeaf; // for overflows where each leaf can't be stored individually 176 | void (*storeLeafs)( struct leafList_s *ll, int nodenum ); 177 | } leafList_t; 178 | 179 | 180 | int CM_BoxBrushes( const vec3_t mins, const vec3_t maxs, cbrush_t **list, int listsize ); 181 | 182 | void CM_StoreLeafs( leafList_t *ll, int nodenum ); 183 | void CM_StoreBrushes( leafList_t *ll, int nodenum ); 184 | 185 | void CM_BoxLeafnums_r( leafList_t *ll, int nodenum ); 186 | 187 | cmodel_t *CM_ClipHandleToModel( clipHandle_t handle ); 188 | qboolean CM_BoundsIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 ); 189 | qboolean CM_BoundsIntersectPoint( const vec3_t mins, const vec3_t maxs, const vec3_t point ); 190 | 191 | // cm_patch.c 192 | 193 | struct patchCollide_s *CM_GeneratePatchCollide( int width, int height, vec3_t *points ); 194 | void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ); 195 | qboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ); 196 | void CM_ClearLevelPatches( void ); 197 | --------------------------------------------------------------------------------