Full Code of id-Software/Quake-III-Arena for AI

master dbe4ddb10315 cached
1370 files
18.4 MB
4.9M tokens
1 requests
Copy disabled (too large) Download .txt
Showing preview only (19,486K chars total). Download the full file to get everything.
Repository: id-Software/Quake-III-Arena
Branch: master
Commit: dbe4ddb10315
Files: 1370
Total size: 18.4 MB

Directory structure:
gitextract_s_acjfki/

├── COPYING.txt
├── README.txt
├── code/
│   ├── Construct
│   ├── Makefile
│   ├── botlib/
│   │   ├── aasfile.h
│   │   ├── be_aas_bsp.h
│   │   ├── be_aas_bspq3.c
│   │   ├── be_aas_cluster.c
│   │   ├── be_aas_cluster.h
│   │   ├── be_aas_debug.c
│   │   ├── be_aas_debug.h
│   │   ├── be_aas_def.h
│   │   ├── be_aas_entity.c
│   │   ├── be_aas_entity.h
│   │   ├── be_aas_file.c
│   │   ├── be_aas_file.h
│   │   ├── be_aas_funcs.h
│   │   ├── be_aas_main.c
│   │   ├── be_aas_main.h
│   │   ├── be_aas_move.c
│   │   ├── be_aas_move.h
│   │   ├── be_aas_optimize.c
│   │   ├── be_aas_optimize.h
│   │   ├── be_aas_reach.c
│   │   ├── be_aas_reach.h
│   │   ├── be_aas_route.c
│   │   ├── be_aas_route.h
│   │   ├── be_aas_routealt.c
│   │   ├── be_aas_routealt.h
│   │   ├── be_aas_sample.c
│   │   ├── be_aas_sample.h
│   │   ├── be_ai_char.c
│   │   ├── be_ai_chat.c
│   │   ├── be_ai_gen.c
│   │   ├── be_ai_goal.c
│   │   ├── be_ai_move.c
│   │   ├── be_ai_weap.c
│   │   ├── be_ai_weight.c
│   │   ├── be_ai_weight.h
│   │   ├── be_ea.c
│   │   ├── be_interface.c
│   │   ├── be_interface.h
│   │   ├── botlib.vcproj
│   │   ├── l_crc.c
│   │   ├── l_crc.h
│   │   ├── l_libvar.c
│   │   ├── l_libvar.h
│   │   ├── l_log.c
│   │   ├── l_log.h
│   │   ├── l_memory.c
│   │   ├── l_memory.h
│   │   ├── l_precomp.c
│   │   ├── l_precomp.h
│   │   ├── l_script.c
│   │   ├── l_script.h
│   │   ├── l_struct.c
│   │   ├── l_struct.h
│   │   ├── l_utils.h
│   │   ├── lcc.mak
│   │   └── linux-i386.mak
│   ├── bspc/
│   │   ├── Conscript
│   │   ├── Makefile
│   │   ├── _files.c
│   │   ├── aas_areamerging.c
│   │   ├── aas_areamerging.h
│   │   ├── aas_cfg.c
│   │   ├── aas_cfg.h
│   │   ├── aas_create.c
│   │   ├── aas_create.h
│   │   ├── aas_edgemelting.c
│   │   ├── aas_edgemelting.h
│   │   ├── aas_facemerging.c
│   │   ├── aas_facemerging.h
│   │   ├── aas_file.c
│   │   ├── aas_file.h
│   │   ├── aas_gsubdiv.c
│   │   ├── aas_gsubdiv.h
│   │   ├── aas_map.c
│   │   ├── aas_map.h
│   │   ├── aas_prunenodes.c
│   │   ├── aas_prunenodes.h
│   │   ├── aas_store.c
│   │   ├── aas_store.h
│   │   ├── aasfile.h
│   │   ├── be_aas_bspc.c
│   │   ├── be_aas_bspc.h
│   │   ├── brushbsp.c
│   │   ├── bspc.c
│   │   ├── bspc.sln
│   │   ├── bspc.vcproj
│   │   ├── cfgq3.c
│   │   ├── csg.c
│   │   ├── faces.c
│   │   ├── gldraw.c
│   │   ├── glfile.c
│   │   ├── l_bsp_ent.c
│   │   ├── l_bsp_ent.h
│   │   ├── l_bsp_hl.c
│   │   ├── l_bsp_hl.h
│   │   ├── l_bsp_q1.c
│   │   ├── l_bsp_q1.h
│   │   ├── l_bsp_q2.c
│   │   ├── l_bsp_q2.h
│   │   ├── l_bsp_q3.c
│   │   ├── l_bsp_q3.h
│   │   ├── l_bsp_sin.c
│   │   ├── l_bsp_sin.h
│   │   ├── l_cmd.c
│   │   ├── l_cmd.h
│   │   ├── l_log.c
│   │   ├── l_log.h
│   │   ├── l_math.c
│   │   ├── l_math.h
│   │   ├── l_mem.c
│   │   ├── l_mem.h
│   │   ├── l_poly.c
│   │   ├── l_poly.h
│   │   ├── l_qfiles.c
│   │   ├── l_qfiles.h
│   │   ├── l_threads.c
│   │   ├── l_threads.h
│   │   ├── l_utils.c
│   │   ├── l_utils.h
│   │   ├── lcc.mak
│   │   ├── leakfile.c
│   │   ├── linux-i386.mak
│   │   ├── map.c
│   │   ├── map_hl.c
│   │   ├── map_q1.c
│   │   ├── map_q2.c
│   │   ├── map_q3.c
│   │   ├── map_sin.c
│   │   ├── nodraw.c
│   │   ├── portals.c
│   │   ├── prtfile.c
│   │   ├── q2files.h
│   │   ├── q3files.h
│   │   ├── qbsp.h
│   │   ├── qfiles.h
│   │   ├── sinfiles.h
│   │   ├── tetrahedron.c
│   │   ├── tetrahedron.h
│   │   ├── textures.c
│   │   ├── tree.c
│   │   └── writebsp.c
│   ├── cgame/
│   │   ├── Conscript
│   │   ├── cg_consolecmds.c
│   │   ├── cg_draw.c
│   │   ├── cg_drawtools.c
│   │   ├── cg_effects.c
│   │   ├── cg_ents.c
│   │   ├── cg_event.c
│   │   ├── cg_info.c
│   │   ├── cg_local.h
│   │   ├── cg_localents.c
│   │   ├── cg_main.c
│   │   ├── cg_marks.c
│   │   ├── cg_newdraw.c
│   │   ├── cg_particles.c
│   │   ├── cg_players.c
│   │   ├── cg_playerstate.c
│   │   ├── cg_predict.c
│   │   ├── cg_public.h
│   │   ├── cg_scoreboard.c
│   │   ├── cg_servercmds.c
│   │   ├── cg_snapshot.c
│   │   ├── cg_syscalls.asm
│   │   ├── cg_syscalls.c
│   │   ├── cg_view.c
│   │   ├── cg_weapons.c
│   │   ├── cgame.bat
│   │   ├── cgame.def
│   │   ├── cgame.plg
│   │   ├── cgame.q3asm
│   │   ├── cgame.sh
│   │   ├── cgame.vcproj
│   │   ├── cgame_ta.bat
│   │   ├── cgame_ta.q3asm
│   │   ├── cgame_ta.sh
│   │   └── tr_types.h
│   ├── cgame.lnt
│   ├── clean.bat
│   ├── client/
│   │   ├── cl_cgame.c
│   │   ├── cl_cin.c
│   │   ├── cl_console.c
│   │   ├── cl_input.c
│   │   ├── cl_keys.c
│   │   ├── cl_main.c
│   │   ├── cl_net_chan.c
│   │   ├── cl_parse.c
│   │   ├── cl_scrn.c
│   │   ├── cl_ui.c
│   │   ├── client.h
│   │   ├── keys.h
│   │   ├── snd_adpcm.c
│   │   ├── snd_dma.c
│   │   ├── snd_local.h
│   │   ├── snd_mem.c
│   │   ├── snd_mix.c
│   │   ├── snd_public.h
│   │   └── snd_wavelet.c
│   ├── game/
│   │   ├── Conscript
│   │   ├── ai_chat.c
│   │   ├── ai_chat.h
│   │   ├── ai_cmd.c
│   │   ├── ai_cmd.h
│   │   ├── ai_dmnet.c
│   │   ├── ai_dmnet.h
│   │   ├── ai_dmq3.c
│   │   ├── ai_dmq3.h
│   │   ├── ai_main.c
│   │   ├── ai_main.h
│   │   ├── ai_team.c
│   │   ├── ai_team.h
│   │   ├── ai_vcmd.c
│   │   ├── ai_vcmd.h
│   │   ├── be_aas.h
│   │   ├── be_ai_char.h
│   │   ├── be_ai_chat.h
│   │   ├── be_ai_gen.h
│   │   ├── be_ai_goal.h
│   │   ├── be_ai_move.h
│   │   ├── be_ai_weap.h
│   │   ├── be_ea.h
│   │   ├── bg_lib.c
│   │   ├── bg_lib.h
│   │   ├── bg_local.h
│   │   ├── bg_misc.c
│   │   ├── bg_pmove.c
│   │   ├── bg_public.h
│   │   ├── bg_slidemove.c
│   │   ├── botlib.h
│   │   ├── chars.h
│   │   ├── g_active.c
│   │   ├── g_arenas.c
│   │   ├── g_bot.c
│   │   ├── g_client.c
│   │   ├── g_cmds.c
│   │   ├── g_combat.c
│   │   ├── g_items.c
│   │   ├── g_local.h
│   │   ├── g_main.c
│   │   ├── g_mem.c
│   │   ├── g_misc.c
│   │   ├── g_missile.c
│   │   ├── g_mover.c
│   │   ├── g_public.h
│   │   ├── g_rankings.c
│   │   ├── g_rankings.h
│   │   ├── g_session.c
│   │   ├── g_spawn.c
│   │   ├── g_svcmds.c
│   │   ├── g_syscalls.asm
│   │   ├── g_syscalls.c
│   │   ├── g_target.c
│   │   ├── g_team.c
│   │   ├── g_team.h
│   │   ├── g_trigger.c
│   │   ├── g_utils.c
│   │   ├── g_weapon.c
│   │   ├── game.bat
│   │   ├── game.def
│   │   ├── game.q3asm
│   │   ├── game.sh
│   │   ├── game.vcproj
│   │   ├── game_ta.bat
│   │   ├── game_ta.q3asm
│   │   ├── game_ta.sh
│   │   ├── inv.h
│   │   ├── match.h
│   │   ├── q_math.c
│   │   ├── q_shared.c
│   │   ├── q_shared.h
│   │   ├── surfaceflags.h
│   │   └── syn.h
│   ├── game.lnt
│   ├── installdebug.bat
│   ├── installrelease.bat
│   ├── installvms.bat
│   ├── jpeg-6/
│   │   ├── README
│   │   ├── jcapimin.c
│   │   ├── jcapistd.c
│   │   ├── jccoefct.c
│   │   ├── jccolor.c
│   │   ├── jcdctmgr.c
│   │   ├── jchuff.c
│   │   ├── jchuff.h
│   │   ├── jcinit.c
│   │   ├── jcmainct.c
│   │   ├── jcmarker.c
│   │   ├── jcmaster.c
│   │   ├── jcomapi.c
│   │   ├── jconfig.h
│   │   ├── jcparam.c
│   │   ├── jcphuff.c
│   │   ├── jcprepct.c
│   │   ├── jcsample.c
│   │   ├── jctrans.c
│   │   ├── jdapimin.c
│   │   ├── jdapistd.c
│   │   ├── jdatadst.c
│   │   ├── jdatasrc.c
│   │   ├── jdcoefct.c
│   │   ├── jdcolor.c
│   │   ├── jdct.h
│   │   ├── jddctmgr.c
│   │   ├── jdhuff.c
│   │   ├── jdhuff.h
│   │   ├── jdinput.c
│   │   ├── jdmainct.c
│   │   ├── jdmarker.c
│   │   ├── jdmaster.c
│   │   ├── jdmerge.c
│   │   ├── jdphuff.c
│   │   ├── jdpostct.c
│   │   ├── jdsample.c
│   │   ├── jdtrans.c
│   │   ├── jerror.c
│   │   ├── jerror.h
│   │   ├── jfdctflt.c
│   │   ├── jfdctfst.c
│   │   ├── jfdctint.c
│   │   ├── jidctflt.c
│   │   ├── jidctfst.c
│   │   ├── jidctint.c
│   │   ├── jidctred.c
│   │   ├── jinclude.h
│   │   ├── jload.c
│   │   ├── jmemansi.c
│   │   ├── jmemdos.c
│   │   ├── jmemmgr.c
│   │   ├── jmemname.c
│   │   ├── jmemnobs.c
│   │   ├── jmemsys.h
│   │   ├── jmorecfg.h
│   │   ├── jpegint.h
│   │   ├── jpeglib.h
│   │   ├── jpegtran.c
│   │   ├── jquant1.c
│   │   ├── jquant2.c
│   │   ├── jutils.c
│   │   └── jversion.h
│   ├── macosx/
│   │   ├── BuildRelease
│   │   ├── CGMouseDeltaFix.h
│   │   ├── CGMouseDeltaFix.m
│   │   ├── CGPrivateAPI.h
│   │   ├── GenerateQGL.pl
│   │   ├── Performance.rtf
│   │   ├── Q3Controller.h
│   │   ├── Q3Controller.m
│   │   ├── Quake3.icns
│   │   ├── Quake3.nib/
│   │   │   ├── classes.nib
│   │   │   ├── info.nib
│   │   │   └── objects.nib
│   │   ├── Quake3.pbproj/
│   │   │   ├── apple.pbxuser
│   │   │   └── project.pbxproj
│   │   ├── RecordDemo.zsh
│   │   ├── botlib.log
│   │   ├── macosx_display.h
│   │   ├── macosx_display.m
│   │   ├── macosx_glimp.h
│   │   ├── macosx_glimp.m
│   │   ├── macosx_glsmp_mutex.m
│   │   ├── macosx_glsmp_null.m
│   │   ├── macosx_glsmp_ports.m
│   │   ├── macosx_input.m
│   │   ├── macosx_local.h
│   │   ├── macosx_qgl.h
│   │   ├── macosx_sndcore.m
│   │   ├── macosx_snddma.m
│   │   ├── macosx_sys.m
│   │   ├── macosx_timers.h
│   │   ├── macosx_timers.m
│   │   └── timedemo.zsh
│   ├── null/
│   │   ├── mac_net.c
│   │   ├── null_client.c
│   │   ├── null_glimp.c
│   │   ├── null_input.c
│   │   ├── null_main.c
│   │   ├── null_net.c
│   │   └── null_snddma.c
│   ├── opts.lnt
│   ├── q3_ui/
│   │   ├── Conscript
│   │   ├── compile.bat
│   │   ├── keycodes.h
│   │   ├── q3_ui.bat
│   │   ├── q3_ui.q3asm
│   │   ├── q3_ui.sh
│   │   ├── q3_ui.vcproj
│   │   ├── ui.def
│   │   ├── ui.q3asm
│   │   ├── ui_addbots.c
│   │   ├── ui_atoms.c
│   │   ├── ui_cdkey.c
│   │   ├── ui_cinematics.c
│   │   ├── ui_confirm.c
│   │   ├── ui_connect.c
│   │   ├── ui_controls2.c
│   │   ├── ui_credits.c
│   │   ├── ui_demo2.c
│   │   ├── ui_display.c
│   │   ├── ui_gameinfo.c
│   │   ├── ui_ingame.c
│   │   ├── ui_loadconfig.c
│   │   ├── ui_local.h
│   │   ├── ui_login.c
│   │   ├── ui_main.c
│   │   ├── ui_menu.c
│   │   ├── ui_mfield.c
│   │   ├── ui_mods.c
│   │   ├── ui_network.c
│   │   ├── ui_options.c
│   │   ├── ui_playermodel.c
│   │   ├── ui_players.c
│   │   ├── ui_playersettings.c
│   │   ├── ui_preferences.c
│   │   ├── ui_qmenu.c
│   │   ├── ui_rankings.c
│   │   ├── ui_rankstatus.c
│   │   ├── ui_removebots.c
│   │   ├── ui_saveconfig.c
│   │   ├── ui_serverinfo.c
│   │   ├── ui_servers2.c
│   │   ├── ui_setup.c
│   │   ├── ui_signup.c
│   │   ├── ui_sound.c
│   │   ├── ui_sparena.c
│   │   ├── ui_specifyleague.c
│   │   ├── ui_specifyserver.c
│   │   ├── ui_splevel.c
│   │   ├── ui_sppostgame.c
│   │   ├── ui_spreset.c
│   │   ├── ui_spskill.c
│   │   ├── ui_startserver.c
│   │   ├── ui_team.c
│   │   ├── ui_teamorders.c
│   │   └── ui_video.c
│   ├── qcommon/
│   │   ├── cm_load.c
│   │   ├── cm_local.h
│   │   ├── cm_patch.c
│   │   ├── cm_patch.h
│   │   ├── cm_polylib.c
│   │   ├── cm_polylib.h
│   │   ├── cm_public.h
│   │   ├── cm_test.c
│   │   ├── cm_trace.c
│   │   ├── cmd.c
│   │   ├── cmd.c.save
│   │   ├── common.c
│   │   ├── cvar.c
│   │   ├── files.c
│   │   ├── huffman.c
│   │   ├── md4.c
│   │   ├── msg.c
│   │   ├── net_chan.c
│   │   ├── qcommon.h
│   │   ├── qfiles.h
│   │   ├── unzip.c
│   │   ├── unzip.h
│   │   ├── vm.c
│   │   ├── vm_interpreted.c
│   │   ├── vm_local.h
│   │   ├── vm_ppc.c
│   │   ├── vm_ppc_new.c
│   │   └── vm_x86.c
│   ├── quake3.sln
│   ├── quake3.vcproj
│   ├── renderer/
│   │   ├── qgl.h
│   │   ├── qgl_linked.h
│   │   ├── ref_trin.def
│   │   ├── renderer.vcproj
│   │   ├── tr_animation.c
│   │   ├── tr_backend.c
│   │   ├── tr_bsp.c
│   │   ├── tr_cmds.c
│   │   ├── tr_curve.c
│   │   ├── tr_flares.c
│   │   ├── tr_font.c
│   │   ├── tr_image.c
│   │   ├── tr_init.c
│   │   ├── tr_light.c
│   │   ├── tr_local.h
│   │   ├── tr_main.c
│   │   ├── tr_marks.c
│   │   ├── tr_mesh.c
│   │   ├── tr_model.c
│   │   ├── tr_noise.c
│   │   ├── tr_public.h
│   │   ├── tr_scene.c
│   │   ├── tr_shade.c
│   │   ├── tr_shade_calc.c
│   │   ├── tr_shader.c
│   │   ├── tr_shadows.c
│   │   ├── tr_sky.c
│   │   ├── tr_surface.c
│   │   └── tr_world.c
│   ├── renderer.lnt
│   ├── run.bat
│   ├── runrelease.bat
│   ├── server/
│   │   ├── server.h
│   │   ├── sv_bot.c
│   │   ├── sv_ccmds.c
│   │   ├── sv_client.c
│   │   ├── sv_game.c
│   │   ├── sv_init.c
│   │   ├── sv_main.c
│   │   ├── sv_net_chan.c
│   │   ├── sv_rankings.c
│   │   ├── sv_snapshot.c
│   │   └── sv_world.c
│   ├── splines/
│   │   ├── Splines.vcproj
│   │   ├── math_angles.cpp
│   │   ├── math_angles.h
│   │   ├── math_matrix.cpp
│   │   ├── math_matrix.h
│   │   ├── math_quaternion.cpp
│   │   ├── math_quaternion.h
│   │   ├── math_vector.cpp
│   │   ├── math_vector.h
│   │   ├── q_parse.cpp
│   │   ├── q_shared.cpp
│   │   ├── q_shared.h
│   │   ├── q_shared.hpp
│   │   ├── splines.cpp
│   │   ├── splines.h
│   │   ├── util_list.h
│   │   ├── util_str.cpp
│   │   └── util_str.h
│   ├── ui/
│   │   ├── Conscript
│   │   ├── compile.bat
│   │   ├── keycodes.h
│   │   ├── ui.bat
│   │   ├── ui.def
│   │   ├── ui.q3asm
│   │   ├── ui.vcproj
│   │   ├── ui_atoms.c
│   │   ├── ui_gameinfo.c
│   │   ├── ui_local.h
│   │   ├── ui_main.c
│   │   ├── ui_players.c
│   │   ├── ui_public.h
│   │   ├── ui_shared.c
│   │   ├── ui_shared.h
│   │   ├── ui_syscalls.asm
│   │   ├── ui_syscalls.c
│   │   └── ui_util.c
│   ├── unix/
│   │   ├── ChangeLog
│   │   ├── Cons_gcc.pm
│   │   ├── Conscript-client
│   │   ├── Conscript-dedicated
│   │   ├── Conscript-pk3
│   │   ├── Conscript-sdk
│   │   ├── Conscript-setup
│   │   ├── LinuxSupport/
│   │   │   ├── CHANGES-1.32.txt
│   │   │   ├── INSTALL
│   │   │   ├── index.html
│   │   │   ├── udp_wide_README.txt
│   │   │   └── udp_wide_broadcast.patch
│   │   ├── Makefile
│   │   ├── Makefile.Game
│   │   ├── Quake3.kdelnk
│   │   ├── README.EULA
│   │   ├── README.Linux
│   │   ├── README.Q3Test
│   │   ├── build_setup.sh
│   │   ├── cons
│   │   ├── extract_ver.pl
│   │   ├── ftol.nasm
│   │   ├── linux_common.c
│   │   ├── linux_glimp.c
│   │   ├── linux_joystick.c
│   │   ├── linux_local.h
│   │   ├── linux_qgl.c
│   │   ├── linux_signals.c
│   │   ├── linux_snd.c
│   │   ├── matha.s
│   │   ├── pcons-2.3.1
│   │   ├── q3test.spec.sh
│   │   ├── qasm.h
│   │   ├── quake3.xpm
│   │   ├── run-target.sh
│   │   ├── snapvector.nasm
│   │   ├── snd_mixa.s
│   │   ├── sys_dosa.s
│   │   ├── unix_glw.h
│   │   ├── unix_main.c
│   │   ├── unix_net.c
│   │   ├── unix_shared.c
│   │   ├── vm_x86.c
│   │   └── vm_x86a.s
│   └── win32/
│       ├── glw_win.h
│       ├── mod-sdk-setup/
│       │   ├── GameSource.VCT
│       │   └── QIIIA Game Source License.doc
│       ├── resource.h
│       ├── win_gamma.c
│       ├── win_glimp.c
│       ├── win_input.c
│       ├── win_local.h
│       ├── win_main.c
│       ├── win_net.c
│       ├── win_qgl.c
│       ├── win_shared.c
│       ├── win_snd.c
│       ├── win_syscon.c
│       ├── win_wndproc.c
│       └── winquake.rc
├── common/
│   ├── aselib.c
│   ├── aselib.h
│   ├── bspfile.c
│   ├── bspfile.h
│   ├── cmdlib.c
│   ├── cmdlib.h
│   ├── imagelib.c
│   ├── imagelib.h
│   ├── l3dslib.c
│   ├── l3dslib.h
│   ├── mathlib.c
│   ├── mathlib.h
│   ├── md4.c
│   ├── mutex.c
│   ├── mutex.h
│   ├── polylib.c
│   ├── polylib.h
│   ├── polyset.h
│   ├── qfiles.h
│   ├── scriplib.c
│   ├── scriplib.h
│   ├── surfaceflags.h
│   ├── threads.c
│   ├── threads.h
│   ├── trilib.c
│   └── trilib.h
├── lcc/
│   ├── COPYRIGHT
│   ├── LOG
│   ├── README
│   ├── README.id
│   ├── alpha/
│   │   └── osf/
│   │       └── tst/
│   │           ├── 8q.1bk
│   │           ├── 8q.2bk
│   │           ├── 8q.sbk
│   │           ├── array.1bk
│   │           ├── array.2bk
│   │           ├── array.sbk
│   │           ├── cf.1bk
│   │           ├── cf.2bk
│   │           ├── cf.sbk
│   │           ├── cq.1bk
│   │           ├── cq.2bk
│   │           ├── cq.sbk
│   │           ├── cvt.1bk
│   │           ├── cvt.2bk
│   │           ├── cvt.sbk
│   │           ├── fields.1bk
│   │           ├── fields.2bk
│   │           ├── fields.sbk
│   │           ├── front.2bk
│   │           ├── front.sbk
│   │           ├── incr.1bk
│   │           ├── incr.2bk
│   │           ├── incr.sbk
│   │           ├── init.1bk
│   │           ├── init.2bk
│   │           ├── init.sbk
│   │           ├── limits.1bk
│   │           ├── limits.2bk
│   │           ├── limits.sbk
│   │           ├── paranoia.1bk
│   │           ├── paranoia.2bk
│   │           ├── paranoia.sbk
│   │           ├── sort.1bk
│   │           ├── sort.2bk
│   │           ├── sort.sbk
│   │           ├── spill.1bk
│   │           ├── spill.2bk
│   │           ├── spill.sbk
│   │           ├── stdarg.1bk
│   │           ├── stdarg.2bk
│   │           ├── stdarg.sbk
│   │           ├── struct.1bk
│   │           ├── struct.2bk
│   │           ├── struct.sbk
│   │           ├── switch.1bk
│   │           ├── switch.2bk
│   │           ├── switch.sbk
│   │           ├── wf1.1bk
│   │           ├── wf1.2bk
│   │           ├── wf1.sbk
│   │           ├── yacc.1bk
│   │           ├── yacc.2bk
│   │           └── yacc.sbk
│   ├── buildnt.bat
│   ├── buildnt.sh
│   ├── cpp/
│   │   ├── cpp.c
│   │   ├── cpp.h
│   │   ├── eval.c
│   │   ├── getopt.c
│   │   ├── hideset.c
│   │   ├── include.c
│   │   ├── lex.c
│   │   ├── macro.c
│   │   ├── nlist.c
│   │   ├── tokens.c
│   │   └── unix.c
│   ├── custom.mk
│   ├── doc/
│   │   ├── 4.html
│   │   ├── bprint.1
│   │   ├── install.html
│   │   └── lcc.1
│   ├── etc/
│   │   ├── bprint.c
│   │   ├── gcc-solaris.c
│   │   ├── irix.c
│   │   ├── lcc.c
│   │   ├── linux.c
│   │   ├── ops.c
│   │   ├── osf.c
│   │   ├── solaris.c
│   │   └── win32.c
│   ├── include/
│   │   ├── alpha/
│   │   │   └── osf/
│   │   │       ├── assert.h
│   │   │       ├── ctype.h
│   │   │       ├── errno.h
│   │   │       ├── float.h
│   │   │       ├── limits.h
│   │   │       ├── locale.h
│   │   │       ├── math.h
│   │   │       ├── setjmp.h
│   │   │       ├── signal.h
│   │   │       ├── stdarg.h
│   │   │       ├── stddef.h
│   │   │       ├── stdio.h
│   │   │       ├── stdlib.h
│   │   │       ├── string.h
│   │   │       └── time.h
│   │   ├── mips/
│   │   │   └── irix/
│   │   │       ├── assert.h
│   │   │       ├── ctype.h
│   │   │       ├── errno.h
│   │   │       ├── float.h
│   │   │       ├── limits.h
│   │   │       ├── locale.h
│   │   │       ├── math.h
│   │   │       ├── setjmp.h
│   │   │       ├── signal.h
│   │   │       ├── stdarg.h
│   │   │       ├── stddef.h
│   │   │       ├── stdio.h
│   │   │       ├── stdlib.h
│   │   │       ├── string.h
│   │   │       └── time.h
│   │   ├── sparc/
│   │   │   └── solaris/
│   │   │       ├── assert.h
│   │   │       ├── ctype.h
│   │   │       ├── errno.h
│   │   │       ├── float.h
│   │   │       ├── limits.h
│   │   │       ├── locale.h
│   │   │       ├── math.h
│   │   │       ├── setjmp.h
│   │   │       ├── signal.h
│   │   │       ├── stdarg.h
│   │   │       ├── stddef.h
│   │   │       ├── stdio.h
│   │   │       ├── stdlib.h
│   │   │       ├── string.h
│   │   │       └── time.h
│   │   └── x86/
│   │       └── linux/
│   │           ├── assert.h
│   │           ├── float.h
│   │           └── stdarg.h
│   ├── lburg/
│   │   ├── gram.c
│   │   ├── gram.y
│   │   ├── lburg.1
│   │   ├── lburg.c
│   │   └── lburg.h
│   ├── lib/
│   │   ├── assert.c
│   │   ├── bbexit.c
│   │   └── yynull.c
│   ├── makefile
│   ├── makefile.nt
│   ├── mips/
│   │   └── irix/
│   │       └── tst/
│   │           ├── 8q.1bk
│   │           ├── 8q.2bk
│   │           ├── 8q.sbk
│   │           ├── array.1bk
│   │           ├── array.2bk
│   │           ├── array.sbk
│   │           ├── cf.1bk
│   │           ├── cf.2bk
│   │           ├── cf.sbk
│   │           ├── cq.1bk
│   │           ├── cq.2bk
│   │           ├── cq.sbk
│   │           ├── cvt.1bk
│   │           ├── cvt.2bk
│   │           ├── cvt.sbk
│   │           ├── fields.1bk
│   │           ├── fields.2bk
│   │           ├── fields.sbk
│   │           ├── front.2bk
│   │           ├── front.sbk
│   │           ├── incr.2bk
│   │           ├── incr.sbk
│   │           ├── init.1bk
│   │           ├── init.2bk
│   │           ├── init.sbk
│   │           ├── limits.1bk
│   │           ├── limits.2bk
│   │           ├── limits.sbk
│   │           ├── paranoia.1bk
│   │           ├── paranoia.2bk
│   │           ├── paranoia.sbk
│   │           ├── sort.1bk
│   │           ├── sort.2bk
│   │           ├── sort.sbk
│   │           ├── spill.2bk
│   │           ├── spill.sbk
│   │           ├── stdarg.1bk
│   │           ├── stdarg.2bk
│   │           ├── stdarg.sbk
│   │           ├── struct.1bk
│   │           ├── struct.2bk
│   │           ├── struct.sbk
│   │           ├── switch.1bk
│   │           ├── switch.2bk
│   │           ├── switch.sbk
│   │           ├── wf1.1bk
│   │           ├── wf1.2bk
│   │           ├── wf1.sbk
│   │           ├── yacc.1bk
│   │           ├── yacc.2bk
│   │           └── yacc.sbk
│   ├── msdev/
│   │   ├── rcc.dsp
│   │   └── rcc.dsw
│   ├── packing.lst
│   ├── sparc/
│   │   └── solaris/
│   │       └── tst/
│   │           ├── 8q.1bk
│   │           ├── 8q.2bk
│   │           ├── 8q.sbk
│   │           ├── array.1bk
│   │           ├── array.2bk
│   │           ├── array.sbk
│   │           ├── cf.1bk
│   │           ├── cf.2bk
│   │           ├── cf.sbk
│   │           ├── cq.1bk
│   │           ├── cq.2bk
│   │           ├── cq.sbk
│   │           ├── cvt.1bk
│   │           ├── cvt.2bk
│   │           ├── cvt.sbk
│   │           ├── fields.1bk
│   │           ├── fields.2bk
│   │           ├── fields.sbk
│   │           ├── front.2bk
│   │           ├── front.sbk
│   │           ├── incr.1bk
│   │           ├── incr.2bk
│   │           ├── incr.sbk
│   │           ├── init.1bk
│   │           ├── init.2bk
│   │           ├── init.sbk
│   │           ├── limits.1bk
│   │           ├── limits.2bk
│   │           ├── limits.sbk
│   │           ├── paranoia.1bk
│   │           ├── paranoia.2bk
│   │           ├── paranoia.sbk
│   │           ├── sort.1bk
│   │           ├── sort.2bk
│   │           ├── sort.sbk
│   │           ├── spill.1bk
│   │           ├── spill.2bk
│   │           ├── spill.sbk
│   │           ├── stdarg.1bk
│   │           ├── stdarg.2bk
│   │           ├── stdarg.sbk
│   │           ├── struct.1bk
│   │           ├── struct.2bk
│   │           ├── struct.sbk
│   │           ├── switch.1bk
│   │           ├── switch.2bk
│   │           ├── switch.sbk
│   │           ├── wf1.1bk
│   │           ├── wf1.2bk
│   │           ├── wf1.sbk
│   │           ├── yacc.1bk
│   │           ├── yacc.2bk
│   │           └── yacc.sbk
│   ├── src/
│   │   ├── 2html.c
│   │   ├── alloc.c
│   │   ├── alpha.md
│   │   ├── asdl.c
│   │   ├── bind.c
│   │   ├── bytecode.c
│   │   ├── c.h
│   │   ├── config.h
│   │   ├── dag.c
│   │   ├── dagcheck.md
│   │   ├── decl.c
│   │   ├── enode.c
│   │   ├── error.c
│   │   ├── event.c
│   │   ├── expr.c
│   │   ├── gen.c
│   │   ├── init.c
│   │   ├── inits.c
│   │   ├── input.c
│   │   ├── lex.c
│   │   ├── list.c
│   │   ├── main.c
│   │   ├── mips.md
│   │   ├── null.c
│   │   ├── output.c
│   │   ├── pass2.c
│   │   ├── prof.c
│   │   ├── profio.c
│   │   ├── rcc.asdl
│   │   ├── run.sh
│   │   ├── simp.c
│   │   ├── sparc.md
│   │   ├── stab.c
│   │   ├── stab.h
│   │   ├── stmt.c
│   │   ├── string.c
│   │   ├── sym.c
│   │   ├── symbolic.c
│   │   ├── token.h
│   │   ├── trace.c
│   │   ├── tree.c
│   │   ├── types.c
│   │   ├── x86.md
│   │   └── x86linux.md
│   ├── tst/
│   │   ├── 8q.0
│   │   ├── 8q.c
│   │   ├── array.0
│   │   ├── array.c
│   │   ├── cf.0
│   │   ├── cf.c
│   │   ├── cq.0
│   │   ├── cq.c
│   │   ├── cvt.0
│   │   ├── cvt.c
│   │   ├── fields.0
│   │   ├── fields.c
│   │   ├── front.0
│   │   ├── front.c
│   │   ├── incr.0
│   │   ├── incr.c
│   │   ├── init.0
│   │   ├── init.c
│   │   ├── limits.0
│   │   ├── limits.c
│   │   ├── paranoia.0
│   │   ├── paranoia.c
│   │   ├── sort.0
│   │   ├── sort.c
│   │   ├── spill.0
│   │   ├── spill.c
│   │   ├── stdarg.0
│   │   ├── stdarg.c
│   │   ├── struct.0
│   │   ├── struct.c
│   │   ├── switch.0
│   │   ├── switch.c
│   │   ├── wf1.0
│   │   ├── wf1.c
│   │   ├── yacc.0
│   │   └── yacc.c
│   └── x86/
│       ├── linux/
│       │   └── tst/
│       │       ├── 8q.1bk
│       │       ├── 8q.2bk
│       │       ├── 8q.sbk
│       │       ├── array.1bk
│       │       ├── array.2bk
│       │       ├── array.sbk
│       │       ├── cf.1bk
│       │       ├── cf.2bk
│       │       ├── cf.sbk
│       │       ├── cq.1bk
│       │       ├── cq.2bk
│       │       ├── cq.sbk
│       │       ├── cvt.1bk
│       │       ├── cvt.2bk
│       │       ├── cvt.sbk
│       │       ├── fields.1bk
│       │       ├── fields.2bk
│       │       ├── fields.sbk
│       │       ├── front.2bk
│       │       ├── front.sbk
│       │       ├── incr.1bk
│       │       ├── incr.2bk
│       │       ├── incr.sbk
│       │       ├── init.1bk
│       │       ├── init.2bk
│       │       ├── init.sbk
│       │       ├── limits.1bk
│       │       ├── limits.2bk
│       │       ├── limits.sbk
│       │       ├── paranoia.1bk
│       │       ├── paranoia.2bk
│       │       ├── paranoia.sbk
│       │       ├── sort.1bk
│       │       ├── sort.2bk
│       │       ├── sort.sbk
│       │       ├── spill.1bk
│       │       ├── spill.2bk
│       │       ├── spill.sbk
│       │       ├── stdarg.1bk
│       │       ├── stdarg.2bk
│       │       ├── stdarg.sbk
│       │       ├── struct.1bk
│       │       ├── struct.2bk
│       │       ├── struct.sbk
│       │       ├── switch.1bk
│       │       ├── switch.2bk
│       │       ├── switch.sbk
│       │       ├── wf1.1bk
│       │       ├── wf1.2bk
│       │       ├── wf1.sbk
│       │       ├── yacc.1bk
│       │       ├── yacc.2bk
│       │       └── yacc.sbk
│       └── win32/
│           └── tst/
│               ├── 8q.1bk
│               ├── 8q.2bk
│               ├── 8q.sbk
│               ├── array.1bk
│               ├── array.2bk
│               ├── array.sbk
│               ├── cf.1bk
│               ├── cf.2bk
│               ├── cf.sbk
│               ├── cq.1bk
│               ├── cq.2bk
│               ├── cq.sbk
│               ├── cvt.1bk
│               ├── cvt.2bk
│               ├── cvt.sbk
│               ├── fields.1bk
│               ├── fields.2bk
│               ├── fields.sbk
│               ├── front.2bk
│               ├── front.sbk
│               ├── incr.1bk
│               ├── incr.2bk
│               ├── incr.sbk
│               ├── init.1bk
│               ├── init.2bk
│               ├── init.sbk
│               ├── limits.1bk
│               ├── limits.2bk
│               ├── limits.sbk
│               ├── paranoia.1bk
│               ├── paranoia.2bk
│               ├── paranoia.sbk
│               ├── sort.1bk
│               ├── sort.2bk
│               ├── sort.sbk
│               ├── spill.1bk
│               ├── spill.2bk
│               ├── spill.sbk
│               ├── stdarg.1bk
│               ├── stdarg.2bk
│               ├── stdarg.sbk
│               ├── struct.1bk
│               ├── struct.2bk
│               ├── struct.sbk
│               ├── switch.1bk
│               ├── switch.2bk
│               ├── switch.sbk
│               ├── wf1.1bk
│               ├── wf1.2bk
│               ├── wf1.sbk
│               ├── yacc.1bk
│               ├── yacc.2bk
│               └── yacc.sbk
├── libs/
│   ├── cmdlib/
│   │   ├── cmdlib.cpp
│   │   └── cmdlib.vcproj
│   ├── cmdlib.h
│   ├── jpeg6/
│   │   ├── README
│   │   ├── jchuff.h
│   │   ├── jcomapi.cpp
│   │   ├── jconfig.h
│   │   ├── jdapimin.cpp
│   │   ├── jdapistd.cpp
│   │   ├── jdatasrc.cpp
│   │   ├── jdcoefct.cpp
│   │   ├── jdcolor.cpp
│   │   ├── jdct.h
│   │   ├── jddctmgr.cpp
│   │   ├── jdhuff.cpp
│   │   ├── jdhuff.h
│   │   ├── jdinput.cpp
│   │   ├── jdmainct.cpp
│   │   ├── jdmarker.cpp
│   │   ├── jdmaster.cpp
│   │   ├── jdpostct.cpp
│   │   ├── jdsample.cpp
│   │   ├── jdtrans.cpp
│   │   ├── jerror.cpp
│   │   ├── jerror.h
│   │   ├── jfdctflt.cpp
│   │   ├── jidctflt.cpp
│   │   ├── jinclude.h
│   │   ├── jmemmgr.cpp
│   │   ├── jmemnobs.cpp
│   │   ├── jmemsys.h
│   │   ├── jmorecfg.h
│   │   ├── jpeg6.vcproj
│   │   ├── jpegint.h
│   │   ├── jpgload.cpp
│   │   ├── jutils.cpp
│   │   └── jversion.h
│   ├── jpeglib.h
│   ├── pak/
│   │   ├── pak.vcproj
│   │   ├── pakstuff.cpp
│   │   ├── unzip.cpp
│   │   └── unzip.h
│   ├── pakstuff.h
│   └── str.h
├── q3asm/
│   ├── Makefile
│   ├── README.Id
│   ├── cmdlib.c
│   ├── cmdlib.h
│   ├── lib.txt
│   ├── mathlib.h
│   ├── notes.txt
│   ├── ops.txt
│   ├── opstrings.h
│   ├── q3asm.c
│   ├── q3asm.sln
│   ├── q3asm.vcproj
│   └── qfiles.h
├── q3map/
│   ├── brush.c
│   ├── brush_primit.c
│   ├── bsp.c
│   ├── facebsp.c
│   ├── fog.c
│   ├── gldraw.c
│   ├── glfile.c
│   ├── leakfile.c
│   ├── light.c
│   ├── light.h
│   ├── light_trace.c
│   ├── lightmaps.c
│   ├── lightv.c
│   ├── makefile
│   ├── map.c
│   ├── mesh.c
│   ├── mesh.h
│   ├── misc_model.c
│   ├── nodraw.c
│   ├── patch.c
│   ├── portals.c
│   ├── prtfile.c
│   ├── q3map.sln
│   ├── q3map.vcproj
│   ├── qbsp.h
│   ├── shaders.c
│   ├── shaders.h
│   ├── soundv.c
│   ├── surface.c
│   ├── terrain.c
│   ├── tjunction.c
│   ├── tree.c
│   ├── vis.c
│   ├── vis.h
│   ├── visflow.c
│   └── writebsp.c
├── q3radiant/
│   ├── BMP.H
│   ├── BRUSH.H
│   ├── BSInput.cpp
│   ├── BSInput.h
│   ├── BSPFILE.H
│   ├── Bmp.cpp
│   ├── Brush.cpp
│   ├── BrushScript.cpp
│   ├── CAMERA.H
│   ├── CSG.CPP
│   ├── CamWnd.cpp
│   ├── CamWnd.h
│   ├── CapDialog.cpp
│   ├── CapDialog.h
│   ├── CharBuffer.h
│   ├── ChildFrm.cpp
│   ├── ChildFrm.h
│   ├── CommandsDlg.cpp
│   ├── CommandsDlg.h
│   ├── DRAG.CPP
│   ├── DialogInfo.cpp
│   ├── DialogInfo.h
│   ├── DialogTextures.cpp
│   ├── DialogTextures.h
│   ├── DialogThick.cpp
│   ├── DialogThick.h
│   ├── DlgEvent.cpp
│   ├── DlgEvent.h
│   ├── ECLASS.CPP
│   ├── ENTITY.CPP
│   ├── ENTITY.H
│   ├── ENTITYW.H
│   ├── EPAIRS.H
│   ├── EditWnd.cpp
│   ├── EditWnd.h
│   ├── EntityListDlg.cpp
│   ├── EntityListDlg.h
│   ├── EpairsWrapper.h
│   ├── FNMATCH.CPP
│   ├── FNMATCH.H
│   ├── FindTextureDlg.cpp
│   ├── FindTextureDlg.h
│   ├── GLINGR.H
│   ├── GLInterface.cpp
│   ├── GLW_WIN.H
│   ├── GroupBar.cpp
│   ├── GroupBar.h
│   ├── GroupDlg.cpp
│   ├── GroupDlg.h
│   ├── IBSPFrontend.h
│   ├── IEpairs.cpp
│   ├── IEpairs.h
│   ├── IMessaging.h
│   ├── IPluginEntities.h
│   ├── ISelectedFace.h
│   ├── IShaders.cpp
│   ├── IShaders.h
│   ├── LBMLIB.CPP
│   ├── LBMLIB.H
│   ├── LstToolBar.cpp
│   ├── LstToolBar.h
│   ├── MAP.CPP
│   ├── MAP.H
│   ├── MATHLIB.CPP
│   ├── MATHLIB.H
│   ├── MRU.CPP
│   ├── MRU.H
│   ├── MainFrm.cpp
│   ├── MainFrm.h
│   ├── MapInfo.cpp
│   ├── MapInfo.h
│   ├── Messaging.cpp
│   ├── Messaging.h
│   ├── NameDlg.cpp
│   ├── NameDlg.h
│   ├── NewProjDlg.cpp
│   ├── NewProjDlg.h
│   ├── PARSE.CPP
│   ├── PARSE.H
│   ├── PMESH.CPP
│   ├── PMESH.H
│   ├── POINTS.CPP
│   ├── PatchDensityDlg.cpp
│   ├── PatchDensityDlg.h
│   ├── PatchDialog.cpp
│   ├── PatchDialog.h
│   ├── PlugIn.cpp
│   ├── PlugIn.h
│   ├── PlugInManager.cpp
│   ├── PlugInManager.h
│   ├── PluginEntities.cpp
│   ├── PrefsDlg.cpp
│   ├── PrefsDlg.h
│   ├── QE3.CPP
│   ├── QE3.H
│   ├── QEDEFS.H
│   ├── QERTYPES.H
│   ├── QFILES.H
│   ├── QGL.H
│   ├── QGL_WIN.C
│   ├── QGL_WIN.CPP
│   ├── RADBSP.CPP
│   ├── RADEditView.cpp
│   ├── RADEditView.h
│   ├── RADEditWnd.cpp
│   ├── RADEditWnd.h
│   ├── RADKEYS.INI
│   ├── Radiant.clw
│   ├── Radiant.cpp
│   ├── Radiant.h
│   ├── Radiant.rc
│   ├── Radiant.sln
│   ├── Radiant.vcproj
│   ├── RadiantDoc.cpp
│   ├── RadiantDoc.h
│   ├── RadiantView.cpp
│   ├── RadiantView.h
│   ├── RotateDlg.cpp
│   ├── RotateDlg.h
│   ├── SELECT.CPP
│   ├── SELECT.H
│   ├── ScaleDialog.cpp
│   ├── ScaleDialog.h
│   ├── ScriptDlg.cpp
│   ├── ScriptDlg.h
│   ├── SelectedFace.cpp
│   ├── ShaderEdit.cpp
│   ├── ShaderEdit.h
│   ├── ShaderInfo.cpp
│   ├── ShaderInfo.h
│   ├── StdAfx.cpp
│   ├── StdAfx.h
│   ├── SurfaceDlg.cpp
│   ├── SurfaceDlg.h
│   ├── SurfacePlugin.cpp
│   ├── TexEdit.cpp
│   ├── TexEdit.h
│   ├── TexWnd.cpp
│   ├── TexWnd.h
│   ├── TextureBar.cpp
│   ├── TextureBar.h
│   ├── TextureLayout.cpp
│   ├── TextureLayout.h
│   ├── TextureLoad.cpp
│   ├── TextureLoad.h
│   ├── Textures.h
│   ├── ToolWnd.cpp
│   ├── ToolWnd.h
│   ├── Undo.cpp
│   ├── Undo.h
│   ├── VERTSEL.CPP
│   ├── VIEW.H
│   ├── WIN_CAM.CPP
│   ├── WIN_DLG.CPP
│   ├── WIN_QE3.CPP
│   ├── WIN_QE3.RC2
│   ├── WIN_XY.CPP
│   ├── WIN_Z.CPP
│   ├── WaveOpen.cpp
│   ├── WaveOpen.h
│   ├── Win_ent.cpp
│   ├── Win_main.cpp
│   ├── Winding.cpp
│   ├── Winding.h
│   ├── XY.H
│   ├── XYWnd.cpp
│   ├── XYWnd.h
│   ├── Z.CPP
│   ├── Z.H
│   ├── ZView.cpp
│   ├── ZView.h
│   ├── ZWnd.cpp
│   ├── ZWnd.h
│   ├── brush_primit.cpp
│   ├── cameratargetdlg.cpp
│   ├── cameratargetdlg.h
│   ├── cbrushstub.cpp
│   ├── dlgcamera.cpp
│   ├── dlgcamera.h
│   ├── igl.h
│   ├── iscriplib.h
│   ├── isurfaceplugin.h
│   ├── qerplugin.h
│   ├── res/
│   │   ├── DEFTEX.WAL
│   │   └── Radiant.rc2
│   ├── resource.h
│   ├── splines/
│   │   ├── Splines.vcproj
│   │   ├── math_angles.cpp
│   │   ├── math_angles.h
│   │   ├── math_matrix.cpp
│   │   ├── math_matrix.h
│   │   ├── math_quaternion.cpp
│   │   ├── math_quaternion.h
│   │   ├── math_vector.cpp
│   │   ├── math_vector.h
│   │   ├── q_parse.cpp
│   │   ├── q_shared.cpp
│   │   ├── q_shared.h
│   │   ├── splines.cpp
│   │   ├── splines.h
│   │   ├── util_list.h
│   │   ├── util_str.cpp
│   │   └── util_str.h
│   ├── terrain.cpp
│   └── terrain.h
└── ui/
    ├── hud.txt
    ├── hud2.txt
    ├── ingame.txt
    ├── menudef.h
    └── menus.txt

================================================
FILE CONTENTS
================================================

================================================
FILE: COPYING.txt
================================================
		    GNU GENERAL PUBLIC LICENSE
		       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

			    Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

		    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

			    NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

		     END OF TERMS AND CONDITIONS



================================================
FILE: README.txt
================================================
Quake III Arena GPL source release
==================================

This file contains the following sections:

LICENSE
GENERAL NOTES
COMPILING ON WIN32
COMPILING ON GNU/LINUX
COMPILING ON MAC

LICENSE
=======

See COPYING.txt for the GNU GENERAL PUBLIC LICENSE

Some source code in this release is not covered by the GPL:

IO on .zip files using portions of zlib
-----------------------------------------------------------------------------
lines	file(s)
4299	code/qcommon/unzip.c
4546	libs/pak/unzip.cpp
Copyright (C) 1998 Gilles Vollant
zlib is Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

MD4 Message-Digest Algorithm
-----------------------------------------------------------------------------
lines	file(s)
299		code/qcommon/md4.c
277		common/md4.c
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.

License to copy and use this software is granted provided that it is identified 
as the <93>RSA Data Security, Inc. MD4 Message-Digest Algorithm<94> in all mater
ial mentioning or referencing this software or this function.
License is also granted to make and use derivative works provided that such work
s are identified as <93>derived from the RSA Data Security, Inc. MD4 Message-Dig
est Algorithm<94> in all material mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning either the merchanta
bility of this software or the suitability of this software for any particular p
urpose. It is provided <93>as is<94> without express or implied warranty of any 
kind.

checksums are used to validate pak files

standard C library replacement routines
-----------------------------------------------------------------------------
lines	file(s)
1324	code/game/bg_lib.c
Copyright (c) 1992, 1993
The Regents of the University of California. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
   must display the following acknowledgement:
     This product includes software developed by the University of
     California, Berkeley and its contributors.
4. Neither the name of the University nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

ADPCM coder/decoder
-----------------------------------------------------------------------------
lines	file(s)
330		code/client/snd_adpcm.c
Copyright 1992 by Stichting Mathematisch Centrum, Amsterdam, The
Netherlands.

                        All Rights Reserved

Permission to use, copy, modify, and distribute this software and its 
documentation for any purpose and without fee is hereby granted, 
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in 
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.

STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

JPEG library
-----------------------------------------------------------------------------
code/jpeg-6
libs/jpeg6
Copyright (C) 1991-1995, Thomas G. Lane

Permission is hereby granted to use, copy, modify, and distribute this
software (or portions thereof) for any purpose, without fee, subject to these
conditions:
(1) If any part of the source code for this software is distributed, then this
README file must be included, with this copyright and no-warranty notice
unaltered; and any additions, deletions, or changes to the original files
must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying
documentation must state that "this software is based in part on the work of
the Independent JPEG Group".
(3) Permission for use of this software is granted only if the user accepts
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind.

These conditions apply to any software derived from or based on the IJG code,
not just to the unmodified library.  If you use our work, you ought to
acknowledge us.

NOTE: unfortunately the README that came with our copy of the library has
been lost, so the one from release 6b is included instead. There are a few
'glue type' modifications to the library to make it easier to use from
the engine, but otherwise the dependency can be easily cleaned up to a
better release of the library.


GENERAL NOTES
=============

A short summary of the file layout:

code/			   		Quake III Arena source code ( renderer, game code, OS layer etc. )
code/bspc				bot routes compiler source code
lcc/					the retargetable C compiler ( produces assembly to be turned into qvm bytecode by q3asm )
q3asm/					assembly to qvm bytecode compiler
q3map/					map compiler ( .map -> .bsp ) - this is the version that comes with Q3Radiant 200f
q3radiant/				Q3Radiant map editor build 200f ( common/ and libs/ are support dirs for radiant )

While we made sure we were still able to compile the game on Windows, GNU/Linux and Mac, this build didn't get any kind of extensive testing so it may not work completely right. Whenever an id game is released under GPL, several projects start making the source code more friendly to nowaday's compilers and environements. If you are picking up this release weeks/months/years after we uploaded it, you probably want to look around on the net for cleaned up versions of this codebase as well.

COMPILING ON WIN32
==================

VC7 / Visual C++ 2003 project files are provided:
code/quake3.sln
q3radiant/Radiant.sln

To compile the qvms, you need to run some batch files:
you will need to have lcc.exe q3cpp.exe q3rcc.exe and q3asm.exe in your path
( some precompiled binaries are provided in lcc/bin and code/win32/mod-sdk-setup/bin )
the qvm batch files are in code/game code/cgame code/q3_ui code/ui ..

COMPILING ON GNU/LINUX
==================

the build system using cons, which may be known as scons's perl ancestor now
you don't have to track it down though, the build script is provided in the tree
you will need nasm and gcc 2.95
make sure you have the X Direct Graphics Access and X Video Mode extensions headers for your X11
a typical compile command goes like this:
[..]/code$ ./unix/cons -- gcc=gcc-2.95 g++=g++-2.95

COMPILING ON MAC
================

project file for OSX compile is in code/macosx/Quake3.pbproj


================================================
FILE: code/Construct
================================================
# -*- mode: perl -*-
# cons script for cgame game q3_ui ui .so and .qvm builds
#
# Oct. 2001 TTimo <ttimo@idsoftware.com>
#

# the top directory is
# <config>-<cpu>-<OS>-<libc version>
# where:
#   <config> is "debug" or "release"
#   <cpu> is "x86" or "ppc"
#   <OS> is "Linux" "BSD" "IRIX" etc.
#   <libc version> is major.minor of libc config

# source the compiler version utility
BEGIN {
  push @INC, './unix';
}
use Cons_gcc;

# defaults
$config = 'debug';
$do_smp = 1;
$do_masterserver = 0;
$do_authserver = 0;
$do_authport = 0;
$do_setup = 0;
$do_bspc = 0;
$do_sdk = 0;
$do_pk3 = 0;
# those are exported
$DO_WIN32 = 0;
$NO_VM = 0;
$NO_SO = 0;
$CC='gcc';
$CXX='g++';

# detect an sdk build (don't attempt client build and other things)
if ( -r 'unix/Conscript-client' )
{
  $no_core = 0;
}
else
{
  $no_core = 1;
}

# detection of CPU type
$cpu = `uname -m`;
chop ($cpu);
if ($cpu +~ /i?86/)
{
  $cpu = 'x86';
}
# OS
$OS = `uname`;
chop ($OS);
# hacky win32 detection and win32 specifics code
if ($OS =~ CYGWIN)
{
	$DO_WIN32 = 1;
}
else
{
	# libc .. do the little magic!
	$libc_cmd = '/lib/libc.so.6 |grep "GNU C "|grep version|awk -F "version " \'{ print $2 }\'|cut -b -3';
	$libc = `$libc_cmd`;
	chop ($libc);
}

if ($DO_WIN32 eq 1)
{
	print("Win32 build\n");

	$config = $ARGV[0];

	# TODO: option to override $Q3BASE from command line
	$Q3BASE = $ENV{Q3BASE}; # FIXME: this doesn't play nice with cygwin path syntax
	print("\$Q3BASE: $Q3BASE\n");	

	if($config eq 'debug')
	{
	  $DIR = 'Debug';
		system("cp -v $DIR/quake3.exe \$Q3BASE");
		system("cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \$Q3BASE/baseq3");
	}
	elsif ($config eq 'debug-TA')
	{
		$DIR = 'Debug_TA';
		system("cp -v $DIR/quake3.exe \$Q3BASE");
		system("cp -v $DIR/cgamex86.dll $DIR/qagamex86.dll $DIR/uix86.dll \$Q3BASE/missionpack");
	}
	elsif($config eq 'release-TA')
	{
		$DIR = 'Release_TA';
		# spank!
		system("./spank.sh");
		system("cp -v $DIR/quake3.exe \$Q3BASE");
	}
	else
	{
		printf("ERROR: no config option (debug debug-TA release-TA)");
		exit;
	}

	# copy selected stuff to shared media
	$DESTDIR='/cygdrive/e/incoming/Id/q3-1.32';
	system("cp -v $DIR/quake3.exe $DESTDIR");
	system("cp -v /cygdrive/e/Q3SetupMedia/quake3/CHANGES-1.32.txt $DESTDIR");

	exit;	
}

if(@ARGV gt 0)
{
  foreach $cmdopt (@ARGV)
  {
    if(lc($cmdopt) eq 'release')
    {
      $config = 'release';
      next;
    }
    elsif(lc($cmdopt) eq 'debug')
    {
      $config = 'debug';
      next;
    }
    elsif(lc($cmdopt) eq 'novm')
    {
      $NO_VM = 1;
      next;
    }
    elsif(lc($cmdopt) eq 'noso')
    {
      $NO_SO = 1;
      next;
    }
    elsif(lc($cmdopt) eq 'nosmp')
    {
      $do_smp = 0;
      next;
    }
    elsif(lc($cmdopt) =~ 'master_server=.*')
    {
      $do_masterserver = 1;
      $master_server = lc($cmdopt);
      $master_server =~ s/master_server=(.*)/\1/;
      next;
    }
    elsif(lc($cmdopt) =~ 'auth_server=.*')
    {
      $do_authserver = 1;
      $auth_server = lc($cmdopt);
      $auth_server =~ s/auth_server=(.*)/\1/;
      next;
    }
    elsif(lc($cmdopt) =~ 'auth_port=.*')
    {
      $do_authport = 1;
      $auth_port = lc($cmdopt);
      $auth_port =~ s/auth_port=(.*)/\1/;
      next;
    }
    elsif(lc($cmdopt) =~ 'setup')
    {
      $do_setup = 1;
      next;
    }
    elsif(lc($cmdopt) =~ 'bspc')
    {
      $do_bspc = 1;
      next;
    }
    elsif(lc($cmdopt) =~ 'sdk')
    {
      $do_sdk = 1;
      next;
    }
    elsif(lc($cmdopt) =~ 'pk3')
    {
      $do_pk3 = 1;
      next;
    }
	elsif(lc($cmdopt) =~ 'gcc=.*')
    {
      $CC=lc($cmdopt);
      $CC =~ s/gcc=(.*)/\1/;
      next;
    }
    elsif(lc($cmdopt) =~ 'g\+\+=.*')
    {
      $CXX=lc($cmdopt);
      $CXX=~s/g\+\+=(.*)/\1/;
      next;
    }
    else
    {
      # output an error & exit
      print("Error\n  $0: Unknown command line option: [ $cmdopt ]\n");
      system("cons -h");
      exit;
    }
  }
}

if (($do_setup eq 1) && ($config ne 'release'))
{
  print("Error\n  $0: 'setup' requires 'release'\n");
  exit;
}

# sdk
if ($do_sdk eq 1)
{
  # extract the Q3 version from q_shared.h
  $line = `cat game/q_shared.h | grep Q3_VERSION`;
  chomp $line;
  $line =~ s/.*Q3\ (.*)\"/$1/;
  $Q3_VER = $line;
  $SDK_NAME = "linuxq3a-sdk-$Q3_VER.x86.run";
  Default "unix/$SDK_NAME";
  Export qw( SDK_NAME Q3_VER );
  Build 'unix/Conscript-sdk';
  return;
}

# build the config directory
$CONFIG_DIR = $config . '-' . $cpu . '-' . $OS . '-' . $libc;

$COMMON_CFLAGS = '-pipe -fsigned-char ';

if ($config eq 'debug')
{
  # use -Werror for better QA  
  $BASE_CFLAGS = $COMMON_CFLAGS . '-g -Wall -Werror -O ';
	$BSPC_BASE_CFLAGS = $COMMON_CFLAGS . '-g -O -DLINUX -DBSPC -Dstricmp=strcasecmp ';
}
else
{
  $BASE_CFLAGS = $COMMON_CFLAGS . '-DNDEBUG -O6 -mcpu=pentiumpro -march=pentium -fomit-frame-pointer -ffast-math -malign-loops=2 -malign-jumps=2 -malign-functions=2 -fno-strict-aliasing -fstrength-reduce ';
	$BSPC_BASE_CFLAGS = $BASE_CFLAGS . '-DLINUX -DBSPC -Dstricmp=strcasecmp ';
}

if ($do_masterserver eq 1)
{
	$BASE_CFLAGS .= "-DMASTER_SERVER_NAME=\\\"$master_server\\\" ";
}

if ($do_authserver eq 1)
{
	$BASE_CFLAGS .= "-DAUTHORIZE_SERVER_NAME=\\\"$auth_server\\\" ";
}

if ($do_authport eq 1)
{
	$BASE_CFLAGS .= "-DPORT_AUTHORIZE=$auth_port ";
}

my @gcc_version = Cons_gcc::get_gcc_version($CC);
print("GCC version: $gcc_version[1] - $gcc_version[2]\n");
# with 2.95 you can link with gcc, this avoids nasty useless libstdc++ dependency
if ($gcc_version[0] eq '2')
{
	$LINK = $CC;
} else {
	$LINK = $CXX;
}

my @ccache = Cons_gcc::get_ccache();
if ($ccache[0] eq '1')
{
  $CC = $ccache[1] . " " . $CC;
  $CXX = $ccache[1] . " " . $CXX;
}

print 'cpu : ' . $cpu . "\nOS  : " . $OS . "\n";
print "libc: " . $libc . "\n";
print "configured for " . $config . " build\n";
print 'CFLAGS: ' . $BASE_CFLAGS . "\n";

# install config
$INSTALL_BASEDIR='#install';

Default $INSTALL_BASEDIR;

sub build_tools {
  system("mkdir qvmtools 2>/dev/null");
  if (@_[0] eq 'q3lcc')
  {
    system("cd ../lcc ; make all ; cp /tmp/lcc ../code/qvmtools/q3lcc ; cp /tmp/rcc ../code/qvmtools/q3rcc ; cp /tmp/cpp ../code/qvmtools/q3cpp");
  }
  elsif (@_[0] eq 'q3asm')
  {
    system("cd ../q3asm ; make ; cp q3asm ../code/qvmtools");
  }
  else
  {
    printf("build_tools: @_[0] unrecognized command\n");
    die;
  }
  return 1;
}

# build tools
$env_tools = new cons();
Command $env_tools 'qvmtools/q3lcc', '[perl] &build_tools(\'q3lcc\')';
Command $env_tools 'qvmtools/q3asm', '[perl] &build_tools(\'q3asm\')';

if ($do_bspc eq 1)
{
	# build bspc
	$BUILD_DIR = $CONFIG_DIR . '/bspc';
	Link $BUILD_DIR => '.';
	$INSTALL_DIR = $INSTALL_BASEDIR . '/utils';
	Export qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
	Build $BUILD_DIR . '/bspc/Conscript';
}

# build vanilla Q3
$TARGET_DIR='Q3';

$INSTALL_DIR = $INSTALL_BASEDIR . '/baseq3';

$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/cgame';
Link $BUILD_DIR => '.';
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
Build $BUILD_DIR . '/cgame/Conscript';

$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/game';
Link $BUILD_DIR => '.';
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
Build $BUILD_DIR . '/game/Conscript';

$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/q3_ui';
Link $BUILD_DIR => '.';
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
Build $BUILD_DIR . '/q3_ui/Conscript';
  
# build TA
$TARGET_DIR='TA';

$INSTALL_DIR = $INSTALL_BASEDIR . '/missionpack';

$BUILD_DIR = $CONFIG_DIR . "/" . $TARGET_DIR . '/cgame';
Link $BUILD_DIR => '.';
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
Build $BUILD_DIR . '/cgame/Conscript';

$BUILD_DIR = $CONFIG_DIR . "/" . $TARGET_DIR . '/game';
Link $BUILD_DIR => '.';
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
Build $BUILD_DIR . '/game/Conscript';

$BUILD_DIR = $CONFIG_DIR . '/' . $TARGET_DIR . '/ui';
Link $BUILD_DIR => '.';
Export qw( BASE_CFLAGS TARGET_DIR INSTALL_DIR NO_VM NO_SO CC CXX LINK );
Build $BUILD_DIR . '/ui/Conscript';

# core
if ($no_core eq 1)
{
  return;
}

$INSTALL_DIR = $INSTALL_BASEDIR;
$BUILD_DIR = $CONFIG_DIR . '/core/dedicated';
Link $BUILD_DIR => '.';
$hack = $BASE_CFLAGS; # hit me!
$BASE_CFLAGS .= '-DDEDICATED ';
Export qw( BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );
Build $BUILD_DIR . '/unix/Conscript-dedicated';
$BASE_CFLAGS = $hack;



$TARGETNAME = 'linuxquake3';
$BUILD_DIR = $CONFIG_DIR . '/core/client';
$BASE_LDFLAGS = '';

Link $BUILD_DIR => '.';
Export qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );
Build $BUILD_DIR . '/unix/Conscript-client';

if ($do_smp eq 1)
{
	$TARGETNAME = 'linuxquake3-smp';
	$BUILD_DIR = $CONFIG_DIR . '/core/client-smp';
	$BASE_CFLAGS .= '-DSMP ';
	$BASE_LDFLAGS = '-lpthread ';
	
  Link $BUILD_DIR => '.';
  Export qw( BASE_CFLAGS BASE_LDFLAGS BUILD_DIR INSTALL_DIR TARGETNAME CC CXX LINK );
  Build $BUILD_DIR . '/unix/Conscript-client';	
}

if ($NO_VM eq 0 && $do_pk3 eq 1)
{
	# build the PK3s
	$INSTALL_DIR = $INSTALL_BASEDIR;
	$BUILD_DIR = $CONFIG_DIR . '/pk3-builder';
	Link $BUILD_DIR => 'unix';
	Export qw( INSTALL_DIR BUILD_DIR CONFIG_DIR CC CXX LINK );
	Build $BUILD_DIR . '/Conscript-pk3';
}

if ($do_setup eq 1)
{
  Link $CONFIG_DIR => '.';
  Export qw( INSTALL_BASEDIR );
  Build $CONFIG_DIR . '/unix/Conscript-setup';
}

Help 
"
Usage: cons [-h] [ -- [release|debug] [novm] [noso] [nosmp] [master_server=<adr>] [auth_server=<adr>] [auth_port=<port>] [pk3] [bspc] [setup] [sdk]]
Default build type is Debug, specifying '-- release' on the
command line builds a Release version (NOTE that this option
only affects the native libraries).

novm: will not build the VMs
noso: will not build the so

below are for core builds only:

nosmp : do not build the SMP-enabled version of the renderer
pk3   : generate the pk3s on the fly (defined in unix/Conscript-pk3)
bspc  : build bspc
setup : build setup 
sdk   : build the mod sdk
"
;


================================================
FILE: code/Makefile
================================================
# nasty ugly to get build system working from Anjuta
all:
	if [ `hostname` == sparkle ] ; then ./unix/pcons-2.3.1 -j4 -- novm noso ; else ./unix/cons ; fi


================================================
FILE: code/botlib/aasfile.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/


//NOTE:	int =	default signed
//				default long

#define AASID						(('S'<<24)+('A'<<16)+('A'<<8)+'E')
#define AASVERSION_OLD				4
#define AASVERSION					5

//presence types
#define PRESENCE_NONE				1
#define PRESENCE_NORMAL				2
#define PRESENCE_CROUCH				4

//travel types
#define MAX_TRAVELTYPES				32
#define TRAVEL_INVALID				1		//temporary not possible
#define TRAVEL_WALK					2		//walking
#define TRAVEL_CROUCH				3		//crouching
#define TRAVEL_BARRIERJUMP			4		//jumping onto a barrier
#define TRAVEL_JUMP					5		//jumping
#define TRAVEL_LADDER				6		//climbing a ladder
#define TRAVEL_WALKOFFLEDGE			7		//walking of a ledge
#define TRAVEL_SWIM					8		//swimming
#define TRAVEL_WATERJUMP			9		//jump out of the water
#define TRAVEL_TELEPORT				10		//teleportation
#define TRAVEL_ELEVATOR				11		//travel by elevator
#define TRAVEL_ROCKETJUMP			12		//rocket jumping required for travel
#define TRAVEL_BFGJUMP				13		//bfg jumping required for travel
#define TRAVEL_GRAPPLEHOOK			14		//grappling hook required for travel
#define TRAVEL_DOUBLEJUMP			15		//double jump
#define TRAVEL_RAMPJUMP				16		//ramp jump
#define TRAVEL_STRAFEJUMP			17		//strafe jump
#define TRAVEL_JUMPPAD				18		//jump pad
#define TRAVEL_FUNCBOB				19		//func bob

//additional travel flags
#define TRAVELTYPE_MASK				0xFFFFFF
#define TRAVELFLAG_NOTTEAM1			(1 << 24)
#define TRAVELFLAG_NOTTEAM2			(2 << 24)

//face flags
#define FACE_SOLID					1		//just solid at the other side
#define FACE_LADDER					2		//ladder
#define FACE_GROUND					4		//standing on ground when in this face
#define FACE_GAP					8		//gap in the ground
#define FACE_LIQUID					16		//face seperating two areas with liquid
#define FACE_LIQUIDSURFACE			32		//face seperating liquid and air
#define FACE_BRIDGE					64		//can walk over this face if bridge is closed

//area contents
#define AREACONTENTS_WATER				1
#define AREACONTENTS_LAVA				2
#define AREACONTENTS_SLIME				4
#define AREACONTENTS_CLUSTERPORTAL		8
#define AREACONTENTS_TELEPORTAL			16
#define AREACONTENTS_ROUTEPORTAL		32
#define AREACONTENTS_TELEPORTER			64
#define AREACONTENTS_JUMPPAD			128
#define AREACONTENTS_DONOTENTER			256
#define	AREACONTENTS_VIEWPORTAL			512
#define AREACONTENTS_MOVER				1024
#define AREACONTENTS_NOTTEAM1			2048
#define AREACONTENTS_NOTTEAM2			4096
//number of model of the mover inside this area
#define AREACONTENTS_MODELNUMSHIFT		24
#define AREACONTENTS_MAXMODELNUM		0xFF
#define AREACONTENTS_MODELNUM			(AREACONTENTS_MAXMODELNUM << AREACONTENTS_MODELNUMSHIFT)

//area flags
#define AREA_GROUNDED				1		//bot can stand on the ground
#define AREA_LADDER					2		//area contains one or more ladder faces
#define AREA_LIQUID					4		//area contains a liquid
#define AREA_DISABLED				8		//area is disabled for routing when set
#define AREA_BRIDGE					16		//area ontop of a bridge

//aas file header lumps
#define AAS_LUMPS					14
#define AASLUMP_BBOXES				0
#define AASLUMP_VERTEXES			1
#define AASLUMP_PLANES				2
#define AASLUMP_EDGES				3
#define AASLUMP_EDGEINDEX			4
#define AASLUMP_FACES				5
#define AASLUMP_FACEINDEX			6
#define AASLUMP_AREAS				7
#define AASLUMP_AREASETTINGS		8
#define AASLUMP_REACHABILITY		9
#define AASLUMP_NODES				10
#define AASLUMP_PORTALS				11
#define AASLUMP_PORTALINDEX			12
#define AASLUMP_CLUSTERS			13

//========== bounding box =========

//bounding box
typedef struct aas_bbox_s
{
	int presencetype;
	int flags;
	vec3_t mins, maxs;
} aas_bbox_t;

//============ settings ===========

//reachability to another area
typedef struct aas_reachability_s
{
	int areanum;						//number of the reachable area
	int facenum;						//number of the face towards the other area
	int edgenum;						//number of the edge towards the other area
	vec3_t start;						//start point of inter area movement
	vec3_t end;							//end point of inter area movement
	int traveltype;					//type of travel required to get to the area
	unsigned short int traveltime;//travel time of the inter area movement
} aas_reachability_t;

//area settings
typedef struct aas_areasettings_s
{
	//could also add all kind of statistic fields
	int contents;						//contents of the area
	int areaflags;						//several area flags
	int presencetype;					//how a bot can be present in this area
	int cluster;						//cluster the area belongs to, if negative it's a portal
	int clusterareanum;				//number of the area in the cluster
	int numreachableareas;			//number of reachable areas from this one
	int firstreachablearea;			//first reachable area in the reachable area index
} aas_areasettings_t;

//cluster portal
typedef struct aas_portal_s
{
	int areanum;						//area that is the actual portal
	int frontcluster;					//cluster at front of portal
	int backcluster;					//cluster at back of portal
	int clusterareanum[2];			//number of the area in the front and back cluster
} aas_portal_t;

//cluster portal index
typedef int aas_portalindex_t;

//cluster
typedef struct aas_cluster_s
{
	int numareas;						//number of areas in the cluster
	int numreachabilityareas;			//number of areas with reachabilities
	int numportals;						//number of cluster portals
	int firstportal;					//first cluster portal in the index
} aas_cluster_t;

//============ 3d definition ============

typedef vec3_t aas_vertex_t;

//just a plane in the third dimension
typedef struct aas_plane_s
{
	vec3_t normal;						//normal vector of the plane
	float dist;							//distance of the plane (normal vector * distance = point in plane)
	int type;
} aas_plane_t;

//edge
typedef struct aas_edge_s
{
	int v[2];							//numbers of the vertexes of this edge
} aas_edge_t;

//edge index, negative if vertexes are reversed
typedef int aas_edgeindex_t;

//a face bounds an area, often it will also seperate two areas
typedef struct aas_face_s
{
	int planenum;						//number of the plane this face is in
	int faceflags;						//face flags (no use to create face settings for just this field)
	int numedges;						//number of edges in the boundary of the face
	int firstedge;						//first edge in the edge index
	int frontarea;						//area at the front of this face
	int backarea;						//area at the back of this face
} aas_face_t;

//face index, stores a negative index if backside of face
typedef int aas_faceindex_t;

//area with a boundary of faces
typedef struct aas_area_s
{
	int areanum;						//number of this area
	//3d definition
	int numfaces;						//number of faces used for the boundary of the area
	int firstface;						//first face in the face index used for the boundary of the area
	vec3_t mins;						//mins of the area
	vec3_t maxs;						//maxs of the area
	vec3_t center;						//'center' of the area
} aas_area_t;

//nodes of the bsp tree
typedef struct aas_node_s
{
	int planenum;
	int children[2];					//child nodes of this node, or areas as leaves when negative
										//when a child is zero it's a solid leaf
} aas_node_t;

//=========== aas file ===============

//header lump
typedef struct
{
	int fileofs;
	int filelen;
} aas_lump_t;

//aas file header
typedef struct aas_header_s
{
	int ident;
	int version;
	int bspchecksum;
	//data entries
	aas_lump_t lumps[AAS_LUMPS];
} aas_header_t;


//====== additional information ======
/*

-	when a node child is a solid leaf the node child number is zero
-	two adjacent areas (sharing a plane at opposite sides) share a face
	this face is a portal between the areas
-	when an area uses a face from the faceindex with a positive index
	then the face plane normal points into the area
-	the face edges are stored counter clockwise using the edgeindex
-	two adjacent convex areas (sharing a face) only share One face
	this is a simple result of the areas being convex
-	the areas can't have a mixture of ground and gap faces
	other mixtures of faces in one area are allowed
-	areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
	the cluster number set to the negative portal number
-	edge zero is a dummy
-	face zero is a dummy
-	area zero is a dummy
-	node zero is a dummy
*/


================================================
FILE: code/botlib/be_aas_bsp.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_bsp.h
 *
 * desc:		AAS
 *
 * $Archive: /source/code/botlib/be_aas_bsp.h $
 *
 *****************************************************************************/

#ifdef AASINTERN
//loads the given BSP file
int AAS_LoadBSPFile(void);
//dump the loaded BSP data
void AAS_DumpBSPData(void);
//unlink the given entity from the bsp tree leaves
void AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves);
//link the given entity to the bsp tree leaves of the given model
bsp_link_t *AAS_BSPLinkEntity(vec3_t absmins,
										vec3_t absmaxs,
										int entnum,
										int modelnum);

//calculates collision with given entity
qboolean AAS_EntityCollision(int entnum,
										vec3_t start,
										vec3_t boxmins,
										vec3_t boxmaxs,
										vec3_t end,
										int contentmask,
										bsp_trace_t *trace);
//for debugging
void AAS_PrintFreeBSPLinks(char *str);
//
#endif //AASINTERN

#define MAX_EPAIRKEY		128

//trace through the world
bsp_trace_t AAS_Trace(	vec3_t start,
								vec3_t mins,
								vec3_t maxs,
								vec3_t end,
								int passent,
								int contentmask);
//returns the contents at the given point
int AAS_PointContents(vec3_t point);
//returns true when p2 is in the PVS of p1
qboolean AAS_inPVS(vec3_t p1, vec3_t p2);
//returns true when p2 is in the PHS of p1
qboolean AAS_inPHS(vec3_t p1, vec3_t p2);
//returns true if the given areas are connected
qboolean AAS_AreasConnected(int area1, int area2);
//creates a list with entities totally or partly within the given box
int AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount);
//gets the mins, maxs and origin of a BSP model
void AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin);
//handle to the next bsp entity
int AAS_NextBSPEntity(int ent);
//return the value of the BSP epair key
int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size);
//get a vector for the BSP epair key
int AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v);
//get a float for the BSP epair key
int AAS_FloatForBSPEpairKey(int ent, char *key, float *value);
//get an integer for the BSP epair key
int AAS_IntForBSPEpairKey(int ent, char *key, int *value);



================================================
FILE: code/botlib/be_aas_bspq3.c
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_bspq3.c
 *
 * desc:		BSP, Environment Sampling
 *
 * $Archive: /MissionPack/code/botlib/be_aas_bspq3.c $
 *
 *****************************************************************************/

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_aas_def.h"

extern botlib_import_t botimport;

//#define TRACE_DEBUG

#define ON_EPSILON		0.005
//#define DEG2RAD( a ) (( a * M_PI ) / 180.0F)

#define MAX_BSPENTITIES		2048

typedef struct rgb_s
{
	int red;
	int green;
	int blue;
} rgb_t;

//bsp entity epair
typedef struct bsp_epair_s
{
	char *key;
	char *value;
	struct bsp_epair_s *next;
} bsp_epair_t;

//bsp data entity
typedef struct bsp_entity_s
{
	bsp_epair_t *epairs;
} bsp_entity_t;

//id Sofware BSP data
typedef struct bsp_s
{
	//true when bsp file is loaded
	int loaded;
	//entity data
	int entdatasize;
	char *dentdata;
	//bsp entities
	int numentities;
	bsp_entity_t entities[MAX_BSPENTITIES];
} bsp_t;

//global bsp
bsp_t bspworld;


#ifdef BSP_DEBUG
typedef struct cname_s
{
	int value;
	char *name;
} cname_t;

cname_t contentnames[] =
{
	{CONTENTS_SOLID,"CONTENTS_SOLID"},
	{CONTENTS_WINDOW,"CONTENTS_WINDOW"},
	{CONTENTS_AUX,"CONTENTS_AUX"},
	{CONTENTS_LAVA,"CONTENTS_LAVA"},
	{CONTENTS_SLIME,"CONTENTS_SLIME"},
	{CONTENTS_WATER,"CONTENTS_WATER"},
	{CONTENTS_MIST,"CONTENTS_MIST"},
	{LAST_VISIBLE_CONTENTS,"LAST_VISIBLE_CONTENTS"},

	{CONTENTS_AREAPORTAL,"CONTENTS_AREAPORTAL"},
	{CONTENTS_PLAYERCLIP,"CONTENTS_PLAYERCLIP"},
	{CONTENTS_MONSTERCLIP,"CONTENTS_MONSTERCLIP"},
	{CONTENTS_CURRENT_0,"CONTENTS_CURRENT_0"},
	{CONTENTS_CURRENT_90,"CONTENTS_CURRENT_90"},
	{CONTENTS_CURRENT_180,"CONTENTS_CURRENT_180"},
	{CONTENTS_CURRENT_270,"CONTENTS_CURRENT_270"},
	{CONTENTS_CURRENT_UP,"CONTENTS_CURRENT_UP"},
	{CONTENTS_CURRENT_DOWN,"CONTENTS_CURRENT_DOWN"},
	{CONTENTS_ORIGIN,"CONTENTS_ORIGIN"},
	{CONTENTS_MONSTER,"CONTENTS_MONSTER"},
	{CONTENTS_DEADMONSTER,"CONTENTS_DEADMONSTER"},
	{CONTENTS_DETAIL,"CONTENTS_DETAIL"},
	{CONTENTS_TRANSLUCENT,"CONTENTS_TRANSLUCENT"},
	{CONTENTS_LADDER,"CONTENTS_LADDER"},
	{0, 0}
};

void PrintContents(int contents)
{
	int i;

	for (i = 0; contentnames[i].value; i++)
	{
		if (contents & contentnames[i].value)
		{
			botimport.Print(PRT_MESSAGE, "%s\n", contentnames[i].name);
		} //end if
	} //end for
} //end of the function PrintContents

#endif // BSP_DEBUG
//===========================================================================
// traces axial boxes of any size through the world
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
bsp_trace_t AAS_Trace(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int passent, int contentmask)
{
	bsp_trace_t bsptrace;
	botimport.Trace(&bsptrace, start, mins, maxs, end, passent, contentmask);
	return bsptrace;
} //end of the function AAS_Trace
//===========================================================================
// returns the contents at the given point
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_PointContents(vec3_t point)
{
	return botimport.PointContents(point);
} //end of the function AAS_PointContents
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_EntityCollision(int entnum,
					vec3_t start, vec3_t boxmins, vec3_t boxmaxs, vec3_t end,
								int contentmask, bsp_trace_t *trace)
{
	bsp_trace_t enttrace;

	botimport.EntityTrace(&enttrace, start, boxmins, boxmaxs, end, entnum, contentmask);
	if (enttrace.fraction < trace->fraction)
	{
		Com_Memcpy(trace, &enttrace, sizeof(bsp_trace_t));
		return qtrue;
	} //end if
	return qfalse;
} //end of the function AAS_EntityCollision
//===========================================================================
// returns true if in Potentially Hearable Set
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_inPVS(vec3_t p1, vec3_t p2)
{
	return botimport.inPVS(p1, p2);
} //end of the function AAS_InPVS
//===========================================================================
// returns true if in Potentially Visible Set
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_inPHS(vec3_t p1, vec3_t p2)
{
	return qtrue;
} //end of the function AAS_inPHS
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t mins, vec3_t maxs, vec3_t origin)
{
	botimport.BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin);
} //end of the function AAS_BSPModelMinsMaxs
//===========================================================================
// unlinks the entity from all leaves
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_UnlinkFromBSPLeaves(bsp_link_t *leaves)
{
} //end of the function AAS_UnlinkFromBSPLeaves
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
bsp_link_t *AAS_BSPLinkEntity(vec3_t absmins, vec3_t absmaxs, int entnum, int modelnum)
{
	return NULL;
} //end of the function AAS_BSPLinkEntity
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_BoxEntities(vec3_t absmins, vec3_t absmaxs, int *list, int maxcount)
{
	return 0;
} //end of the function AAS_BoxEntities
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
int AAS_NextBSPEntity(int ent)
{
	ent++;
	if (ent >= 1 && ent < bspworld.numentities) return ent;
	return 0;
} //end of the function AAS_NextBSPEntity
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
int AAS_BSPEntityInRange(int ent)
{
	if (ent <= 0 || ent >= bspworld.numentities)
	{
		botimport.Print(PRT_MESSAGE, "bsp entity out of range\n");
		return qfalse;
	} //end if
	return qtrue;
} //end of the function AAS_BSPEntityInRange
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size)
{
	bsp_epair_t *epair;

	value[0] = '\0';
	if (!AAS_BSPEntityInRange(ent)) return qfalse;
	for (epair = bspworld.entities[ent].epairs; epair; epair = epair->next)
	{
		if (!strcmp(epair->key, key))
		{
			strncpy(value, epair->value, size-1);
			value[size-1] = '\0';
			return qtrue;
		} //end if
	} //end for
	return qfalse;
} //end of the function AAS_FindBSPEpair
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_VectorForBSPEpairKey(int ent, char *key, vec3_t v)
{
	char buf[MAX_EPAIRKEY];
	double v1, v2, v3;

	VectorClear(v);
	if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
	//scanf into doubles, then assign, so it is vec_t size independent
	v1 = v2 = v3 = 0;
	sscanf(buf, "%lf %lf %lf", &v1, &v2, &v3);
	v[0] = v1;
	v[1] = v2;
	v[2] = v3;
	return qtrue;
} //end of the function AAS_VectorForBSPEpairKey
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_FloatForBSPEpairKey(int ent, char *key, float *value)
{
	char buf[MAX_EPAIRKEY];
	
	*value = 0;
	if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
	*value = atof(buf);
	return qtrue;
} //end of the function AAS_FloatForBSPEpairKey
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_IntForBSPEpairKey(int ent, char *key, int *value)
{
	char buf[MAX_EPAIRKEY];
	
	*value = 0;
	if (!AAS_ValueForBSPEpairKey(ent, key, buf, MAX_EPAIRKEY)) return qfalse;
	*value = atoi(buf);
	return qtrue;
} //end of the function AAS_IntForBSPEpairKey
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_FreeBSPEntities(void)
{
	int i;
	bsp_entity_t *ent;
	bsp_epair_t *epair, *nextepair;

	for (i = 1; i < bspworld.numentities; i++)
	{
		ent = &bspworld.entities[i];
		for (epair = ent->epairs; epair; epair = nextepair)
		{
			nextepair = epair->next;
			//
			if (epair->key) FreeMemory(epair->key);
			if (epair->value) FreeMemory(epair->value);
			FreeMemory(epair);
		} //end for
	} //end for
	bspworld.numentities = 0;
} //end of the function AAS_FreeBSPEntities
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_ParseBSPEntities(void)
{
	script_t *script;
	token_t token;
	bsp_entity_t *ent;
	bsp_epair_t *epair;

	script = LoadScriptMemory(bspworld.dentdata, bspworld.entdatasize, "entdata");
	SetScriptFlags(script, SCFL_NOSTRINGWHITESPACES|SCFL_NOSTRINGESCAPECHARS);//SCFL_PRIMITIVE);

	bspworld.numentities = 1;

	while(PS_ReadToken(script, &token))
	{
		if (strcmp(token.string, "{"))
		{
			ScriptError(script, "invalid %s\n", token.string);
			AAS_FreeBSPEntities();
			FreeScript(script);
			return;
		} //end if
		if (bspworld.numentities >= MAX_BSPENTITIES)
		{
			botimport.Print(PRT_MESSAGE, "too many entities in BSP file\n");
			break;
		} //end if
		ent = &bspworld.entities[bspworld.numentities];
		bspworld.numentities++;
		ent->epairs = NULL;
		while(PS_ReadToken(script, &token))
		{
			if (!strcmp(token.string, "}")) break;
			epair = (bsp_epair_t *) GetClearedHunkMemory(sizeof(bsp_epair_t));
			epair->next = ent->epairs;
			ent->epairs = epair;
			if (token.type != TT_STRING)
			{
				ScriptError(script, "invalid %s\n", token.string);
				AAS_FreeBSPEntities();
				FreeScript(script);
				return;
			} //end if
			StripDoubleQuotes(token.string);
			epair->key = (char *) GetHunkMemory(strlen(token.string) + 1);
			strcpy(epair->key, token.string);
			if (!PS_ExpectTokenType(script, TT_STRING, 0, &token))
			{
				AAS_FreeBSPEntities();
				FreeScript(script);
				return;
			} //end if
			StripDoubleQuotes(token.string);
			epair->value = (char *) GetHunkMemory(strlen(token.string) + 1);
			strcpy(epair->value, token.string);
		} //end while
		if (strcmp(token.string, "}"))
		{
			ScriptError(script, "missing }\n");
			AAS_FreeBSPEntities();
			FreeScript(script);
			return;
		} //end if
	} //end while
	FreeScript(script);
} //end of the function AAS_ParseBSPEntities
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_BSPTraceLight(vec3_t start, vec3_t end, vec3_t endpos, int *red, int *green, int *blue)
{
	return 0;
} //end of the function AAS_BSPTraceLight
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_DumpBSPData(void)
{
	AAS_FreeBSPEntities();

	if (bspworld.dentdata) FreeMemory(bspworld.dentdata);
	bspworld.dentdata = NULL;
	bspworld.entdatasize = 0;
	//
	bspworld.loaded = qfalse;
	Com_Memset( &bspworld, 0, sizeof(bspworld) );
} //end of the function AAS_DumpBSPData
//===========================================================================
// load an bsp file
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_LoadBSPFile(void)
{
	AAS_DumpBSPData();
	bspworld.entdatasize = strlen(botimport.BSPEntityData()) + 1;
	bspworld.dentdata = (char *) GetClearedHunkMemory(bspworld.entdatasize);
	Com_Memcpy(bspworld.dentdata, botimport.BSPEntityData(), bspworld.entdatasize);
	AAS_ParseBSPEntities();
	bspworld.loaded = qtrue;
	return BLERR_NOERROR;
} //end of the function AAS_LoadBSPFile


================================================
FILE: code/botlib/be_aas_cluster.c
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_cluster.c
 *
 * desc:		area clustering
 *
 * $Archive: /MissionPack/code/botlib/be_aas_cluster.c $
 *
 *****************************************************************************/

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_log.h"
#include "l_memory.h"
#include "l_libvar.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_aas_def.h"

extern botlib_import_t botimport;

#define AAS_MAX_PORTALS					65536
#define AAS_MAX_PORTALINDEXSIZE			65536
#define AAS_MAX_CLUSTERS				65536
//
#define MAX_PORTALAREAS			1024

// do not flood through area faces, only use reachabilities
int nofaceflood = qtrue;

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_RemoveClusterAreas(void)
{
	int i;

	for (i = 1; i < aasworld.numareas; i++)
	{
		aasworld.areasettings[i].cluster = 0;
	} //end for
} //end of the function AAS_RemoveClusterAreas
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ClearCluster(int clusternum)
{
	int i;

	for (i = 1; i < aasworld.numareas; i++)
	{
		if (aasworld.areasettings[i].cluster == clusternum)
		{
			aasworld.areasettings[i].cluster = 0;
		} //end if
	} //end for
} //end of the function AAS_ClearCluster
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_RemovePortalsClusterReference(int clusternum)
{
	int portalnum;

	for (portalnum = 1; portalnum < aasworld.numportals; portalnum++)
	{
		if (aasworld.portals[portalnum].frontcluster == clusternum)
		{
			aasworld.portals[portalnum].frontcluster = 0;
		} //end if
		if (aasworld.portals[portalnum].backcluster == clusternum)
		{
			aasworld.portals[portalnum].backcluster = 0;
		} //end if
	} //end for
} //end of the function AAS_RemovePortalsClusterReference
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_UpdatePortal(int areanum, int clusternum)
{
	int portalnum;
	aas_portal_t *portal;
	aas_cluster_t *cluster;

	//find the portal of the area
	for (portalnum = 1; portalnum < aasworld.numportals; portalnum++)
	{
		if (aasworld.portals[portalnum].areanum == areanum) break;
	} //end for
	//
	if (portalnum == aasworld.numportals)
	{
		AAS_Error("no portal of area %d", areanum);
		return qtrue;
	} //end if
	//
	portal = &aasworld.portals[portalnum];
	//if the portal is already fully updated
	if (portal->frontcluster == clusternum) return qtrue;
	if (portal->backcluster == clusternum) return qtrue;
	//if the portal has no front cluster yet
	if (!portal->frontcluster)
	{
		portal->frontcluster = clusternum;
	} //end if
	//if the portal has no back cluster yet
	else if (!portal->backcluster)
	{
		portal->backcluster = clusternum;
	} //end else if
	else
	{
		//remove the cluster portal flag contents
		aasworld.areasettings[areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;
		Log_Write("portal area %d is seperating more than two clusters\r\n", areanum);
		return qfalse;
	} //end else
	if (aasworld.portalindexsize >= AAS_MAX_PORTALINDEXSIZE)
	{
		AAS_Error("AAS_MAX_PORTALINDEXSIZE");
		return qtrue;
	} //end if
	//set the area cluster number to the negative portal number
	aasworld.areasettings[areanum].cluster = -portalnum;
	//add the portal to the cluster using the portal index
	cluster = &aasworld.clusters[clusternum];
	aasworld.portalindex[cluster->firstportal + cluster->numportals] = portalnum;
	aasworld.portalindexsize++;
	cluster->numportals++;
	return qtrue;
} //end of the function AAS_UpdatePortal
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_FloodClusterAreas_r(int areanum, int clusternum)
{
	aas_area_t *area;
	aas_face_t *face;
	int facenum, i;

	//
	if (areanum <= 0 || areanum >= aasworld.numareas)
	{
		AAS_Error("AAS_FloodClusterAreas_r: areanum out of range");
		return qfalse;
	} //end if
	//if the area is already part of a cluster
	if (aasworld.areasettings[areanum].cluster > 0)
	{
		if (aasworld.areasettings[areanum].cluster == clusternum) return qtrue;
		//
		//there's a reachability going from one cluster to another only in one direction
		//
		AAS_Error("cluster %d touched cluster %d at area %d\r\n",
				clusternum, aasworld.areasettings[areanum].cluster, areanum);
		return qfalse;
	} //end if
	//don't add the cluster portal areas to the clusters
	if (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL)
	{
		return AAS_UpdatePortal(areanum, clusternum);
	} //end if
	//set the area cluster number
	aasworld.areasettings[areanum].cluster = clusternum;
	aasworld.areasettings[areanum].clusterareanum =
				aasworld.clusters[clusternum].numareas;
	//the cluster has an extra area
	aasworld.clusters[clusternum].numareas++;

	area = &aasworld.areas[areanum];
	//use area faces to flood into adjacent areas
	if (!nofaceflood)
	{
		for (i = 0; i < area->numfaces; i++)
		{
			facenum = abs(aasworld.faceindex[area->firstface + i]);
			face = &aasworld.faces[facenum];
			if (face->frontarea == areanum)
			{
				if (face->backarea) if (!AAS_FloodClusterAreas_r(face->backarea, clusternum)) return qfalse;
			} //end if
			else
			{
				if (face->frontarea) if (!AAS_FloodClusterAreas_r(face->frontarea, clusternum)) return qfalse;
			} //end else
		} //end for
	} //end if
	//use the reachabilities to flood into other areas
	for (i = 0; i < aasworld.areasettings[areanum].numreachableareas; i++)
	{
		if (!aasworld.reachability[
					aasworld.areasettings[areanum].firstreachablearea + i].areanum)
		{
			continue;
		} //end if
		if (!AAS_FloodClusterAreas_r(aasworld.reachability[
				aasworld.areasettings[areanum].firstreachablearea + i].areanum, clusternum)) return qfalse;
	} //end for
	return qtrue;
} //end of the function AAS_FloodClusterAreas_r
//===========================================================================
// try to flood from all areas without cluster into areas with a cluster set
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_FloodClusterAreasUsingReachabilities(int clusternum)
{
	int i, j, areanum;

	for (i = 1; i < aasworld.numareas; i++)
	{
		//if this area already has a cluster set
		if (aasworld.areasettings[i].cluster)
			continue;
		//if this area is a cluster portal
		if (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)
			continue;
		//loop over the reachable areas from this area
		for (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)
		{
			//the reachable area
			areanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;
			//if this area is a cluster portal
			if (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL)
				continue;
			//if this area has a cluster set
			if (aasworld.areasettings[areanum].cluster)
			{
				if (!AAS_FloodClusterAreas_r(i, clusternum))
					return qfalse;
				i = 0;
				break;
			} //end if
		} //end for
	} //end for
	return qtrue;
} //end of the function AAS_FloodClusterAreasUsingReachabilities
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_NumberClusterPortals(int clusternum)
{
	int i, portalnum;
	aas_cluster_t *cluster;
	aas_portal_t *portal;

	cluster = &aasworld.clusters[clusternum];
	for (i = 0; i < cluster->numportals; i++)
	{
		portalnum = aasworld.portalindex[cluster->firstportal + i];
		portal = &aasworld.portals[portalnum];
		if (portal->frontcluster == clusternum)
		{
			portal->clusterareanum[0] = cluster->numareas++;
		} //end if
		else
		{
			portal->clusterareanum[1] = cluster->numareas++;
		} //end else
	} //end for
} //end of the function AAS_NumberClusterPortals
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_NumberClusterAreas(int clusternum)
{
	int i, portalnum;
	aas_cluster_t *cluster;
	aas_portal_t *portal;

	aasworld.clusters[clusternum].numareas = 0;
	aasworld.clusters[clusternum].numreachabilityareas = 0;
	//number all areas in this cluster WITH reachabilities
	for (i = 1; i < aasworld.numareas; i++)
	{
		//
		if (aasworld.areasettings[i].cluster != clusternum) continue;
		//
		if (!AAS_AreaReachability(i)) continue;
		//
		aasworld.areasettings[i].clusterareanum = aasworld.clusters[clusternum].numareas;
		//the cluster has an extra area
		aasworld.clusters[clusternum].numareas++;
		aasworld.clusters[clusternum].numreachabilityareas++;
	} //end for
	//number all portals in this cluster WITH reachabilities
	cluster = &aasworld.clusters[clusternum];
	for (i = 0; i < cluster->numportals; i++)
	{
		portalnum = aasworld.portalindex[cluster->firstportal + i];
		portal = &aasworld.portals[portalnum];
		if (!AAS_AreaReachability(portal->areanum)) continue;
		if (portal->frontcluster == clusternum)
		{
			portal->clusterareanum[0] = cluster->numareas++;
			aasworld.clusters[clusternum].numreachabilityareas++;
		} //end if
		else
		{
			portal->clusterareanum[1] = cluster->numareas++;
			aasworld.clusters[clusternum].numreachabilityareas++;
		} //end else
	} //end for
	//number all areas in this cluster WITHOUT reachabilities
	for (i = 1; i < aasworld.numareas; i++)
	{
		//
		if (aasworld.areasettings[i].cluster != clusternum) continue;
		//
		if (AAS_AreaReachability(i)) continue;
		//
		aasworld.areasettings[i].clusterareanum = aasworld.clusters[clusternum].numareas;
		//the cluster has an extra area
		aasworld.clusters[clusternum].numareas++;
	} //end for
	//number all portals in this cluster WITHOUT reachabilities
	cluster = &aasworld.clusters[clusternum];
	for (i = 0; i < cluster->numportals; i++)
	{
		portalnum = aasworld.portalindex[cluster->firstportal + i];
		portal = &aasworld.portals[portalnum];
		if (AAS_AreaReachability(portal->areanum)) continue;
		if (portal->frontcluster == clusternum)
		{
			portal->clusterareanum[0] = cluster->numareas++;
		} //end if
		else
		{
			portal->clusterareanum[1] = cluster->numareas++;
		} //end else
	} //end for
} //end of the function AAS_NumberClusterAreas
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
int AAS_FindClusters(void)
{
	int i;
	aas_cluster_t *cluster;

	AAS_RemoveClusterAreas();
	//
	for (i = 1; i < aasworld.numareas; i++)
	{
		//if the area is already part of a cluster
		if (aasworld.areasettings[i].cluster)
			continue;
		// if not flooding through faces only use areas that have reachabilities
		if (nofaceflood)
		{
			if (!aasworld.areasettings[i].numreachableareas)
				continue;
		} //end if
		//if the area is a cluster portal
		if (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)
			continue;
		if (aasworld.numclusters >= AAS_MAX_CLUSTERS)
		{
			AAS_Error("AAS_MAX_CLUSTERS");
			return qfalse;
		} //end if
		cluster = &aasworld.clusters[aasworld.numclusters];
		cluster->numareas = 0;
		cluster->numreachabilityareas = 0;
		cluster->firstportal = aasworld.portalindexsize;
		cluster->numportals = 0;
		//flood the areas in this cluster
		if (!AAS_FloodClusterAreas_r(i, aasworld.numclusters))
			return qfalse;
		if (!AAS_FloodClusterAreasUsingReachabilities(aasworld.numclusters))
			return qfalse;
		//number the cluster areas
		//AAS_NumberClusterPortals(aasworld.numclusters);
		AAS_NumberClusterAreas(aasworld.numclusters);
		//Log_Write("cluster %d has %d areas\r\n", aasworld.numclusters, cluster->numareas);
		aasworld.numclusters++;
	} //end for
	return qtrue;
} //end of the function AAS_FindClusters
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_CreatePortals(void)
{
	int i;
	aas_portal_t *portal;

	for (i = 1; i < aasworld.numareas; i++)
	{
		//if the area is a cluster portal
		if (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)
		{
			if (aasworld.numportals >= AAS_MAX_PORTALS)
			{
				AAS_Error("AAS_MAX_PORTALS");
				return;
			} //end if
			portal = &aasworld.portals[aasworld.numportals];
			portal->areanum = i;
			portal->frontcluster = 0;
			portal->backcluster = 0;
			aasworld.numportals++;
		} //end if
	} //end for
} //end of the function AAS_CreatePortals
/*
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_MapContainsTeleporters(void)
{
	bsp_entity_t *entities, *ent;
	char *classname;

	entities = AAS_ParseBSPEntities();

	for (ent = entities; ent; ent = ent->next)
	{
		classname = AAS_ValueForBSPEpairKey(ent, "classname");
		if (classname && !strcmp(classname, "misc_teleporter"))
		{
			AAS_FreeBSPEntities(entities);
			return qtrue;
		} //end if
	} //end for
	return qfalse;
} //end of the function AAS_MapContainsTeleporters
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_NonConvexFaces(aas_face_t *face1, aas_face_t *face2, int side1, int side2)
{
	int i, j, edgenum;
	aas_plane_t *plane1, *plane2;
	aas_edge_t *edge;
	

	plane1 = &aasworld.planes[face1->planenum ^ side1];
	plane2 = &aasworld.planes[face2->planenum ^ side2];

	//check if one of the points of face1 is at the back of the plane of face2
	for (i = 0; i < face1->numedges; i++)
	{
		edgenum = abs(aasworld.edgeindex[face1->firstedge + i]);
		edge = &aasworld.edges[edgenum];
		for (j = 0; j < 2; j++)
		{
			if (DotProduct(plane2->normal, aasworld.vertexes[edge->v[j]]) -
							plane2->dist < -0.01) return qtrue;
		} //end for
	} //end for
	for (i = 0; i < face2->numedges; i++)
	{
		edgenum = abs(aasworld.edgeindex[face2->firstedge + i]);
		edge = &aasworld.edges[edgenum];
		for (j = 0; j < 2; j++)
		{
			if (DotProduct(plane1->normal, aasworld.vertexes[edge->v[j]]) -
							plane1->dist < -0.01) return qtrue;
		} //end for
	} //end for

	return qfalse;
} //end of the function AAS_NonConvexFaces
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_CanMergeAreas(int *areanums, int numareas)
{
	int i, j, s, face1num, face2num, side1, side2, fn1, fn2;
	aas_face_t *face1, *face2;
	aas_area_t *area1, *area2;

	for (i = 0; i < numareas; i++)
	{
		area1 = &aasworld.areas[areanums[i]];
		for (fn1 = 0; fn1 < area1->numfaces; fn1++)
		{
			face1num = abs(aasworld.faceindex[area1->firstface + fn1]);
			face1 = &aasworld.faces[face1num];
			side1 = face1->frontarea != areanums[i];
			//check if the face isn't a shared one with one of the other areas
			for (s = 0; s < numareas; s++)
			{
				if (s == i) continue;
				if (face1->frontarea == s || face1->backarea == s) break;
			} //end for
			//if the face was a shared one
			if (s != numareas) continue;
			//
			for (j = 0; j < numareas; j++)
			{
				if (j == i) continue;
				area2 = &aasworld.areas[areanums[j]];
				for (fn2 = 0; fn2 < area2->numfaces; fn2++)
				{
					face2num = abs(aasworld.faceindex[area2->firstface + fn2]);
					face2 = &aasworld.faces[face2num];
					side2 = face2->frontarea != areanums[j];
					//check if the face isn't a shared one with one of the other areas
					for (s = 0; s < numareas; s++)
					{
						if (s == j) continue;
						if (face2->frontarea == s || face2->backarea == s) break;
					} //end for
					//if the face was a shared one
					if (s != numareas) continue;
					//
					if (AAS_NonConvexFaces(face1, face2, side1, side2)) return qfalse;
				} //end for
			} //end for
		} //end for
	} //end for
	return qtrue;
} //end of the function AAS_CanMergeAreas
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_NonConvexEdges(aas_edge_t *edge1, aas_edge_t *edge2, int side1, int side2, int planenum)
{
	int i;
	vec3_t edgevec1, edgevec2, normal1, normal2;
	float dist1, dist2;
	aas_plane_t *plane;

	plane = &aasworld.planes[planenum];
	VectorSubtract(aasworld.vertexes[edge1->v[1]], aasworld.vertexes[edge1->v[0]], edgevec1);
	VectorSubtract(aasworld.vertexes[edge2->v[1]], aasworld.vertexes[edge2->v[0]], edgevec2);
	if (side1) VectorInverse(edgevec1);
	if (side2) VectorInverse(edgevec2);
	//
	CrossProduct(edgevec1, plane->normal, normal1);
	dist1 = DotProduct(normal1, aasworld.vertexes[edge1->v[0]]);
	CrossProduct(edgevec2, plane->normal, normal2);
	dist2 = DotProduct(normal2, aasworld.vertexes[edge2->v[0]]);

	for (i = 0; i < 2; i++)
	{
		if (DotProduct(aasworld.vertexes[edge1->v[i]], normal2) - dist2 < -0.01) return qfalse;
	} //end for
	for (i = 0; i < 2; i++)
	{
		if (DotProduct(aasworld.vertexes[edge2->v[i]], normal1) - dist1 < -0.01) return qfalse;
	} //end for
	return qtrue;
} //end of the function AAS_NonConvexEdges
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_CanMergeFaces(int *facenums, int numfaces, int planenum)
{
	int i, j, s, edgenum1, edgenum2, side1, side2, en1, en2, ens;
	aas_face_t *face1, *face2, *otherface;
	aas_edge_t *edge1, *edge2;

	for (i = 0; i < numfaces; i++)
	{
		face1 = &aasworld.faces[facenums[i]];
		for (en1 = 0; en1 < face1->numedges; en1++)
		{
			edgenum1 = aasworld.edgeindex[face1->firstedge + en1];
			side1 = (edgenum1 < 0) ^ (face1->planenum != planenum);
			edgenum1 = abs(edgenum1);
			edge1 = &aasworld.edges[edgenum1];
			//check if the edge is shared with another face
			for (s = 0; s < numfaces; s++)
			{
				if (s == i) continue;
				otherface = &aasworld.faces[facenums[s]];
				for (ens = 0; ens < otherface->numedges; ens++)
				{
					if (edgenum1 == abs(aasworld.edgeindex[otherface->firstedge + ens])) break;
				} //end for
				if (ens != otherface->numedges) break;
			} //end for
			//if the edge was shared
			if (s != numfaces) continue;
			//
			for (j = 0; j < numfaces; j++)
			{
				if (j == i) continue;
				face2 = &aasworld.faces[facenums[j]];
				for (en2 = 0; en2 < face2->numedges; en2++)
				{
					edgenum2 = aasworld.edgeindex[face2->firstedge + en2];
					side2 = (edgenum2 < 0) ^ (face2->planenum != planenum);
					edgenum2 = abs(edgenum2);
					edge2 = &aasworld.edges[edgenum2];
					//check if the edge is shared with another face
					for (s = 0; s < numfaces; s++)
					{
						if (s == i) continue;
						otherface = &aasworld.faces[facenums[s]];
						for (ens = 0; ens < otherface->numedges; ens++)
						{
							if (edgenum2 == abs(aasworld.edgeindex[otherface->firstedge + ens])) break;
						} //end for
						if (ens != otherface->numedges) break;
					} //end for
					//if the edge was shared
					if (s != numfaces) continue;
					//
					if (AAS_NonConvexEdges(edge1, edge2, side1, side2, planenum)) return qfalse;
				} //end for
			} //end for
		} //end for
	} //end for
	return qtrue;
} //end of the function AAS_CanMergeFaces*/
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ConnectedAreas_r(int *areanums, int numareas, int *connectedareas, int curarea)
{
	int i, j, otherareanum, facenum;
	aas_area_t *area;
	aas_face_t *face;

	connectedareas[curarea] = qtrue;
	area = &aasworld.areas[areanums[curarea]];
	for (i = 0; i < area->numfaces; i++)
	{
		facenum = abs(aasworld.faceindex[area->firstface + i]);
		face = &aasworld.faces[facenum];
		//if the face is solid
		if (face->faceflags & FACE_SOLID) continue;
		//get the area at the other side of the face
		if (face->frontarea != areanums[curarea]) otherareanum = face->frontarea;
		else otherareanum = face->backarea;
		//check if the face is leading to one of the other areas
		for (j = 0; j < numareas; j++)
		{
			if (areanums[j] == otherareanum) break;
		} //end for
		//if the face isn't leading to one of the other areas
		if (j == numareas) continue;
		//if the other area is already connected
		if (connectedareas[j]) continue;
		//recursively proceed with the other area
		AAS_ConnectedAreas_r(areanums, numareas, connectedareas, j);
	} //end for
} //end of the function AAS_ConnectedAreas_r
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_ConnectedAreas(int *areanums, int numareas)
{
	int connectedareas[MAX_PORTALAREAS], i;

	Com_Memset(connectedareas, 0, sizeof(connectedareas));
	if (numareas < 1) return qfalse;
	if (numareas == 1) return qtrue;
	AAS_ConnectedAreas_r(areanums, numareas, connectedareas, 0);
	for (i = 0; i < numareas; i++)
	{
		if (!connectedareas[i]) return qfalse;
	} //end for
	return qtrue;
} //end of the function AAS_ConnectedAreas
//===========================================================================
// gets adjacent areas with less presence types recursively
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_GetAdjacentAreasWithLessPresenceTypes_r(int *areanums, int numareas, int curareanum)
{
	int i, j, presencetype, otherpresencetype, otherareanum, facenum;
	aas_area_t *area;
	aas_face_t *face;

	areanums[numareas++] = curareanum;
	area = &aasworld.areas[curareanum];
	presencetype = aasworld.areasettings[curareanum].presencetype;
	for (i = 0; i < area->numfaces; i++)
	{
		facenum = abs(aasworld.faceindex[area->firstface + i]);
		face = &aasworld.faces[facenum];
		//if the face is solid
		if (face->faceflags & FACE_SOLID) continue;
		//the area at the other side of the face
		if (face->frontarea != curareanum) otherareanum = face->frontarea;
		else otherareanum = face->backarea;
		//
		otherpresencetype = aasworld.areasettings[otherareanum].presencetype;
		//if the other area has less presence types
		if ((presencetype & ~otherpresencetype) &&
				!(otherpresencetype & ~presencetype))
		{
			//check if the other area isn't already in the list
			for (j = 0; j < numareas; j++)
			{
				if (otherareanum == areanums[j]) break;
			} //end for
			//if the other area isn't already in the list
			if (j == numareas)
			{
				if (numareas >= MAX_PORTALAREAS)
				{
					AAS_Error("MAX_PORTALAREAS");
					return numareas;
				} //end if
				numareas = AAS_GetAdjacentAreasWithLessPresenceTypes_r(areanums, numareas, otherareanum);
			} //end if
		} //end if
	} //end for
	return numareas;
} //end of the function AAS_GetAdjacentAreasWithLessPresenceTypes_r
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_CheckAreaForPossiblePortals(int areanum)
{
	int i, j, k, fen, ben, frontedgenum, backedgenum, facenum;
	int areanums[MAX_PORTALAREAS], numareas, otherareanum;
	int numareafrontfaces[MAX_PORTALAREAS], numareabackfaces[MAX_PORTALAREAS];
	int frontfacenums[MAX_PORTALAREAS], backfacenums[MAX_PORTALAREAS];
	int numfrontfaces, numbackfaces;
	int frontareanums[MAX_PORTALAREAS], backareanums[MAX_PORTALAREAS];
	int numfrontareas, numbackareas;
	int frontplanenum, backplanenum, faceplanenum;
	aas_area_t *area;
	aas_face_t *frontface, *backface, *face;

	//if it isn't already a portal
	if (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL) return 0;
	//it must be a grounded area
	if (!(aasworld.areasettings[areanum].areaflags & AREA_GROUNDED)) return 0;
	//
	Com_Memset(numareafrontfaces, 0, sizeof(numareafrontfaces));
	Com_Memset(numareabackfaces, 0, sizeof(numareabackfaces));
	numareas = numfrontfaces = numbackfaces = 0;
	numfrontareas = numbackareas = 0;
	frontplanenum = backplanenum = -1;
	//add any adjacent areas with less presence types
	numareas = AAS_GetAdjacentAreasWithLessPresenceTypes_r(areanums, 0, areanum);
	//
	for (i = 0; i < numareas; i++)
	{
		area = &aasworld.areas[areanums[i]];
		for (j = 0; j < area->numfaces; j++)
		{
			facenum = abs(aasworld.faceindex[area->firstface + j]);
			face = &aasworld.faces[facenum];
			//if the face is solid
			if (face->faceflags & FACE_SOLID) continue;
			//check if the face is shared with one of the other areas
			for (k = 0; k < numareas; k++)
			{
				if (k == i) continue;
				if (face->frontarea == areanums[k] || face->backarea == areanums[k]) break;
			} //end for
			//if the face is shared
			if (k != numareas) continue;
			//the number of the area at the other side of the face
			if (face->frontarea == areanums[i]) otherareanum = face->backarea;
			else otherareanum = face->frontarea;
			//if the other area already is a cluter portal
			if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) return 0;
			//number of the plane of the area
			faceplanenum = face->planenum & ~1;
			//
			if (frontplanenum < 0 || faceplanenum == frontplanenum)
			{
				frontplanenum = faceplanenum;
				frontfacenums[numfrontfaces++] = facenum;
				for (k = 0; k < numfrontareas; k++)
				{
					if (frontareanums[k] == otherareanum) break;
				} //end for
				if (k == numfrontareas) frontareanums[numfrontareas++] = otherareanum;
				numareafrontfaces[i]++;
			} //end if
			else if (backplanenum < 0 || faceplanenum == backplanenum)
			{
				backplanenum = faceplanenum;
				backfacenums[numbackfaces++] = facenum;
				for (k = 0; k < numbackareas; k++)
				{
					if (backareanums[k] == otherareanum) break;
				} //end for
				if (k == numbackareas) backareanums[numbackareas++] = otherareanum;
				numareabackfaces[i]++;
			} //end else
			else
			{
				return 0;
			} //end else
		} //end for
	} //end for
	//every area should have at least one front face and one back face
	for (i = 0; i < numareas; i++)
	{
		if (!numareafrontfaces[i] || !numareabackfaces[i]) return 0;
	} //end for
	//the front areas should all be connected
	if (!AAS_ConnectedAreas(frontareanums, numfrontareas)) return 0;
	//the back areas should all be connected
	if (!AAS_ConnectedAreas(backareanums, numbackareas)) return 0;
	//none of the front faces should have a shared edge with a back face
	for (i = 0; i < numfrontfaces; i++)
	{
		frontface = &aasworld.faces[frontfacenums[i]];
		for (fen = 0; fen < frontface->numedges; fen++)
		{
			frontedgenum = abs(aasworld.edgeindex[frontface->firstedge + fen]);
			for (j = 0; j < numbackfaces; j++)
			{
				backface = &aasworld.faces[backfacenums[j]];
				for (ben = 0; ben < backface->numedges; ben++)
				{
					backedgenum = abs(aasworld.edgeindex[backface->firstedge + ben]);
					if (frontedgenum == backedgenum) break;
				} //end for
				if (ben != backface->numedges) break;
			} //end for
			if (j != numbackfaces) break;
		} //end for
		if (fen != frontface->numedges) break;
	} //end for
	if (i != numfrontfaces) return 0;
	//set the cluster portal contents
	for (i = 0; i < numareas; i++)
	{
		aasworld.areasettings[areanums[i]].contents |= AREACONTENTS_CLUSTERPORTAL;
		//this area can be used as a route portal
		aasworld.areasettings[areanums[i]].contents |= AREACONTENTS_ROUTEPORTAL;
		Log_Write("possible portal: %d\r\n", areanums[i]);
	} //end for
	//
	return numareas;
} //end of the function AAS_CheckAreaForPossiblePortals
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_FindPossiblePortals(void)
{
	int i, numpossibleportals;

	numpossibleportals = 0;
	for (i = 1; i < aasworld.numareas; i++)
	{
		numpossibleportals += AAS_CheckAreaForPossiblePortals(i);
	} //end for
	botimport.Print(PRT_MESSAGE, "\r%6d possible portal areas\n", numpossibleportals);
} //end of the function AAS_FindPossiblePortals
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_RemoveAllPortals(void)
{
	int i;

	for (i = 1; i < aasworld.numareas; i++)
	{
		aasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;
	} //end for
} //end of the function AAS_RemoveAllPortals

#if 0
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_FloodCluster_r(int areanum, int clusternum)
{
	int i, otherareanum;
	aas_face_t *face;
	aas_area_t *area;

	//set cluster mark
	aasworld.areasettings[areanum].cluster = clusternum;
	//if the area is a portal
	//if (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL) return;
	//
	area = &aasworld.areas[areanum];
	//use area faces to flood into adjacent areas
	for (i = 0; i < area->numfaces; i++)
	{
		face = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];
		//
		if (face->frontarea != areanum) otherareanum = face->frontarea;
		else otherareanum = face->backarea;
		//if there's no area at the other side
		if (!otherareanum) continue;
		//if the area is a portal
		if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;
		//if the area is already marked
		if (aasworld.areasettings[otherareanum].cluster) continue;
		//
		AAS_FloodCluster_r(otherareanum, clusternum);
	} //end for
	//use the reachabilities to flood into other areas
	for (i = 0; i < aasworld.areasettings[areanum].numreachableareas; i++)
	{
		otherareanum = aasworld.reachability[
					aasworld.areasettings[areanum].firstreachablearea + i].areanum;
		if (!otherareanum)
		{
			continue;
			AAS_Error("reachability %d has zero area\n", aasworld.areasettings[areanum].firstreachablearea + i);
		} //end if
		//if the area is a portal
		if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;
		//if the area is already marked
		if (aasworld.areasettings[otherareanum].cluster) continue;
		//
		AAS_FloodCluster_r(otherareanum, clusternum);
	} //end for
} //end of the function AAS_FloodCluster_r
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_RemoveTeleporterPortals(void)
{
	int i, j, areanum;

	for (i = 1; i < aasworld.numareas; i++)
	{
		for (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)
		{
			areanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;
			if (aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].traveltype == TRAVEL_TELEPORT)
			{
				aasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;
				aasworld.areasettings[areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;
				break;
			} //end if
		} //end for
	} //end for
} //end of the function AAS_RemoveTeleporterPortals
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_FloodClusterReachabilities(int clusternum)
{
	int i, j, areanum;

	for (i = 1; i < aasworld.numareas; i++)
	{
		//if this area already has a cluster set
		if (aasworld.areasettings[i].cluster) continue;
		//if this area is a cluster portal
		if (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL) continue;
		//loop over the reachable areas from this area
		for (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)
		{
			//the reachable area
			areanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;
			//if this area is a cluster portal
			if (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;
			//if this area has a cluster set
			if (aasworld.areasettings[areanum].cluster == clusternum)
			{
				AAS_FloodCluster_r(i, clusternum);
				i = 0;
				break;
			} //end if
		} //end for
	} //end for
} //end of the function AAS_FloodClusterReachabilities

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_RemoveNotClusterClosingPortals(void)
{
	int i, j, k, facenum, otherareanum, nonclosingportals;
	aas_area_t *area;
	aas_face_t *face;

	AAS_RemoveTeleporterPortals();
	//
	nonclosingportals = 0;
	for (i = 1; i < aasworld.numareas; i++)
	{
		if (!(aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)) continue;
		//find a non-portal area adjacent to the portal area and flood
		//the cluster from there
		area = &aasworld.areas[i];
		for (j = 0; j < area->numfaces; j++)
		{
			facenum = abs(aasworld.faceindex[area->firstface + j]);
			face = &aasworld.faces[facenum];
			//
			if (face->frontarea != i) otherareanum = face->frontarea;
			else otherareanum = face->backarea;
			//
			if (!otherareanum) continue;
			//
			if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL)
			{
				continue;
			} //end if
			//reset all cluster fields
			AAS_RemoveClusterAreas();
			//
			AAS_FloodCluster_r(otherareanum, 1);
			AAS_FloodClusterReachabilities(1);
			//check if all adjacent non-portal areas have a cluster set
			for (k = 0; k < area->numfaces; k++)
			{
				facenum = abs(aasworld.faceindex[area->firstface + k]);
				face = &aasworld.faces[facenum];
				//
				if (face->frontarea != i) otherareanum = face->frontarea;
				else otherareanum = face->backarea;
				//
				if (!otherareanum) continue;
				//
				if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL)
				{
					continue;
				} //end if
				//
				if (!aasworld.areasettings[otherareanum].cluster) break;
			} //end for
			//if all adjacent non-portal areas have a cluster set then the portal
			//didn't seal a cluster
			if (k >= area->numfaces)
			{
				aasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;
				nonclosingportals++;
				//recheck all the other portals again
				i = 0;
				break;
			} //end if
		} //end for
	} //end for
	botimport.Print(PRT_MESSAGE, "\r%6d non closing portals removed\n", nonclosingportals);
} //end of the function AAS_RemoveNotClusterClosingPortals

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================

void AAS_RemoveNotClusterClosingPortals(void)
{
	int i, j, facenum, otherareanum, nonclosingportals, numseperatedclusters;
	aas_area_t *area;
	aas_face_t *face;

	AAS_RemoveTeleporterPortals();
	//
	nonclosingportals = 0;
	for (i = 1; i < aasworld.numareas; i++)
	{
		if (!(aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)) continue;
		//
		numseperatedclusters = 0;
		//reset all cluster fields
		AAS_RemoveClusterAreas();
		//find a non-portal area adjacent to the portal area and flood
		//the cluster from there
		area = &aasworld.areas[i];
		for (j = 0; j < area->numfaces; j++)
		{
			facenum = abs(aasworld.faceindex[area->firstface + j]);
			face = &aasworld.faces[facenum];
			//
			if (face->frontarea != i) otherareanum = face->frontarea;
			else otherareanum = face->backarea;
			//if not solid at the other side of the face
			if (!otherareanum) continue;
			//don't flood into other portals
			if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;
			//if the area already has a cluster set
			if (aasworld.areasettings[otherareanum].cluster) continue;
			//another cluster is seperated by this portal
			numseperatedclusters++;
			//flood the cluster
			AAS_FloodCluster_r(otherareanum, numseperatedclusters);
			AAS_FloodClusterReachabilities(numseperatedclusters);
		} //end for
		//use the reachabilities to flood into other areas
		for (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)
		{
			otherareanum = aasworld.reachability[
						aasworld.areasettings[i].firstreachablearea + j].areanum;
			//this should never be qtrue but we check anyway
			if (!otherareanum) continue;
			//don't flood into other portals
			if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL) continue;
			//if the area already has a cluster set
			if (aasworld.areasettings[otherareanum].cluster) continue;
			//another cluster is seperated by this portal
			numseperatedclusters++;
			//flood the cluster
			AAS_FloodCluster_r(otherareanum, numseperatedclusters);
			AAS_FloodClusterReachabilities(numseperatedclusters);
		} //end for
		//a portal must seperate no more and no less than 2 clusters
		if (numseperatedclusters != 2)
		{
			aasworld.areasettings[i].contents &= ~AREACONTENTS_CLUSTERPORTAL;
			nonclosingportals++;
			//recheck all the other portals again
			i = 0;
		} //end if
	} //end for
	botimport.Print(PRT_MESSAGE, "\r%6d non closing portals removed\n", nonclosingportals);
} //end of the function AAS_RemoveNotClusterClosingPortals

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================

void AAS_AddTeleporterPortals(void)
{
	int j, area2num, facenum, otherareanum;
	char *target, *targetname, *classname;
	bsp_entity_t *entities, *ent, *dest;
	vec3_t origin, destorigin, mins, maxs, end;
	vec3_t bbmins, bbmaxs;
	aas_area_t *area;
	aas_face_t *face;
	aas_trace_t trace;
	aas_link_t *areas, *link;

	entities = AAS_ParseBSPEntities();

	for (ent = entities; ent; ent = ent->next)
	{
		classname = AAS_ValueForBSPEpairKey(ent, "classname");
		if (classname && !strcmp(classname, "misc_teleporter"))
		{
			if (!AAS_VectorForBSPEpairKey(ent, "origin", origin))
			{
				botimport.Print(PRT_ERROR, "teleporter (%s) without origin\n", target);
				continue;
			} //end if
			//
			target = AAS_ValueForBSPEpairKey(ent, "target");
			if (!target)
			{
				botimport.Print(PRT_ERROR, "teleporter (%s) without target\n", target);
				continue;
			} //end if
			for (dest = entities; dest; dest = dest->next)
			{
				classname = AAS_ValueForBSPEpairKey(dest, "classname");
				if (classname && !strcmp(classname, "misc_teleporter_dest"))
				{
					targetname = AAS_ValueForBSPEpairKey(dest, "targetname");
					if (targetname && !strcmp(targetname, target))
					{
						break;
					} //end if
				} //end if
			} //end for
			if (!dest)
			{
				botimport.Print(PRT_ERROR, "teleporter without destination (%s)\n", target);
				continue;
			} //end if
			if (!AAS_VectorForBSPEpairKey(dest, "origin", destorigin))
			{
				botimport.Print(PRT_ERROR, "teleporter destination (%s) without origin\n", target);
				continue;
			} //end if
			destorigin[2] += 24; //just for q2e1m2, the dork has put the telepads in the ground
			VectorCopy(destorigin, end);
			end[2] -= 100;
			trace = AAS_TraceClientBBox(destorigin, end, PRESENCE_CROUCH, -1);
			if (trace.startsolid)
			{
				botimport.Print(PRT_ERROR, "teleporter destination (%s) in solid\n", target);
				continue;
			} //end if
			VectorCopy(trace.endpos, destorigin);
			area2num = AAS_PointAreaNum(destorigin);
			//reset all cluster fields
			for (j = 0; j < aasworld.numareas; j++)
			{
				aasworld.areasettings[j].cluster = 0;
			} //end for
			//
			VectorSet(mins, -8, -8, 8);
			VectorSet(maxs, 8, 8, 24);
			//
			AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bbmins, bbmaxs);
			//
			VectorAdd(origin, mins, mins);
			VectorAdd(origin, maxs, maxs);
			//add bounding box size
			VectorSubtract(mins, bbmaxs, mins);
			VectorSubtract(maxs, bbmins, maxs);
			//link an invalid (-1) entity
			areas = AAS_AASLinkEntity(mins, maxs, -1);
			//
			for (link = areas; link; link = link->next_area)
			{
				if (!AAS_AreaGrounded(link->areanum)) continue;
				//add the teleporter portal mark
				aasworld.areasettings[link->areanum].contents |= AREACONTENTS_CLUSTERPORTAL |
																			AREACONTENTS_TELEPORTAL;
			} //end for
			//
			for (link = areas; link; link = link->next_area)
			{
				if (!AAS_AreaGrounded(link->areanum)) continue;
				//find a non-portal area adjacent to the portal area and flood
				//the cluster from there
				area = &aasworld.areas[link->areanum];
				for (j = 0; j < area->numfaces; j++)
				{
					facenum = abs(aasworld.faceindex[area->firstface + j]);
					face = &aasworld.faces[facenum];
					//
					if (face->frontarea != link->areanum) otherareanum = face->frontarea;
					else otherareanum = face->backarea;
					//
					if (!otherareanum) continue;
					//
					if (aasworld.areasettings[otherareanum].contents & AREACONTENTS_CLUSTERPORTAL)
					{
						continue;
					} //end if
					//
					AAS_FloodCluster_r(otherareanum, 1);
				} //end for
			} //end for
			//if the teleport destination IS in the same cluster
			if (aasworld.areasettings[area2num].cluster)
			{
				for (link = areas; link; link = link->next_area)
				{
					if (!AAS_AreaGrounded(link->areanum)) continue;
					//add the teleporter portal mark
					aasworld.areasettings[link->areanum].contents &= ~(AREACONTENTS_CLUSTERPORTAL |
																				AREACONTENTS_TELEPORTAL);
				} //end for
			} //end if
		} //end if
	} //end for
	AAS_FreeBSPEntities(entities);
} //end of the function AAS_AddTeleporterPortals

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_AddTeleporterPortals(void)
{
	int i, j, areanum;

	for (i = 1; i < aasworld.numareas; i++)
	{
		for (j = 0; j < aasworld.areasettings[i].numreachableareas; j++)
		{
			if (aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].traveltype != TRAVEL_TELEPORT) continue;
			areanum = aasworld.reachability[aasworld.areasettings[i].firstreachablearea + j].areanum;
			aasworld.areasettings[areanum].contents |= AREACONTENTS_CLUSTERPORTAL;
		} //end for
	} //end for
} //end of the function AAS_AddTeleporterPortals

#endif

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_TestPortals(void)
{
	int i;
	aas_portal_t *portal;

	for (i = 1; i < aasworld.numportals; i++)
	{
		portal = &aasworld.portals[i];
		if (!portal->frontcluster)
		{
			aasworld.areasettings[portal->areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;
			Log_Write("portal area %d has no front cluster\r\n", portal->areanum);
			return qfalse;
		} //end if
		if (!portal->backcluster)
		{
			aasworld.areasettings[portal->areanum].contents &= ~AREACONTENTS_CLUSTERPORTAL;
			Log_Write("portal area %d has no back cluster\r\n", portal->areanum);
			return qfalse;
		} //end if
	} //end for
	return qtrue;
} //end of the function
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_CountForcedClusterPortals(void)
{
	int num, i;

	num = 0;
	for (i = 1; i < aasworld.numareas; i++)
	{
		if (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)
		{
			Log_Write("area %d is a forced portal area\r\n", i);
			num++;
		} //end if
	} //end for
	botimport.Print(PRT_MESSAGE, "%6d forced portal areas\n", num);
} //end of the function AAS_CountForcedClusterPortals
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_CreateViewPortals(void)
{
	int i;

	for (i = 1; i < aasworld.numareas; i++)
	{
		if (aasworld.areasettings[i].contents & AREACONTENTS_CLUSTERPORTAL)
		{
			aasworld.areasettings[i].contents |= AREACONTENTS_VIEWPORTAL;
		} //end if
	} //end for
} //end of the function AAS_CreateViewPortals
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_SetViewPortalsAsClusterPortals(void)
{
	int i;

	for (i = 1; i < aasworld.numareas; i++)
	{
		if (aasworld.areasettings[i].contents & AREACONTENTS_VIEWPORTAL)
		{
			aasworld.areasettings[i].contents |= AREACONTENTS_CLUSTERPORTAL;
		} //end if
	} //end for
} //end of the function AAS_SetViewPortalsAsClusterPortals
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_InitClustering(void)
{
	int i, removedPortalAreas;
	int n, total, numreachabilityareas;

	if (!aasworld.loaded) return;
	//if there are clusters
	if (aasworld.numclusters >= 1)
	{
#ifndef BSPC
		//if clustering isn't forced
		if (!((int)LibVarGetValue("forceclustering")) &&
			!((int)LibVarGetValue("forcereachability"))) return;
#endif
	} //end if
	//set all view portals as cluster portals in case we re-calculate the reachabilities and clusters (with -reach)
	AAS_SetViewPortalsAsClusterPortals();
	//count the number of forced cluster portals
	AAS_CountForcedClusterPortals();
	//remove all area cluster marks
	AAS_RemoveClusterAreas();
	//find possible cluster portals
	AAS_FindPossiblePortals();
	//craete portals to for the bot view
	AAS_CreateViewPortals();
	//remove all portals that are not closing a cluster
	//AAS_RemoveNotClusterClosingPortals();
	//initialize portal memory
	if (aasworld.portals) FreeMemory(aasworld.portals);
	aasworld.portals = (aas_portal_t *) GetClearedMemory(AAS_MAX_PORTALS * sizeof(aas_portal_t));
	//initialize portal index memory
	if (aasworld.portalindex) FreeMemory(aasworld.portalindex);
	aasworld.portalindex = (aas_portalindex_t *) GetClearedMemory(AAS_MAX_PORTALINDEXSIZE * sizeof(aas_portalindex_t));
	//initialize cluster memory
	if (aasworld.clusters) FreeMemory(aasworld.clusters);
	aasworld.clusters = (aas_cluster_t *) GetClearedMemory(AAS_MAX_CLUSTERS * sizeof(aas_cluster_t));
	//
	removedPortalAreas = 0;
	botimport.Print(PRT_MESSAGE, "\r%6d removed portal areas", removedPortalAreas);
	while(1)
	{
		botimport.Print(PRT_MESSAGE, "\r%6d", removedPortalAreas);
		//initialize the number of portals and clusters
		aasworld.numportals = 1;		//portal 0 is a dummy
		aasworld.portalindexsize = 0;
		aasworld.numclusters = 1;		//cluster 0 is a dummy
		//create the portals from the portal areas
		AAS_CreatePortals();
		//
		removedPortalAreas++;
		//find the clusters
		if (!AAS_FindClusters())
			continue;
		//test the portals
		if (!AAS_TestPortals())
			continue;
		//
		break;
	} //end while
	botimport.Print(PRT_MESSAGE, "\n");
	//the AAS file should be saved
	aasworld.savefile = qtrue;
	//write the portal areas to the log file
	for (i = 1; i < aasworld.numportals; i++)
	{
		Log_Write("portal %d: area %d\r\n", i, aasworld.portals[i].areanum);
	} //end for
	// report cluster info
	botimport.Print(PRT_MESSAGE, "%6d portals created\n", aasworld.numportals);
	botimport.Print(PRT_MESSAGE, "%6d clusters created\n", aasworld.numclusters);
	for (i = 1; i < aasworld.numclusters; i++)
	{
		botimport.Print(PRT_MESSAGE, "cluster %d has %d reachability areas\n", i,
				aasworld.clusters[i].numreachabilityareas);
	} //end for
	// report AAS file efficiency
	numreachabilityareas = 0;
	total = 0;
	for (i = 0; i < aasworld.numclusters; i++) {
		n = aasworld.clusters[i].numreachabilityareas;
		numreachabilityareas += n;
		total += n * n;
	}
	total += numreachabilityareas * aasworld.numportals;
	//
	botimport.Print(PRT_MESSAGE, "%6i total reachability areas\n", numreachabilityareas);
	botimport.Print(PRT_MESSAGE, "%6i AAS memory/CPU usage (the lower the better)\n", total * 3);
} //end of the function AAS_InitClustering


================================================
FILE: code/botlib/be_aas_cluster.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_cluster.h
 *
 * desc:		AAS
 *
 * $Archive: /source/code/botlib/be_aas_cluster.h $
 *
 *****************************************************************************/

#ifdef AASINTERN
//initialize the AAS clustering
void AAS_InitClustering(void);
//
void AAS_SetViewPortalsAsClusterPortals(void);
#endif //AASINTERN



================================================
FILE: code/botlib/be_aas_debug.c
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_debug.c
 *
 * desc:		AAS debug code
 *
 * $Archive: /MissionPack/code/botlib/be_aas_debug.c $
 *
 *****************************************************************************/

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_libvar.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_interface.h"
#include "be_aas_funcs.h"
#include "be_aas_def.h"

#define MAX_DEBUGLINES				1024
#define MAX_DEBUGPOLYGONS			8192

int debuglines[MAX_DEBUGLINES];
int debuglinevisible[MAX_DEBUGLINES];
int numdebuglines;

static int debugpolygons[MAX_DEBUGPOLYGONS];

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ClearShownPolygons(void)
{
	int i;
//*
	for (i = 0; i < MAX_DEBUGPOLYGONS; i++)
	{
		if (debugpolygons[i]) botimport.DebugPolygonDelete(debugpolygons[i]);
		debugpolygons[i] = 0;
	} //end for
//*/
/*
	for (i = 0; i < MAX_DEBUGPOLYGONS; i++)
	{
		botimport.DebugPolygonDelete(i);
		debugpolygons[i] = 0;
	} //end for
*/
} //end of the function AAS_ClearShownPolygons
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowPolygon(int color, int numpoints, vec3_t *points)
{
	int i;

	for (i = 0; i < MAX_DEBUGPOLYGONS; i++)
	{
		if (!debugpolygons[i])
		{
			debugpolygons[i] = botimport.DebugPolygonCreate(color, numpoints, points);
			break;
		} //end if
	} //end for
} //end of the function AAS_ShowPolygon
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ClearShownDebugLines(void)
{
	int i;

	//make all lines invisible
	for (i = 0; i < MAX_DEBUGLINES; i++)
	{
		if (debuglines[i])
		{
			//botimport.DebugLineShow(debuglines[i], NULL, NULL, LINECOLOR_NONE);
			botimport.DebugLineDelete(debuglines[i]);
			debuglines[i] = 0;
			debuglinevisible[i] = qfalse;
		} //end if
	} //end for
} //end of the function AAS_ClearShownDebugLines
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_DebugLine(vec3_t start, vec3_t end, int color)
{
	int line;

	for (line = 0; line < MAX_DEBUGLINES; line++)
	{
		if (!debuglines[line])
		{
			debuglines[line] = botimport.DebugLineCreate();
			debuglinevisible[line] = qfalse;
			numdebuglines++;
		} //end if
		if (!debuglinevisible[line])
		{
			botimport.DebugLineShow(debuglines[line], start, end, color);
			debuglinevisible[line] = qtrue;
			return;
		} //end else
	} //end for
} //end of the function AAS_DebugLine
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_PermanentLine(vec3_t start, vec3_t end, int color)
{
	int line;

	line = botimport.DebugLineCreate();
	botimport.DebugLineShow(line, start, end, color);
} //end of the function AAS_PermenentLine
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_DrawPermanentCross(vec3_t origin, float size, int color)
{
	int i, debugline;
	vec3_t start, end;

	for (i = 0; i < 3; i++)
	{
		VectorCopy(origin, start);
		start[i] += size;
		VectorCopy(origin, end);
		end[i] -= size;
		AAS_DebugLine(start, end, color);
		debugline = botimport.DebugLineCreate();
		botimport.DebugLineShow(debugline, start, end, color);
	} //end for
} //end of the function AAS_DrawPermanentCross
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color)
{
	int n0, n1, n2, j, line, lines[2];
	vec3_t start1, end1, start2, end2;

	//make a cross in the hit plane at the hit point
	VectorCopy(point, start1);
	VectorCopy(point, end1);
	VectorCopy(point, start2);
	VectorCopy(point, end2);

	n0 = type % 3;
	n1 = (type + 1) % 3;
	n2 = (type + 2) % 3;
	start1[n1] -= 6;
	start1[n2] -= 6;
	end1[n1] += 6;
	end1[n2] += 6;
	start2[n1] += 6;
	start2[n2] -= 6;
	end2[n1] -= 6;
	end2[n2] += 6;

	start1[n0] = (dist - (start1[n1] * normal[n1] +
				start1[n2] * normal[n2])) / normal[n0];
	end1[n0] = (dist - (end1[n1] * normal[n1] +
				end1[n2] * normal[n2])) / normal[n0];
	start2[n0] = (dist - (start2[n1] * normal[n1] +
				start2[n2] * normal[n2])) / normal[n0];
	end2[n0] = (dist - (end2[n1] * normal[n1] +
				end2[n2] * normal[n2])) / normal[n0];

	for (j = 0, line = 0; j < 2 && line < MAX_DEBUGLINES; line++)
	{
		if (!debuglines[line])
		{
			debuglines[line] = botimport.DebugLineCreate();
			lines[j++] = debuglines[line];
			debuglinevisible[line] = qtrue;
			numdebuglines++;
		} //end if
		else if (!debuglinevisible[line])
		{
			lines[j++] = debuglines[line];
			debuglinevisible[line] = qtrue;
		} //end else
	} //end for
	botimport.DebugLineShow(lines[0], start1, end1, color);
	botimport.DebugLineShow(lines[1], start2, end2, color);
} //end of the function AAS_DrawPlaneCross
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs)
{
	vec3_t bboxcorners[8];
	int lines[3];
	int i, j, line;

	//upper corners
	bboxcorners[0][0] = origin[0] + maxs[0];
	bboxcorners[0][1] = origin[1] + maxs[1];
	bboxcorners[0][2] = origin[2] + maxs[2];
	//
	bboxcorners[1][0] = origin[0] + mins[0];
	bboxcorners[1][1] = origin[1] + maxs[1];
	bboxcorners[1][2] = origin[2] + maxs[2];
	//
	bboxcorners[2][0] = origin[0] + mins[0];
	bboxcorners[2][1] = origin[1] + mins[1];
	bboxcorners[2][2] = origin[2] + maxs[2];
	//
	bboxcorners[3][0] = origin[0] + maxs[0];
	bboxcorners[3][1] = origin[1] + mins[1];
	bboxcorners[3][2] = origin[2] + maxs[2];
	//lower corners
	Com_Memcpy(bboxcorners[4], bboxcorners[0], sizeof(vec3_t) * 4);
	for (i = 0; i < 4; i++) bboxcorners[4 + i][2] = origin[2] + mins[2];
	//draw bounding box
	for (i = 0; i < 4; i++)
	{
		for (j = 0, line = 0; j < 3 && line < MAX_DEBUGLINES; line++)
		{
			if (!debuglines[line])
			{
				debuglines[line] = botimport.DebugLineCreate();
				lines[j++] = debuglines[line];
				debuglinevisible[line] = qtrue;
				numdebuglines++;
			} //end if
			else if (!debuglinevisible[line])
			{
				lines[j++] = debuglines[line];
				debuglinevisible[line] = qtrue;
			} //end else
		} //end for
		//top plane
		botimport.DebugLineShow(lines[0], bboxcorners[i],
									bboxcorners[(i+1)&3], LINECOLOR_RED);
		//bottom plane
		botimport.DebugLineShow(lines[1], bboxcorners[4+i],
									bboxcorners[4+((i+1)&3)], LINECOLOR_RED);
		//vertical lines
		botimport.DebugLineShow(lines[2], bboxcorners[i],
									bboxcorners[4+i], LINECOLOR_RED);
	} //end for
} //end of the function AAS_ShowBoundingBox
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowFace(int facenum)
{
	int i, color, edgenum;
	aas_edge_t *edge;
	aas_face_t *face;
	aas_plane_t *plane;
	vec3_t start, end;

	color = LINECOLOR_YELLOW;
	//check if face number is in range
	if (facenum >= aasworld.numfaces)
	{
		botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
	} //end if
	face = &aasworld.faces[facenum];
	//walk through the edges of the face
	for (i = 0; i < face->numedges; i++)
	{
		//edge number
		edgenum = abs(aasworld.edgeindex[face->firstedge + i]);
		//check if edge number is in range
		if (edgenum >= aasworld.numedges)
		{
			botimport.Print(PRT_ERROR, "edgenum %d out of range\n", edgenum);
		} //end if
		edge = &aasworld.edges[edgenum];
		if (color == LINECOLOR_RED) color = LINECOLOR_GREEN;
		else if (color == LINECOLOR_GREEN) color = LINECOLOR_BLUE;
		else if (color == LINECOLOR_BLUE) color = LINECOLOR_YELLOW;
		else color = LINECOLOR_RED;
		AAS_DebugLine(aasworld.vertexes[edge->v[0]],
										aasworld.vertexes[edge->v[1]],
										color);
	} //end for
	plane = &aasworld.planes[face->planenum];
	edgenum = abs(aasworld.edgeindex[face->firstedge]);
	edge = &aasworld.edges[edgenum];
	VectorCopy(aasworld.vertexes[edge->v[0]], start);
	VectorMA(start, 20, plane->normal, end);
	AAS_DebugLine(start, end, LINECOLOR_RED);
} //end of the function AAS_ShowFace
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowFacePolygon(int facenum, int color, int flip)
{
	int i, edgenum, numpoints;
	vec3_t points[128];
	aas_edge_t *edge;
	aas_face_t *face;

	//check if face number is in range
	if (facenum >= aasworld.numfaces)
	{
		botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
	} //end if
	face = &aasworld.faces[facenum];
	//walk through the edges of the face
	numpoints = 0;
	if (flip)
	{
		for (i = face->numedges-1; i >= 0; i--)
		{
			//edge number
			edgenum = aasworld.edgeindex[face->firstedge + i];
			edge = &aasworld.edges[abs(edgenum)];
			VectorCopy(aasworld.vertexes[edge->v[edgenum < 0]], points[numpoints]);
			numpoints++;
		} //end for
	} //end if
	else
	{
		for (i = 0; i < face->numedges; i++)
		{
			//edge number
			edgenum = aasworld.edgeindex[face->firstedge + i];
			edge = &aasworld.edges[abs(edgenum)];
			VectorCopy(aasworld.vertexes[edge->v[edgenum < 0]], points[numpoints]);
			numpoints++;
		} //end for
	} //end else
	AAS_ShowPolygon(color, numpoints, points);
} //end of the function AAS_ShowFacePolygon
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowArea(int areanum, int groundfacesonly)
{
	int areaedges[MAX_DEBUGLINES];
	int numareaedges, i, j, n, color = 0, line;
	int facenum, edgenum;
	aas_area_t *area;
	aas_face_t *face;
	aas_edge_t *edge;

	//
	numareaedges = 0;
	//
	if (areanum < 0 || areanum >= aasworld.numareas)
	{
		botimport.Print(PRT_ERROR, "area %d out of range [0, %d]\n",
								areanum, aasworld.numareas);
		return;
	} //end if
	//pointer to the convex area
	area = &aasworld.areas[areanum];
	//walk through the faces of the area
	for (i = 0; i < area->numfaces; i++)
	{
		facenum = abs(aasworld.faceindex[area->firstface + i]);
		//check if face number is in range
		if (facenum >= aasworld.numfaces)
		{
			botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
		} //end if
		face = &aasworld.faces[facenum];
		//ground faces only
		if (groundfacesonly)
		{
			if (!(face->faceflags & (FACE_GROUND | FACE_LADDER))) continue;
		} //end if
		//walk through the edges of the face
		for (j = 0; j < face->numedges; j++)
		{
			//edge number
			edgenum = abs(aasworld.edgeindex[face->firstedge + j]);
			//check if edge number is in range
			if (edgenum >= aasworld.numedges)
			{
				botimport.Print(PRT_ERROR, "edgenum %d out of range\n", edgenum);
			} //end if
			//check if the edge is stored already
			for (n = 0; n < numareaedges; n++)
			{
				if (areaedges[n] == edgenum) break;
			} //end for
			if (n == numareaedges && numareaedges < MAX_DEBUGLINES)
			{
				areaedges[numareaedges++] = edgenum;
			} //end if
		} //end for
		//AAS_ShowFace(facenum);
	} //end for
	//draw all the edges
	for (n = 0; n < numareaedges; n++)
	{
		for (line = 0; line < MAX_DEBUGLINES; line++)
		{
			if (!debuglines[line])
			{
				debuglines[line] = botimport.DebugLineCreate();
				debuglinevisible[line] = qfalse;
				numdebuglines++;
			} //end if
			if (!debuglinevisible[line])
			{
				break;
			} //end else
		} //end for
		if (line >= MAX_DEBUGLINES) return;
		edge = &aasworld.edges[areaedges[n]];
		if (color == LINECOLOR_RED) color = LINECOLOR_BLUE;
		else if (color == LINECOLOR_BLUE) color = LINECOLOR_GREEN;
		else if (color == LINECOLOR_GREEN) color = LINECOLOR_YELLOW;
		else color = LINECOLOR_RED;
		botimport.DebugLineShow(debuglines[line],
									aasworld.vertexes[edge->v[0]],
									aasworld.vertexes[edge->v[1]],
									color);
		debuglinevisible[line] = qtrue;
	} //end for*/
} //end of the function AAS_ShowArea
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly)
{
	int i, facenum;
	aas_area_t *area;
	aas_face_t *face;

	//
	if (areanum < 0 || areanum >= aasworld.numareas)
	{
		botimport.Print(PRT_ERROR, "area %d out of range [0, %d]\n",
								areanum, aasworld.numareas);
		return;
	} //end if
	//pointer to the convex area
	area = &aasworld.areas[areanum];
	//walk through the faces of the area
	for (i = 0; i < area->numfaces; i++)
	{
		facenum = abs(aasworld.faceindex[area->firstface + i]);
		//check if face number is in range
		if (facenum >= aasworld.numfaces)
		{
			botimport.Print(PRT_ERROR, "facenum %d out of range\n", facenum);
		} //end if
		face = &aasworld.faces[facenum];
		//ground faces only
		if (groundfacesonly)
		{
			if (!(face->faceflags & (FACE_GROUND | FACE_LADDER))) continue;
		} //end if
		AAS_ShowFacePolygon(facenum, color, face->frontarea != areanum);
	} //end for
} //end of the function AAS_ShowAreaPolygons
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_DrawCross(vec3_t origin, float size, int color)
{
	int i;
	vec3_t start, end;

	for (i = 0; i < 3; i++)
	{
		VectorCopy(origin, start);
		start[i] += size;
		VectorCopy(origin, end);
		end[i] -= size;
		AAS_DebugLine(start, end, color);
	} //end for
} //end of the function AAS_DrawCross
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_PrintTravelType(int traveltype)
{
#ifdef DEBUG
	char *str;
	//
	switch(traveltype & TRAVELTYPE_MASK)
	{
		case TRAVEL_INVALID: str = "TRAVEL_INVALID"; break;
		case TRAVEL_WALK: str = "TRAVEL_WALK"; break;
		case TRAVEL_CROUCH: str = "TRAVEL_CROUCH"; break;
		case TRAVEL_BARRIERJUMP: str = "TRAVEL_BARRIERJUMP"; break;
		case TRAVEL_JUMP: str = "TRAVEL_JUMP"; break;
		case TRAVEL_LADDER: str = "TRAVEL_LADDER"; break;
		case TRAVEL_WALKOFFLEDGE: str = "TRAVEL_WALKOFFLEDGE"; break;
		case TRAVEL_SWIM: str = "TRAVEL_SWIM"; break;
		case TRAVEL_WATERJUMP: str = "TRAVEL_WATERJUMP"; break;
		case TRAVEL_TELEPORT: str = "TRAVEL_TELEPORT"; break;
		case TRAVEL_ELEVATOR: str = "TRAVEL_ELEVATOR"; break;
		case TRAVEL_ROCKETJUMP: str = "TRAVEL_ROCKETJUMP"; break;
		case TRAVEL_BFGJUMP: str = "TRAVEL_BFGJUMP"; break;
		case TRAVEL_GRAPPLEHOOK: str = "TRAVEL_GRAPPLEHOOK"; break;
		case TRAVEL_JUMPPAD: str = "TRAVEL_JUMPPAD"; break;
		case TRAVEL_FUNCBOB: str = "TRAVEL_FUNCBOB"; break;
		default: str = "UNKNOWN TRAVEL TYPE"; break;
	} //end switch
	botimport.Print(PRT_MESSAGE, "%s", str);
#endif
} //end of the function AAS_PrintTravelType
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor)
{
	vec3_t dir, cross, p1, p2, up = {0, 0, 1};
	float dot;

	VectorSubtract(end, start, dir);
	VectorNormalize(dir);
	dot = DotProduct(dir, up);
	if (dot > 0.99 || dot < -0.99) VectorSet(cross, 1, 0, 0);
	else CrossProduct(dir, up, cross);

	VectorMA(end, -6, dir, p1);
	VectorCopy(p1, p2);
	VectorMA(p1, 6, cross, p1);
	VectorMA(p2, -6, cross, p2);

	AAS_DebugLine(start, end, linecolor);
	AAS_DebugLine(p1, end, arrowcolor);
	AAS_DebugLine(p2, end, arrowcolor);
} //end of the function AAS_DrawArrow
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowReachability(aas_reachability_t *reach)
{
	vec3_t dir, cmdmove, velocity;
	float speed, zvel;
	aas_clientmove_t move;

	AAS_ShowAreaPolygons(reach->areanum, 5, qtrue);
	//AAS_ShowArea(reach->areanum, qtrue);
	AAS_DrawArrow(reach->start, reach->end, LINECOLOR_BLUE, LINECOLOR_YELLOW);
	//
	if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP ||
		(reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE)
	{
		AAS_HorizontalVelocityForJump(aassettings.phys_jumpvel, reach->start, reach->end, &speed);
		//
		VectorSubtract(reach->end, reach->start, dir);
		dir[2] = 0;
		VectorNormalize(dir);
		//set the velocity
		VectorScale(dir, speed, velocity);
		//set the command movement
		VectorClear(cmdmove);
		cmdmove[2] = aassettings.phys_jumpvel;
		//
		AAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,
									velocity, cmdmove, 3, 30, 0.1f,
									SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|
									SE_ENTERLAVA|SE_HITGROUNDDAMAGE, 0, qtrue);
		//
		if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP)
		{
			AAS_JumpReachRunStart(reach, dir);
			AAS_DrawCross(dir, 4, LINECOLOR_BLUE);
		} //end if
	} //end if
	else if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_ROCKETJUMP)
	{
		zvel = AAS_RocketJumpZVelocity(reach->start);
		AAS_HorizontalVelocityForJump(zvel, reach->start, reach->end, &speed);
		//
		VectorSubtract(reach->end, reach->start, dir);
		dir[2] = 0;
		VectorNormalize(dir);
		//get command movement
		VectorScale(dir, speed, cmdmove);
		VectorSet(velocity, 0, 0, zvel);
		//
		AAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,
									velocity, cmdmove, 30, 30, 0.1f,
									SE_ENTERWATER|SE_ENTERSLIME|
									SE_ENTERLAVA|SE_HITGROUNDDAMAGE|
									SE_TOUCHJUMPPAD|SE_HITGROUNDAREA, reach->areanum, qtrue);
	} //end else if
	else if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD)
	{
		VectorSet(cmdmove, 0, 0, 0);
		//
		VectorSubtract(reach->end, reach->start, dir);
		dir[2] = 0;
		VectorNormalize(dir);
		//set the velocity
		//NOTE: the edgenum is the horizontal velocity
		VectorScale(dir, reach->edgenum, velocity);
		//NOTE: the facenum is the Z velocity
		velocity[2] = reach->facenum;
		//
		AAS_PredictClientMovement(&move, -1, reach->start, PRESENCE_NORMAL, qtrue,
									velocity, cmdmove, 30, 30, 0.1f,
									SE_ENTERWATER|SE_ENTERSLIME|
									SE_ENTERLAVA|SE_HITGROUNDDAMAGE|
									SE_TOUCHJUMPPAD|SE_HITGROUNDAREA, reach->areanum, qtrue);
	} //end else if
} //end of the function AAS_ShowReachability
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ShowReachableAreas(int areanum)
{
	aas_areasettings_t *settings;
	static aas_reachability_t reach;
	static int index, lastareanum;
	static float lasttime;

	if (areanum != lastareanum)
	{
		index = 0;
		lastareanum = areanum;
	} //end if
	settings = &aasworld.areasettings[areanum];
	//
	if (!settings->numreachableareas) return;
	//
	if (index >= settings->numreachableareas) index = 0;
	//
	if (AAS_Time() - lasttime > 1.5)
	{
		Com_Memcpy(&reach, &aasworld.reachability[settings->firstreachablearea + index], sizeof(aas_reachability_t));
		index++;
		lasttime = AAS_Time();
		AAS_PrintTravelType(reach.traveltype & TRAVELTYPE_MASK);
		botimport.Print(PRT_MESSAGE, "\n");
	} //end if
	AAS_ShowReachability(&reach);
} //end of the function ShowReachableAreas

void AAS_FloodAreas_r(int areanum, int cluster, int *done)
{
	int nextareanum, i, facenum;
	aas_area_t *area;
	aas_face_t *face;
	aas_areasettings_t *settings;
	aas_reachability_t *reach;

	AAS_ShowAreaPolygons(areanum, 1, qtrue);
	//pointer to the convex area
	area = &aasworld.areas[areanum];
	settings = &aasworld.areasettings[areanum];
	//walk through the faces of the area
	for (i = 0; i < area->numfaces; i++)
	{
		facenum = abs(aasworld.faceindex[area->firstface + i]);
		face = &aasworld.faces[facenum];
		if (face->frontarea == areanum)
			nextareanum = face->backarea;
		else
			nextareanum = face->frontarea;
		if (!nextareanum)
			continue;
		if (done[nextareanum])
			continue;
		done[nextareanum] = qtrue;
		if (aasworld.areasettings[nextareanum].contents & AREACONTENTS_VIEWPORTAL)
			continue;
		if (AAS_AreaCluster(nextareanum) != cluster)
			continue;
		AAS_FloodAreas_r(nextareanum, cluster, done);
	} //end for
	//
	for (i = 0; i < settings->numreachableareas; i++)
	{
		reach = &aasworld.reachability[settings->firstreachablearea + i];
		nextareanum = reach->areanum;
		if (!nextareanum)
			continue;
		if (done[nextareanum])
			continue;
		done[nextareanum] = qtrue;
		if (aasworld.areasettings[nextareanum].contents & AREACONTENTS_VIEWPORTAL)
			continue;
		if (AAS_AreaCluster(nextareanum) != cluster)
			continue;
		/*
		if ((reach->traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE)
		{
			AAS_DebugLine(reach->start, reach->end, 1);
		}
		*/
		AAS_FloodAreas_r(nextareanum, cluster, done);
	}
}

void AAS_FloodAreas(vec3_t origin)
{
	int areanum, cluster, *done;

	done = (int *) GetClearedMemory(aasworld.numareas * sizeof(int));
	areanum = AAS_PointAreaNum(origin);
	cluster = AAS_AreaCluster(areanum);
	AAS_FloodAreas_r(areanum, cluster, done);
}


================================================
FILE: code/botlib/be_aas_debug.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_debug.h
 *
 * desc:		AAS
 *
 * $Archive: /source/code/botlib/be_aas_debug.h $
 *
 *****************************************************************************/

//clear the shown debug lines
void AAS_ClearShownDebugLines(void);
//
void AAS_ClearShownPolygons(void);
//show a debug line
void AAS_DebugLine(vec3_t start, vec3_t end, int color);
//show a permenent line
void AAS_PermanentLine(vec3_t start, vec3_t end, int color);
//show a permanent cross
void AAS_DrawPermanentCross(vec3_t origin, float size, int color);
//draw a cross in the plane
void AAS_DrawPlaneCross(vec3_t point, vec3_t normal, float dist, int type, int color);
//show a bounding box
void AAS_ShowBoundingBox(vec3_t origin, vec3_t mins, vec3_t maxs);
//show a face
void AAS_ShowFace(int facenum);
//show an area
void AAS_ShowArea(int areanum, int groundfacesonly);
//
void AAS_ShowAreaPolygons(int areanum, int color, int groundfacesonly);
//draw a cros
void AAS_DrawCross(vec3_t origin, float size, int color);
//print the travel type
void AAS_PrintTravelType(int traveltype);
//draw an arrow
void AAS_DrawArrow(vec3_t start, vec3_t end, int linecolor, int arrowcolor);
//visualize the given reachability
void AAS_ShowReachability(struct aas_reachability_s *reach);
//show the reachable areas from the given area
void AAS_ShowReachableAreas(int areanum);



================================================
FILE: code/botlib/be_aas_def.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_def.h
 *
 * desc:		AAS
 *
 * $Archive: /source/code/botlib/be_aas_def.h $
 *
 *****************************************************************************/

//debugging on
#define AAS_DEBUG

#define MAX_CLIENTS			64
#define	MAX_MODELS			256		// these are sent over the net as 8 bits
#define	MAX_SOUNDS			256		// so they cannot be blindly increased
#define	MAX_CONFIGSTRINGS	1024

#define	CS_SCORES			32
#define	CS_MODELS			(CS_SCORES+MAX_CLIENTS)
#define	CS_SOUNDS			(CS_MODELS+MAX_MODELS)

#define DF_AASENTNUMBER(x)		(x - aasworld.entities)
#define DF_NUMBERAASENT(x)		(&aasworld.entities[x])
#define DF_AASENTCLIENT(x)		(x - aasworld.entities - 1)
#define DF_CLIENTAASENT(x)		(&aasworld.entities[x + 1])

#ifndef MAX_PATH
	#define MAX_PATH				MAX_QPATH
#endif

//string index (for model, sound and image index)
typedef struct aas_stringindex_s
{
	int numindexes;
	char **index;
} aas_stringindex_t;

//structure to link entities to areas and areas to entities
typedef struct aas_link_s
{
	int entnum;
	int areanum;
	struct aas_link_s *next_ent, *prev_ent;
	struct aas_link_s *next_area, *prev_area;
} aas_link_t;

//structure to link entities to leaves and leaves to entities
typedef struct bsp_link_s
{
	int entnum;
	int leafnum;
	struct bsp_link_s *next_ent, *prev_ent;
	struct bsp_link_s *next_leaf, *prev_leaf;
} bsp_link_t;

typedef struct bsp_entdata_s
{
	vec3_t origin;
	vec3_t angles;
	vec3_t absmins;
	vec3_t absmaxs;
	int solid;
	int modelnum;
} bsp_entdata_t;

//entity
typedef struct aas_entity_s
{
	//entity info
	aas_entityinfo_t i;
	//links into the AAS areas
	aas_link_t *areas;
	//links into the BSP leaves
	bsp_link_t *leaves;
} aas_entity_t;

typedef struct aas_settings_s
{
	vec3_t phys_gravitydirection;
	float phys_friction;
	float phys_stopspeed;
	float phys_gravity;
	float phys_waterfriction;
	float phys_watergravity;
	float phys_maxvelocity;
	float phys_maxwalkvelocity;
	float phys_maxcrouchvelocity;
	float phys_maxswimvelocity;
	float phys_walkaccelerate;
	float phys_airaccelerate;
	float phys_swimaccelerate;
	float phys_maxstep;
	float phys_maxsteepness;
	float phys_maxwaterjump;
	float phys_maxbarrier;
	float phys_jumpvel;
	float phys_falldelta5;
	float phys_falldelta10;
	float rs_waterjump;
	float rs_teleport;
	float rs_barrierjump;
	float rs_startcrouch;
	float rs_startgrapple;
	float rs_startwalkoffledge;
	float rs_startjump;
	float rs_rocketjump;
	float rs_bfgjump;
	float rs_jumppad;
	float rs_aircontrolledjumppad;
	float rs_funcbob;
	float rs_startelevator;
	float rs_falldamage5;
	float rs_falldamage10;
	float rs_maxfallheight;
	float rs_maxjumpfallheight;
} aas_settings_t;

#define CACHETYPE_PORTAL		0
#define CACHETYPE_AREA			1

//routing cache
typedef struct aas_routingcache_s
{
	byte type;									//portal or area cache
	float time;									//last time accessed or updated
	int size;									//size of the routing cache
	int cluster;								//cluster the cache is for
	int areanum;								//area the cache is created for
	vec3_t origin;								//origin within the area
	float starttraveltime;						//travel time to start with
	int travelflags;							//combinations of the travel flags
	struct aas_routingcache_s *prev, *next;
	struct aas_routingcache_s *time_prev, *time_next;
	unsigned char *reachabilities;				//reachabilities used for routing
	unsigned short int traveltimes[1];			//travel time for every area (variable sized)
} aas_routingcache_t;

//fields for the routing algorithm
typedef struct aas_routingupdate_s
{
	int cluster;
	int areanum;								//area number of the update
	vec3_t start;								//start point the area was entered
	unsigned short int tmptraveltime;			//temporary travel time
	unsigned short int *areatraveltimes;		//travel times within the area
	qboolean inlist;							//true if the update is in the list
	struct aas_routingupdate_s *next;
	struct aas_routingupdate_s *prev;
} aas_routingupdate_t;

//reversed reachability link
typedef struct aas_reversedlink_s
{
	int linknum;								//the aas_areareachability_t
	int areanum;								//reachable from this area
	struct aas_reversedlink_s *next;			//next link
} aas_reversedlink_t;

//reversed area reachability
typedef struct aas_reversedreachability_s
{
	int numlinks;
	aas_reversedlink_t *first;
} aas_reversedreachability_t;

//areas a reachability goes through
typedef struct aas_reachabilityareas_s
{
	int firstarea, numareas;
} aas_reachabilityareas_t;

typedef struct aas_s
{
	int loaded;									//true when an AAS file is loaded
	int initialized;							//true when AAS has been initialized
	int savefile;								//set true when file should be saved
	int bspchecksum;
	//current time
	float time;
	int numframes;
	//name of the aas file
	char filename[MAX_PATH];
	char mapname[MAX_PATH];
	//bounding boxes
	int numbboxes;
	aas_bbox_t *bboxes;
	//vertexes
	int numvertexes;
	aas_vertex_t *vertexes;
	//planes
	int numplanes;
	aas_plane_t *planes;
	//edges
	int numedges;
	aas_edge_t *edges;
	//edge index
	int edgeindexsize;
	aas_edgeindex_t *edgeindex;
	//faces
	int numfaces;
	aas_face_t *faces;
	//face index
	int faceindexsize;
	aas_faceindex_t *faceindex;
	//convex areas
	int numareas;
	aas_area_t *areas;
	//convex area settings
	int numareasettings;
	aas_areasettings_t *areasettings;
	//reachablity list
	int reachabilitysize;
	aas_reachability_t *reachability;
	//nodes of the bsp tree
	int numnodes;
	aas_node_t *nodes;
	//cluster portals
	int numportals;
	aas_portal_t *portals;
	//cluster portal index
	int portalindexsize;
	aas_portalindex_t *portalindex;
	//clusters
	int numclusters;
	aas_cluster_t *clusters;
	//
	int numreachabilityareas;
	float reachabilitytime;
	//enities linked in the areas
	aas_link_t *linkheap;						//heap with link structures
	int linkheapsize;							//size of the link heap
	aas_link_t *freelinks;						//first free link
	aas_link_t **arealinkedentities;			//entities linked into areas
	//entities
	int maxentities;
	int maxclients;
	aas_entity_t *entities;
	//string indexes
	char *configstrings[MAX_CONFIGSTRINGS];
	int indexessetup;
	//index to retrieve travel flag for a travel type
	int travelflagfortype[MAX_TRAVELTYPES];
	//travel flags for each area based on contents
	int *areacontentstravelflags;
	//routing update
	aas_routingupdate_t *areaupdate;
	aas_routingupdate_t *portalupdate;
	//number of routing updates during a frame (reset every frame)
	int frameroutingupdates;
	//reversed reachability links
	aas_reversedreachability_t *reversedreachability;
	//travel times within the areas
	unsigned short ***areatraveltimes;
	//array of size numclusters with cluster cache
	aas_routingcache_t ***clusterareacache;
	aas_routingcache_t **portalcache;
	//cache list sorted on time
	aas_routingcache_t *oldestcache;		// start of cache list sorted on time
	aas_routingcache_t *newestcache;		// end of cache list sorted on time
	//maximum travel time through portal areas
	int *portalmaxtraveltimes;
	//areas the reachabilities go through
	int *reachabilityareaindex;
	aas_reachabilityareas_t *reachabilityareas;
} aas_t;

#define AASINTERN

#ifndef BSPCINCLUDE

#include "be_aas_main.h"
#include "be_aas_entity.h"
#include "be_aas_sample.h"
#include "be_aas_cluster.h"
#include "be_aas_reach.h"
#include "be_aas_route.h"
#include "be_aas_routealt.h"
#include "be_aas_debug.h"
#include "be_aas_file.h"
#include "be_aas_optimize.h"
#include "be_aas_bsp.h"
#include "be_aas_move.h"

#endif //BSPCINCLUDE


================================================
FILE: code/botlib/be_aas_entity.c
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_entity.c
 *
 * desc:		AAS entities
 *
 * $Archive: /MissionPack/code/botlib/be_aas_entity.c $
 *
 *****************************************************************************/

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_utils.h"
#include "l_log.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
#include "be_aas_def.h"

#define MASK_SOLID		CONTENTS_PLAYERCLIP

//FIXME: these might change
enum {
	ET_GENERAL,
	ET_PLAYER,
	ET_ITEM,
	ET_MISSILE,
	ET_MOVER
};

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_UpdateEntity(int entnum, bot_entitystate_t *state)
{
	int relink;
	aas_entity_t *ent;
	vec3_t absmins, absmaxs;

	if (!aasworld.loaded)
	{
		botimport.Print(PRT_MESSAGE, "AAS_UpdateEntity: not loaded\n");
		return BLERR_NOAASFILE;
	} //end if

	ent = &aasworld.entities[entnum];

	if (!state) {
		//unlink the entity
		AAS_UnlinkFromAreas(ent->areas);
		//unlink the entity from the BSP leaves
		AAS_UnlinkFromBSPLeaves(ent->leaves);
		//
		ent->areas = NULL;
		//
		ent->leaves = NULL;
		return BLERR_NOERROR;
	}

	ent->i.update_time = AAS_Time() - ent->i.ltime;
	ent->i.type = state->type;
	ent->i.flags = state->flags;
	ent->i.ltime = AAS_Time();
	VectorCopy(ent->i.origin, ent->i.lastvisorigin);
	VectorCopy(state->old_origin, ent->i.old_origin);
	ent->i.solid = state->solid;
	ent->i.groundent = state->groundent;
	ent->i.modelindex = state->modelindex;
	ent->i.modelindex2 = state->modelindex2;
	ent->i.frame = state->frame;
	ent->i.event = state->event;
	ent->i.eventParm = state->eventParm;
	ent->i.powerups = state->powerups;
	ent->i.weapon = state->weapon;
	ent->i.legsAnim = state->legsAnim;
	ent->i.torsoAnim = state->torsoAnim;
	//number of the entity
	ent->i.number = entnum;
	//updated so set valid flag
	ent->i.valid = qtrue;
	//link everything the first frame
	if (aasworld.numframes == 1) relink = qtrue;
	else relink = qfalse;
	//
	if (ent->i.solid == SOLID_BSP)
	{
		//if the angles of the model changed
		if (!VectorCompare(state->angles, ent->i.angles))
		{
			VectorCopy(state->angles, ent->i.angles);
			relink = qtrue;
		} //end if
		//get the mins and maxs of the model
		//FIXME: rotate mins and maxs
		AAS_BSPModelMinsMaxsOrigin(ent->i.modelindex, ent->i.angles, ent->i.mins, ent->i.maxs, NULL);
	} //end if
	else if (ent->i.solid == SOLID_BBOX)
	{
		//if the bounding box size changed
		if (!VectorCompare(state->mins, ent->i.mins) ||
				!VectorCompare(state->maxs, ent->i.maxs))
		{
			VectorCopy(state->mins, ent->i.mins);
			VectorCopy(state->maxs, ent->i.maxs);
			relink = qtrue;
		} //end if
		VectorCopy(state->angles, ent->i.angles);
	} //end if
	//if the origin changed
	if (!VectorCompare(state->origin, ent->i.origin))
	{
		VectorCopy(state->origin, ent->i.origin);
		relink = qtrue;
	} //end if
	//if the entity should be relinked
	if (relink)
	{
		//don't link the world model
		if (entnum != ENTITYNUM_WORLD)
		{
			//absolute mins and maxs
			VectorAdd(ent->i.mins, ent->i.origin, absmins);
			VectorAdd(ent->i.maxs, ent->i.origin, absmaxs);
			//unlink the entity
			AAS_UnlinkFromAreas(ent->areas);
			//relink the entity to the AAS areas (use the larges bbox)
			ent->areas = AAS_LinkEntityClientBBox(absmins, absmaxs, entnum, PRESENCE_NORMAL);
			//unlink the entity from the BSP leaves
			AAS_UnlinkFromBSPLeaves(ent->leaves);
			//link the entity to the world BSP tree
			ent->leaves = AAS_BSPLinkEntity(absmins, absmaxs, entnum, 0);
		} //end if
	} //end if
	return BLERR_NOERROR;
} //end of the function AAS_UpdateEntity
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_EntityInfo(int entnum, aas_entityinfo_t *info)
{
	if (!aasworld.initialized)
	{
		botimport.Print(PRT_FATAL, "AAS_EntityInfo: aasworld not initialized\n");
		Com_Memset(info, 0, sizeof(aas_entityinfo_t));
		return;
	} //end if

	if (entnum < 0 || entnum >= aasworld.maxentities)
	{
		botimport.Print(PRT_FATAL, "AAS_EntityInfo: entnum %d out of range\n", entnum);
		Com_Memset(info, 0, sizeof(aas_entityinfo_t));
		return;
	} //end if

	Com_Memcpy(info, &aasworld.entities[entnum].i, sizeof(aas_entityinfo_t));
} //end of the function AAS_EntityInfo
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_EntityOrigin(int entnum, vec3_t origin)
{
	if (entnum < 0 || entnum >= aasworld.maxentities)
	{
		botimport.Print(PRT_FATAL, "AAS_EntityOrigin: entnum %d out of range\n", entnum);
		VectorClear(origin);
		return;
	} //end if

	VectorCopy(aasworld.entities[entnum].i.origin, origin);
} //end of the function AAS_EntityOrigin
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_EntityModelindex(int entnum)
{
	if (entnum < 0 || entnum >= aasworld.maxentities)
	{
		botimport.Print(PRT_FATAL, "AAS_EntityModelindex: entnum %d out of range\n", entnum);
		return 0;
	} //end if
	return aasworld.entities[entnum].i.modelindex;
} //end of the function AAS_EntityModelindex
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_EntityType(int entnum)
{
	if (!aasworld.initialized) return 0;

	if (entnum < 0 || entnum >= aasworld.maxentities)
	{
		botimport.Print(PRT_FATAL, "AAS_EntityType: entnum %d out of range\n", entnum);
		return 0;
	} //end if
	return aasworld.entities[entnum].i.type;
} //end of the AAS_EntityType
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_EntityModelNum(int entnum)
{
	if (!aasworld.initialized) return 0;

	if (entnum < 0 || entnum >= aasworld.maxentities)
	{
		botimport.Print(PRT_FATAL, "AAS_EntityModelNum: entnum %d out of range\n", entnum);
		return 0;
	} //end if
	return aasworld.entities[entnum].i.modelindex;
} //end of the function AAS_EntityModelNum
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin)
{
	int i;
	aas_entity_t *ent;

	for (i = 0; i < aasworld.maxentities; i++)
	{
		ent = &aasworld.entities[i];
		if (ent->i.type == ET_MOVER)
		{
			if (ent->i.modelindex == modelnum)
			{
				VectorCopy(ent->i.origin, origin);
				return qtrue;
			} //end if
		} //end if
	} //end for
	return qfalse;
} //end of the function AAS_OriginOfMoverWithModelNum
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs)
{
	aas_entity_t *ent;

	if (!aasworld.initialized) return;

	if (entnum < 0 || entnum >= aasworld.maxentities)
	{
		botimport.Print(PRT_FATAL, "AAS_EntitySize: entnum %d out of range\n", entnum);
		return;
	} //end if

	ent = &aasworld.entities[entnum];
	VectorCopy(ent->i.mins, mins);
	VectorCopy(ent->i.maxs, maxs);
} //end of the function AAS_EntitySize
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata)
{
	aas_entity_t *ent;

	ent = &aasworld.entities[entnum];
	VectorCopy(ent->i.origin, entdata->origin);
	VectorCopy(ent->i.angles, entdata->angles);
	VectorAdd(ent->i.origin, ent->i.mins, entdata->absmins);
	VectorAdd(ent->i.origin, ent->i.maxs, entdata->absmaxs);
	entdata->solid = ent->i.solid;
	entdata->modelnum = ent->i.modelindex - 1;
} //end of the function AAS_EntityBSPData
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ResetEntityLinks(void)
{
	int i;
	for (i = 0; i < aasworld.maxentities; i++)
	{
		aasworld.entities[i].areas = NULL;
		aasworld.entities[i].leaves = NULL;
	} //end for
} //end of the function AAS_ResetEntityLinks
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_InvalidateEntities(void)
{
	int i;
	for (i = 0; i < aasworld.maxentities; i++)
	{
		aasworld.entities[i].i.valid = qfalse;
		aasworld.entities[i].i.number = i;
	} //end for
} //end of the function AAS_InvalidateEntities
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_UnlinkInvalidEntities(void)
{
	int i;
	aas_entity_t *ent;

	for (i = 0; i < aasworld.maxentities; i++)
	{
		ent = &aasworld.entities[i];
		if (!ent->i.valid)
		{
			AAS_UnlinkFromAreas( ent->areas );
			ent->areas = NULL;
			AAS_UnlinkFromBSPLeaves( ent->leaves );
			ent->leaves = NULL;
		} //end for
	} //end for
} //end of the function AAS_UnlinkInvalidEntities
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_NearestEntity(vec3_t origin, int modelindex)
{
	int i, bestentnum;
	float dist, bestdist;
	aas_entity_t *ent;
	vec3_t dir;

	bestentnum = 0;
	bestdist = 99999;
	for (i = 0; i < aasworld.maxentities; i++)
	{
		ent = &aasworld.entities[i];
		if (ent->i.modelindex != modelindex) continue;
		VectorSubtract(ent->i.origin, origin, dir);
		if (abs(dir[0]) < 40)
		{
			if (abs(dir[1]) < 40)
			{
				dist = VectorLength(dir);
				if (dist < bestdist)
				{
					bestdist = dist;
					bestentnum = i;
				} //end if
			} //end if
		} //end if
	} //end for
	return bestentnum;
} //end of the function AAS_NearestEntity
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_BestReachableEntityArea(int entnum)
{
	aas_entity_t *ent;

	ent = &aasworld.entities[entnum];
	return AAS_BestReachableLinkArea(ent->areas);
} //end of the function AAS_BestReachableEntityArea
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
int AAS_NextEntity(int entnum)
{
	if (!aasworld.loaded) return 0;

	if (entnum < 0) entnum = -1;
	while(++entnum < aasworld.maxentities)
	{
		if (aasworld.entities[entnum].i.valid) return entnum;
	} //end while
	return 0;
} //end of the function AAS_NextEntity


================================================
FILE: code/botlib/be_aas_entity.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_entity.h
 *
 * desc:		AAS
 *
 * $Archive: /source/code/botlib/be_aas_entity.h $
 *
 *****************************************************************************/

#ifdef AASINTERN
//invalidates all entity infos
void AAS_InvalidateEntities(void);
//unlink not updated entities
void AAS_UnlinkInvalidEntities(void);
//resets the entity AAS and BSP links (sets areas and leaves pointers to NULL)
void AAS_ResetEntityLinks(void);
//updates an entity
int AAS_UpdateEntity(int ent, bot_entitystate_t *state);
//gives the entity data used for collision detection
void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata);
#endif //AASINTERN

//returns the size of the entity bounding box in mins and maxs
void AAS_EntitySize(int entnum, vec3_t mins, vec3_t maxs);
//returns the BSP model number of the entity
int AAS_EntityModelNum(int entnum);
//returns the origin of an entity with the given model number
int AAS_OriginOfMoverWithModelNum(int modelnum, vec3_t origin);
//returns the best reachable area the entity is situated in
int AAS_BestReachableEntityArea(int entnum);
//returns the info of the given entity
void AAS_EntityInfo(int entnum, aas_entityinfo_t *info);
//returns the next entity
int AAS_NextEntity(int entnum);
//returns the origin of the entity
void AAS_EntityOrigin(int entnum, vec3_t origin);
//returns the entity type
int AAS_EntityType(int entnum);
//returns the model index of the entity
int AAS_EntityModelindex(int entnum);



================================================
FILE: code/botlib/be_aas_file.c
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_file.c
 *
 * desc:		AAS file loading/writing
 *
 * $Archive: /MissionPack/code/botlib/be_aas_file.c $
 *
 *****************************************************************************/

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_libvar.h"
#include "l_utils.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
#include "be_aas_def.h"

//#define AASFILEDEBUG

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_SwapAASData(void)
{
	int i, j;
	//bounding boxes
	for (i = 0; i < aasworld.numbboxes; i++)
	{
		aasworld.bboxes[i].presencetype = LittleLong(aasworld.bboxes[i].presencetype);
		aasworld.bboxes[i].flags = LittleLong(aasworld.bboxes[i].flags);
		for (j = 0; j < 3; j++)
		{
			aasworld.bboxes[i].mins[j] = LittleLong(aasworld.bboxes[i].mins[j]);
			aasworld.bboxes[i].maxs[j] = LittleLong(aasworld.bboxes[i].maxs[j]);
		} //end for
	} //end for
	//vertexes
	for (i = 0; i < aasworld.numvertexes; i++)
	{
		for (j = 0; j < 3; j++)
			aasworld.vertexes[i][j] = LittleFloat(aasworld.vertexes[i][j]);
	} //end for
	//planes
	for (i = 0; i < aasworld.numplanes; i++)
	{
		for (j = 0; j < 3; j++)
			aasworld.planes[i].normal[j] = LittleFloat(aasworld.planes[i].normal[j]);
		aasworld.planes[i].dist = LittleFloat(aasworld.planes[i].dist);
		aasworld.planes[i].type = LittleLong(aasworld.planes[i].type);
	} //end for
	//edges
	for (i = 0; i < aasworld.numedges; i++)
	{
		aasworld.edges[i].v[0] = LittleLong(aasworld.edges[i].v[0]);
		aasworld.edges[i].v[1] = LittleLong(aasworld.edges[i].v[1]);
	} //end for
	//edgeindex
	for (i = 0; i < aasworld.edgeindexsize; i++)
	{
		aasworld.edgeindex[i] = LittleLong(aasworld.edgeindex[i]);
	} //end for
	//faces
	for (i = 0; i < aasworld.numfaces; i++)
	{
		aasworld.faces[i].planenum = LittleLong(aasworld.faces[i].planenum);
		aasworld.faces[i].faceflags = LittleLong(aasworld.faces[i].faceflags);
		aasworld.faces[i].numedges = LittleLong(aasworld.faces[i].numedges);
		aasworld.faces[i].firstedge = LittleLong(aasworld.faces[i].firstedge);
		aasworld.faces[i].frontarea = LittleLong(aasworld.faces[i].frontarea);
		aasworld.faces[i].backarea = LittleLong(aasworld.faces[i].backarea);
	} //end for
	//face index
	for (i = 0; i < aasworld.faceindexsize; i++)
	{
		aasworld.faceindex[i] = LittleLong(aasworld.faceindex[i]);
	} //end for
	//convex areas
	for (i = 0; i < aasworld.numareas; i++)
	{
		aasworld.areas[i].areanum = LittleLong(aasworld.areas[i].areanum);
		aasworld.areas[i].numfaces = LittleLong(aasworld.areas[i].numfaces);
		aasworld.areas[i].firstface = LittleLong(aasworld.areas[i].firstface);
		for (j = 0; j < 3; j++)
		{
			aasworld.areas[i].mins[j] = LittleFloat(aasworld.areas[i].mins[j]);
			aasworld.areas[i].maxs[j] = LittleFloat(aasworld.areas[i].maxs[j]);
			aasworld.areas[i].center[j] = LittleFloat(aasworld.areas[i].center[j]);
		} //end for
	} //end for
	//area settings
	for (i = 0; i < aasworld.numareasettings; i++)
	{
		aasworld.areasettings[i].contents = LittleLong(aasworld.areasettings[i].contents);
		aasworld.areasettings[i].areaflags = LittleLong(aasworld.areasettings[i].areaflags);
		aasworld.areasettings[i].presencetype = LittleLong(aasworld.areasettings[i].presencetype);
		aasworld.areasettings[i].cluster = LittleLong(aasworld.areasettings[i].cluster);
		aasworld.areasettings[i].clusterareanum = LittleLong(aasworld.areasettings[i].clusterareanum);
		aasworld.areasettings[i].numreachableareas = LittleLong(aasworld.areasettings[i].numreachableareas);
		aasworld.areasettings[i].firstreachablearea = LittleLong(aasworld.areasettings[i].firstreachablearea);
	} //end for
	//area reachability
	for (i = 0; i < aasworld.reachabilitysize; i++)
	{
		aasworld.reachability[i].areanum = LittleLong(aasworld.reachability[i].areanum);
		aasworld.reachability[i].facenum = LittleLong(aasworld.reachability[i].facenum);
		aasworld.reachability[i].edgenum = LittleLong(aasworld.reachability[i].edgenum);
		for (j = 0; j < 3; j++)
		{
			aasworld.reachability[i].start[j] = LittleFloat(aasworld.reachability[i].start[j]);
			aasworld.reachability[i].end[j] = LittleFloat(aasworld.reachability[i].end[j]);
		} //end for
		aasworld.reachability[i].traveltype = LittleLong(aasworld.reachability[i].traveltype);
		aasworld.reachability[i].traveltime = LittleShort(aasworld.reachability[i].traveltime);
	} //end for
	//nodes
	for (i = 0; i < aasworld.numnodes; i++)
	{
		aasworld.nodes[i].planenum = LittleLong(aasworld.nodes[i].planenum);
		aasworld.nodes[i].children[0] = LittleLong(aasworld.nodes[i].children[0]);
		aasworld.nodes[i].children[1] = LittleLong(aasworld.nodes[i].children[1]);
	} //end for
	//cluster portals
	for (i = 0; i < aasworld.numportals; i++)
	{
		aasworld.portals[i].areanum = LittleLong(aasworld.portals[i].areanum);
		aasworld.portals[i].frontcluster = LittleLong(aasworld.portals[i].frontcluster);
		aasworld.portals[i].backcluster = LittleLong(aasworld.portals[i].backcluster);
		aasworld.portals[i].clusterareanum[0] = LittleLong(aasworld.portals[i].clusterareanum[0]);
		aasworld.portals[i].clusterareanum[1] = LittleLong(aasworld.portals[i].clusterareanum[1]);
	} //end for
	//cluster portal index
	for (i = 0; i < aasworld.portalindexsize; i++)
	{
		aasworld.portalindex[i] = LittleLong(aasworld.portalindex[i]);
	} //end for
	//cluster
	for (i = 0; i < aasworld.numclusters; i++)
	{
		aasworld.clusters[i].numareas = LittleLong(aasworld.clusters[i].numareas);
		aasworld.clusters[i].numreachabilityareas = LittleLong(aasworld.clusters[i].numreachabilityareas);
		aasworld.clusters[i].numportals = LittleLong(aasworld.clusters[i].numportals);
		aasworld.clusters[i].firstportal = LittleLong(aasworld.clusters[i].firstportal);
	} //end for
} //end of the function AAS_SwapAASData
//===========================================================================
// dump the current loaded aas file
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_DumpAASData(void)
{
	aasworld.numbboxes = 0;
	if (aasworld.bboxes) FreeMemory(aasworld.bboxes);
	aasworld.bboxes = NULL;
	aasworld.numvertexes = 0;
	if (aasworld.vertexes) FreeMemory(aasworld.vertexes);
	aasworld.vertexes = NULL;
	aasworld.numplanes = 0;
	if (aasworld.planes) FreeMemory(aasworld.planes);
	aasworld.planes = NULL;
	aasworld.numedges = 0;
	if (aasworld.edges) FreeMemory(aasworld.edges);
	aasworld.edges = NULL;
	aasworld.edgeindexsize = 0;
	if (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);
	aasworld.edgeindex = NULL;
	aasworld.numfaces = 0;
	if (aasworld.faces) FreeMemory(aasworld.faces);
	aasworld.faces = NULL;
	aasworld.faceindexsize = 0;
	if (aasworld.faceindex) FreeMemory(aasworld.faceindex);
	aasworld.faceindex = NULL;
	aasworld.numareas = 0;
	if (aasworld.areas) FreeMemory(aasworld.areas);
	aasworld.areas = NULL;
	aasworld.numareasettings = 0;
	if (aasworld.areasettings) FreeMemory(aasworld.areasettings);
	aasworld.areasettings = NULL;
	aasworld.reachabilitysize = 0;
	if (aasworld.reachability) FreeMemory(aasworld.reachability);
	aasworld.reachability = NULL;
	aasworld.numnodes = 0;
	if (aasworld.nodes) FreeMemory(aasworld.nodes);
	aasworld.nodes = NULL;
	aasworld.numportals = 0;
	if (aasworld.portals) FreeMemory(aasworld.portals);
	aasworld.portals = NULL;
	aasworld.numportals = 0;
	if (aasworld.portalindex) FreeMemory(aasworld.portalindex);
	aasworld.portalindex = NULL;
	aasworld.portalindexsize = 0;
	if (aasworld.clusters) FreeMemory(aasworld.clusters);
	aasworld.clusters = NULL;
	aasworld.numclusters = 0;
	//
	aasworld.loaded = qfalse;
	aasworld.initialized = qfalse;
	aasworld.savefile = qfalse;
} //end of the function AAS_DumpAASData
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
#ifdef AASFILEDEBUG
void AAS_FileInfo(void)
{
	int i, n, optimized;

	botimport.Print(PRT_MESSAGE, "version = %d\n", AASVERSION);
	botimport.Print(PRT_MESSAGE, "numvertexes = %d\n", aasworld.numvertexes);
	botimport.Print(PRT_MESSAGE, "numplanes = %d\n", aasworld.numplanes);
	botimport.Print(PRT_MESSAGE, "numedges = %d\n", aasworld.numedges);
	botimport.Print(PRT_MESSAGE, "edgeindexsize = %d\n", aasworld.edgeindexsize);
	botimport.Print(PRT_MESSAGE, "numfaces = %d\n", aasworld.numfaces);
	botimport.Print(PRT_MESSAGE, "faceindexsize = %d\n", aasworld.faceindexsize);
	botimport.Print(PRT_MESSAGE, "numareas = %d\n", aasworld.numareas);
	botimport.Print(PRT_MESSAGE, "numareasettings = %d\n", aasworld.numareasettings);
	botimport.Print(PRT_MESSAGE, "reachabilitysize = %d\n", aasworld.reachabilitysize);
	botimport.Print(PRT_MESSAGE, "numnodes = %d\n", aasworld.numnodes);
	botimport.Print(PRT_MESSAGE, "numportals = %d\n", aasworld.numportals);
	botimport.Print(PRT_MESSAGE, "portalindexsize = %d\n", aasworld.portalindexsize);
	botimport.Print(PRT_MESSAGE, "numclusters = %d\n", aasworld.numclusters);
	//
	for (n = 0, i = 0; i < aasworld.numareasettings; i++)
	{
		if (aasworld.areasettings[i].areaflags & AREA_GROUNDED) n++;
	} //end for
	botimport.Print(PRT_MESSAGE, "num grounded areas = %d\n", n);
	//
	botimport.Print(PRT_MESSAGE, "planes size %d bytes\n", aasworld.numplanes * sizeof(aas_plane_t));
	botimport.Print(PRT_MESSAGE, "areas size %d bytes\n", aasworld.numareas * sizeof(aas_area_t));
	botimport.Print(PRT_MESSAGE, "areasettings size %d bytes\n", aasworld.numareasettings * sizeof(aas_areasettings_t));
	botimport.Print(PRT_MESSAGE, "nodes size %d bytes\n", aasworld.numnodes * sizeof(aas_node_t));
	botimport.Print(PRT_MESSAGE, "reachability size %d bytes\n", aasworld.reachabilitysize * sizeof(aas_reachability_t));
	botimport.Print(PRT_MESSAGE, "portals size %d bytes\n", aasworld.numportals * sizeof(aas_portal_t));
	botimport.Print(PRT_MESSAGE, "clusters size %d bytes\n", aasworld.numclusters * sizeof(aas_cluster_t));

	optimized = aasworld.numplanes * sizeof(aas_plane_t) +
					aasworld.numareas * sizeof(aas_area_t) +
					aasworld.numareasettings * sizeof(aas_areasettings_t) +
					aasworld.numnodes * sizeof(aas_node_t) +
					aasworld.reachabilitysize * sizeof(aas_reachability_t) +
					aasworld.numportals * sizeof(aas_portal_t) +
					aasworld.numclusters * sizeof(aas_cluster_t);
	botimport.Print(PRT_MESSAGE, "optimzed size %d KB\n", optimized >> 10);
} //end of the function AAS_FileInfo
#endif //AASFILEDEBUG
//===========================================================================
// allocate memory and read a lump of a AAS file
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
char *AAS_LoadAASLump(fileHandle_t fp, int offset, int length, int *lastoffset, int size)
{
	char *buf;
	//
	if (!length)
	{
		//just alloc a dummy
		return (char *) GetClearedHunkMemory(size+1);
	} //end if
	//seek to the data
	if (offset != *lastoffset)
	{
		botimport.Print(PRT_WARNING, "AAS file not sequentially read\n");
		if (botimport.FS_Seek(fp, offset, FS_SEEK_SET))
		{
			AAS_Error("can't seek to aas lump\n");
			AAS_DumpAASData();
			botimport.FS_FCloseFile(fp);
			return 0;
		} //end if
	} //end if
	//allocate memory
	buf = (char *) GetClearedHunkMemory(length+1);
	//read the data
	if (length)
	{
		botimport.FS_Read(buf, length, fp );
		*lastoffset += length;
	} //end if
	return buf;
} //end of the function AAS_LoadAASLump
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
void AAS_DData(unsigned char *data, int size)
{
	int i;

	for (i = 0; i < size; i++)
	{
		data[i] ^= (unsigned char) i * 119;
	} //end for
} //end of the function AAS_DData
//===========================================================================
// load an aas file
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
int AAS_LoadAASFile(char *filename)
{
	fileHandle_t fp;
	aas_header_t header;
	int offset, length, lastoffset;

	botimport.Print(PRT_MESSAGE, "trying to load %s\n", filename);
	//dump current loaded aas file
	AAS_DumpAASData();
	//open the file
	botimport.FS_FOpenFile( filename, &fp, FS_READ );
	if (!fp)
	{
		AAS_Error("can't open %s\n", filename);
		return BLERR_CANNOTOPENAASFILE;
	} //end if
	//read the header
	botimport.FS_Read(&header, sizeof(aas_header_t), fp );
	lastoffset = sizeof(aas_header_t);
	//check header identification
	header.ident = LittleLong(header.ident);
	if (header.ident != AASID)
	{
		AAS_Error("%s is not an AAS file\n", filename);
		botimport.FS_FCloseFile(fp);
		return BLERR_WRONGAASFILEID;
	} //end if
	//check the version
	header.version = LittleLong(header.version);
	//
	if (header.version != AASVERSION_OLD && header.version != AASVERSION)
	{
		AAS_Error("aas file %s is version %i, not %i\n", filename, header.version, AASVERSION);
		botimport.FS_FCloseFile(fp);
		return BLERR_WRONGAASFILEVERSION;
	} //end if
	//
	if (header.version == AASVERSION)
	{
		AAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8);
	} //end if
	//
	aasworld.bspchecksum = atoi(LibVarGetString( "sv_mapChecksum"));
	if (LittleLong(header.bspchecksum) != aasworld.bspchecksum)
	{
		AAS_Error("aas file %s is out of date\n", filename);
		botimport.FS_FCloseFile(fp);
		return BLERR_WRONGAASFILEVERSION;
	} //end if
	//load the lumps:
	//bounding boxes
	offset = LittleLong(header.lumps[AASLUMP_BBOXES].fileofs);
	length = LittleLong(header.lumps[AASLUMP_BBOXES].filelen);
	aasworld.bboxes = (aas_bbox_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_bbox_t));
	aasworld.numbboxes = length / sizeof(aas_bbox_t);
	if (aasworld.numbboxes && !aasworld.bboxes) return BLERR_CANNOTREADAASLUMP;
	//vertexes
	offset = LittleLong(header.lumps[AASLUMP_VERTEXES].fileofs);
	length = LittleLong(header.lumps[AASLUMP_VERTEXES].filelen);
	aasworld.vertexes = (aas_vertex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_vertex_t));
	aasworld.numvertexes = length / sizeof(aas_vertex_t);
	if (aasworld.numvertexes && !aasworld.vertexes) return BLERR_CANNOTREADAASLUMP;
	//planes
	offset = LittleLong(header.lumps[AASLUMP_PLANES].fileofs);
	length = LittleLong(header.lumps[AASLUMP_PLANES].filelen);
	aasworld.planes = (aas_plane_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_plane_t));
	aasworld.numplanes = length / sizeof(aas_plane_t);
	if (aasworld.numplanes && !aasworld.planes) return BLERR_CANNOTREADAASLUMP;
	//edges
	offset = LittleLong(header.lumps[AASLUMP_EDGES].fileofs);
	length = LittleLong(header.lumps[AASLUMP_EDGES].filelen);
	aasworld.edges = (aas_edge_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_edge_t));
	aasworld.numedges = length / sizeof(aas_edge_t);
	if (aasworld.numedges && !aasworld.edges) return BLERR_CANNOTREADAASLUMP;
	//edgeindex
	offset = LittleLong(header.lumps[AASLUMP_EDGEINDEX].fileofs);
	length = LittleLong(header.lumps[AASLUMP_EDGEINDEX].filelen);
	aasworld.edgeindex = (aas_edgeindex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_edgeindex_t));
	aasworld.edgeindexsize = length / sizeof(aas_edgeindex_t);
	if (aasworld.edgeindexsize && !aasworld.edgeindex) return BLERR_CANNOTREADAASLUMP;
	//faces
	offset = LittleLong(header.lumps[AASLUMP_FACES].fileofs);
	length = LittleLong(header.lumps[AASLUMP_FACES].filelen);
	aasworld.faces = (aas_face_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_face_t));
	aasworld.numfaces = length / sizeof(aas_face_t);
	if (aasworld.numfaces && !aasworld.faces) return BLERR_CANNOTREADAASLUMP;
	//faceindex
	offset = LittleLong(header.lumps[AASLUMP_FACEINDEX].fileofs);
	length = LittleLong(header.lumps[AASLUMP_FACEINDEX].filelen);
	aasworld.faceindex = (aas_faceindex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_faceindex_t));
	aasworld.faceindexsize = length / sizeof(aas_faceindex_t);
	if (aasworld.faceindexsize && !aasworld.faceindex) return BLERR_CANNOTREADAASLUMP;
	//convex areas
	offset = LittleLong(header.lumps[AASLUMP_AREAS].fileofs);
	length = LittleLong(header.lumps[AASLUMP_AREAS].filelen);
	aasworld.areas = (aas_area_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_area_t));
	aasworld.numareas = length / sizeof(aas_area_t);
	if (aasworld.numareas && !aasworld.areas) return BLERR_CANNOTREADAASLUMP;
	//area settings
	offset = LittleLong(header.lumps[AASLUMP_AREASETTINGS].fileofs);
	length = LittleLong(header.lumps[AASLUMP_AREASETTINGS].filelen);
	aasworld.areasettings = (aas_areasettings_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_areasettings_t));
	aasworld.numareasettings = length / sizeof(aas_areasettings_t);
	if (aasworld.numareasettings && !aasworld.areasettings) return BLERR_CANNOTREADAASLUMP;
	//reachability list
	offset = LittleLong(header.lumps[AASLUMP_REACHABILITY].fileofs);
	length = LittleLong(header.lumps[AASLUMP_REACHABILITY].filelen);
	aasworld.reachability = (aas_reachability_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_reachability_t));
	aasworld.reachabilitysize = length / sizeof(aas_reachability_t);
	if (aasworld.reachabilitysize && !aasworld.reachability) return BLERR_CANNOTREADAASLUMP;
	//nodes
	offset = LittleLong(header.lumps[AASLUMP_NODES].fileofs);
	length = LittleLong(header.lumps[AASLUMP_NODES].filelen);
	aasworld.nodes = (aas_node_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_node_t));
	aasworld.numnodes = length / sizeof(aas_node_t);
	if (aasworld.numnodes && !aasworld.nodes) return BLERR_CANNOTREADAASLUMP;
	//cluster portals
	offset = LittleLong(header.lumps[AASLUMP_PORTALS].fileofs);
	length = LittleLong(header.lumps[AASLUMP_PORTALS].filelen);
	aasworld.portals = (aas_portal_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_portal_t));
	aasworld.numportals = length / sizeof(aas_portal_t);
	if (aasworld.numportals && !aasworld.portals) return BLERR_CANNOTREADAASLUMP;
	//cluster portal index
	offset = LittleLong(header.lumps[AASLUMP_PORTALINDEX].fileofs);
	length = LittleLong(header.lumps[AASLUMP_PORTALINDEX].filelen);
	aasworld.portalindex = (aas_portalindex_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_portalindex_t));
	aasworld.portalindexsize = length / sizeof(aas_portalindex_t);
	if (aasworld.portalindexsize && !aasworld.portalindex) return BLERR_CANNOTREADAASLUMP;
	//clusters
	offset = LittleLong(header.lumps[AASLUMP_CLUSTERS].fileofs);
	length = LittleLong(header.lumps[AASLUMP_CLUSTERS].filelen);
	aasworld.clusters = (aas_cluster_t *) AAS_LoadAASLump(fp, offset, length, &lastoffset, sizeof(aas_cluster_t));
	aasworld.numclusters = length / sizeof(aas_cluster_t);
	if (aasworld.numclusters && !aasworld.clusters) return BLERR_CANNOTREADAASLUMP;
	//swap everything
	AAS_SwapAASData();
	//aas file is loaded
	aasworld.loaded = qtrue;
	//close the file
	botimport.FS_FCloseFile(fp);
	//
#ifdef AASFILEDEBUG
	AAS_FileInfo();
#endif //AASFILEDEBUG
	//
	return BLERR_NOERROR;
} //end of the function AAS_LoadAASFile
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
static int AAS_WriteAASLump_offset;

int AAS_WriteAASLump(fileHandle_t fp, aas_header_t *h, int lumpnum, void *data, int length)
{
	aas_lump_t *lump;

	lump = &h->lumps[lumpnum];
	
	lump->fileofs = LittleLong(AAS_WriteAASLump_offset);	//LittleLong(ftell(fp));
	lump->filelen = LittleLong(length);

	if (length > 0)
	{
		botimport.FS_Write(data, length, fp );
	} //end if

	AAS_WriteAASLump_offset += length;

	return qtrue;
} //end of the function AAS_WriteAASLump
//===========================================================================
// aas data is useless after writing to file because it is byte swapped
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean AAS_WriteAASFile(char *filename)
{
	aas_header_t header;
	fileHandle_t fp;

	botimport.Print(PRT_MESSAGE, "writing %s\n", filename);
	//swap the aas data
	AAS_SwapAASData();
	//initialize the file header
	Com_Memset(&header, 0, sizeof(aas_header_t));
	header.ident = LittleLong(AASID);
	header.version = LittleLong(AASVERSION);
	header.bspchecksum = LittleLong(aasworld.bspchecksum);
	//open a new file
	botimport.FS_FOpenFile( filename, &fp, FS_WRITE );
	if (!fp)
	{
		botimport.Print(PRT_ERROR, "error opening %s\n", filename);
		return qfalse;
	} //end if
	//write the header
	botimport.FS_Write(&header, sizeof(aas_header_t), fp);
	AAS_WriteAASLump_offset = sizeof(aas_header_t);
	//add the data lumps to the file
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_BBOXES, aasworld.bboxes,
		aasworld.numbboxes * sizeof(aas_bbox_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_VERTEXES, aasworld.vertexes,
		aasworld.numvertexes * sizeof(aas_vertex_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_PLANES, aasworld.planes,
		aasworld.numplanes * sizeof(aas_plane_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGES, aasworld.edges,
		aasworld.numedges * sizeof(aas_edge_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGEINDEX, aasworld.edgeindex,
		aasworld.edgeindexsize * sizeof(aas_edgeindex_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_FACES, aasworld.faces,
		aasworld.numfaces * sizeof(aas_face_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_FACEINDEX, aasworld.faceindex,
		aasworld.faceindexsize * sizeof(aas_faceindex_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_AREAS, aasworld.areas,
		aasworld.numareas * sizeof(aas_area_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_AREASETTINGS, aasworld.areasettings,
		aasworld.numareasettings * sizeof(aas_areasettings_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_REACHABILITY, aasworld.reachability,
		aasworld.reachabilitysize * sizeof(aas_reachability_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_NODES, aasworld.nodes,
		aasworld.numnodes * sizeof(aas_node_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALS, aasworld.portals,
		aasworld.numportals * sizeof(aas_portal_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_PORTALINDEX, aasworld.portalindex,
		aasworld.portalindexsize * sizeof(aas_portalindex_t))) return qfalse;
	if (!AAS_WriteAASLump(fp, &header, AASLUMP_CLUSTERS, aasworld.clusters,
		aasworld.numclusters * sizeof(aas_cluster_t))) return qfalse;
	//rewrite the header with the added lumps
	botimport.FS_Seek(fp, 0, FS_SEEK_SET);
	AAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8);
	botimport.FS_Write(&header, sizeof(aas_header_t), fp);
	//close the file
	botimport.FS_FCloseFile(fp);
	return qtrue;
} //end of the function AAS_WriteAASFile


================================================
FILE: code/botlib/be_aas_file.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_file.h
 *
 * desc:		AAS
 *
 * $Archive: /source/code/botlib/be_aas_file.h $
 *
 *****************************************************************************/

#ifdef AASINTERN
//loads the AAS file with the given name
int AAS_LoadAASFile(char *filename);
//writes an AAS file with the given name
qboolean AAS_WriteAASFile(char *filename);
//dumps the loaded AAS data
void AAS_DumpAASData(void);
//print AAS file information
void AAS_FileInfo(void);
#endif //AASINTERN



================================================
FILE: code/botlib/be_aas_funcs.h
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_funcs.h
 *
 * desc:		AAS
 *
 * $Archive: /source/code/botlib/be_aas_funcs.h $
 *
 *****************************************************************************/

#ifndef BSPCINCLUDE

#include "be_aas_main.h"
#include "be_aas_entity.h"
#include "be_aas_sample.h"
#include "be_aas_cluster.h"
#include "be_aas_reach.h"
#include "be_aas_route.h"
#include "be_aas_routealt.h"
#include "be_aas_debug.h"
#include "be_aas_file.h"
#include "be_aas_optimize.h"
#include "be_aas_bsp.h"
#include "be_aas_move.h"

#endif //BSPCINCLUDE


================================================
FILE: code/botlib/be_aas_main.c
================================================
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/

/*****************************************************************************
 * name:		be_aas_main.c
 *
 * desc:		AAS
 *
 * $Archive: /MissionPack/code/botlib/be_aas_main.c $
 *
 *****************************************************************************/

#include "../game/q_shared.h"
#include "l_memory.h"
#include "l_libvar.h"
#include "l_utils.h"
#include "l_script.h"
#include "l_precomp.h"
#include "l_struct.h"
#include "l_log.h"
#include "aasfile.h"
#include "../game/botlib.h"
#include "../game/be_aas.h"
#include "be_aas_funcs.h"
#include "be_interface.h"
#include "be_aas_def.h"

aas_t aasworld;

libvar_t *saveroutingcache;

//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void QDECL AAS_Error(char *fmt, ...)
{
	char str[1024];
	va_list arglist;

	va_start(arglist, fmt);
	vsprintf(str, fmt, arglist);
	va_end(arglist);
	botimport.Print(PRT_FATAL, str);
} //end of the function AAS_Error
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
char *AAS_StringFromIndex(char *indexname, char *stringindex[], int numindexes, int index)
{
	if (!aasworld.indexessetup)
	{
		botimport.Print(PRT_ERROR, "%s: index %d not setup\n", indexname, index);
		return "";
	} //end if
	if (index < 0 || index >= numindexes)
	{
		botimport.Print(PRT_ERROR, "%s: index %d out of range\n", indexname, index);
		return "";
	} //end if
	if (!stringindex[index])
	{
		if (index)
		{
			botimport.Print(PRT_ERROR, "%s: reference to unused index %d\n", indexname, index);
		} //end if
		return "";
	} //end if
	return stringindex[index];
} //end of the function AAS_StringFromIndex
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_IndexFromString(char *indexname, char *stringindex[], int numindexes, char *string)
{
	int i;
	if (!aasworld.indexessetup)
	{
		botimport.Print(PRT_ERROR, "%s: index not setup \"%s\"\n", indexname, string);
		return 0;
	} //end if
	for (i = 0; i < numindexes; i++)
	{
		if (!stringindex[i]) continue;
		if (!Q_stricmp(stringindex[i], string)) return i;
	} //end for
	return 0;
} //end of the function AAS_IndexFromString
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
char *AAS_ModelFromIndex(int index)
{
	return AAS_StringFromIndex("ModelFromIndex", &aasworld.configstrings[CS_MODELS], MAX_MODELS, index);
} //end of the function AAS_ModelFromIndex
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_IndexFromModel(char *modelname)
{
	return AAS_IndexFromString("IndexFromModel", &aasworld.configstrings[CS_MODELS], MAX_MODELS, modelname);
} //end of the function AAS_IndexFromModel
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_UpdateStringIndexes(int numconfigstrings, char *configstrings[])
{
	int i;
	//set string pointers and copy the strings
	for (i = 0; i < numconfigstrings; i++)
	{
		if (configstrings[i])
		{
			//if (aasworld.configstrings[i]) FreeMemory(aasworld.configstrings[i]);
			aasworld.configstrings[i] = (char *) GetMemory(strlen(configstrings[i]) + 1);
			strcpy(aasworld.configstrings[i], configstrings[i]);
		} //end if
	} //end for
	aasworld.indexessetup = qtrue;
} //end of the function AAS_UpdateStringIndexes
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_Loaded(void)
{
	return aasworld.loaded;
} //end of the function AAS_Loaded
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
int AAS_Initialized(void)
{
	return aasworld.initialized;
} //end of the function AAS_Initialized
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_SetInitialized(void)
{
	aasworld.initialized = qtrue;
	botimport.Print(PRT_MESSAGE, "AAS initialized.\n");
#ifdef DEBUG
	//create all the routing cache
	//AAS_CreateAllRoutingCache();
	//
	//AAS_RoutingInfo();
#endif
} //end of the function AAS_SetInitialized
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
void AAS_ContinueInit(float time)
{
	//if no AAS file loaded
	if (!aasworld.loaded) return;
	//if AAS is already initialized
	if (aasworld.initialized) return;
	//calculate reachability, if not finished return
	if (AAS_ContinueInitReachability(time)) return;
	//initialize clustering for the new map
	AAS_InitClustering();
	//if reachability has been calculated and an A
Download .txt
gitextract_s_acjfki/

├── COPYING.txt
├── README.txt
├── code/
│   ├── Construct
│   ├── Makefile
│   ├── botlib/
│   │   ├── aasfile.h
│   │   ├── be_aas_bsp.h
│   │   ├── be_aas_bspq3.c
│   │   ├── be_aas_cluster.c
│   │   ├── be_aas_cluster.h
│   │   ├── be_aas_debug.c
│   │   ├── be_aas_debug.h
│   │   ├── be_aas_def.h
│   │   ├── be_aas_entity.c
│   │   ├── be_aas_entity.h
│   │   ├── be_aas_file.c
│   │   ├── be_aas_file.h
│   │   ├── be_aas_funcs.h
│   │   ├── be_aas_main.c
│   │   ├── be_aas_main.h
│   │   ├── be_aas_move.c
│   │   ├── be_aas_move.h
│   │   ├── be_aas_optimize.c
│   │   ├── be_aas_optimize.h
│   │   ├── be_aas_reach.c
│   │   ├── be_aas_reach.h
│   │   ├── be_aas_route.c
│   │   ├── be_aas_route.h
│   │   ├── be_aas_routealt.c
│   │   ├── be_aas_routealt.h
│   │   ├── be_aas_sample.c
│   │   ├── be_aas_sample.h
│   │   ├── be_ai_char.c
│   │   ├── be_ai_chat.c
│   │   ├── be_ai_gen.c
│   │   ├── be_ai_goal.c
│   │   ├── be_ai_move.c
│   │   ├── be_ai_weap.c
│   │   ├── be_ai_weight.c
│   │   ├── be_ai_weight.h
│   │   ├── be_ea.c
│   │   ├── be_interface.c
│   │   ├── be_interface.h
│   │   ├── botlib.vcproj
│   │   ├── l_crc.c
│   │   ├── l_crc.h
│   │   ├── l_libvar.c
│   │   ├── l_libvar.h
│   │   ├── l_log.c
│   │   ├── l_log.h
│   │   ├── l_memory.c
│   │   ├── l_memory.h
│   │   ├── l_precomp.c
│   │   ├── l_precomp.h
│   │   ├── l_script.c
│   │   ├── l_script.h
│   │   ├── l_struct.c
│   │   ├── l_struct.h
│   │   ├── l_utils.h
│   │   ├── lcc.mak
│   │   └── linux-i386.mak
│   ├── bspc/
│   │   ├── Conscript
│   │   ├── Makefile
│   │   ├── _files.c
│   │   ├── aas_areamerging.c
│   │   ├── aas_areamerging.h
│   │   ├── aas_cfg.c
│   │   ├── aas_cfg.h
│   │   ├── aas_create.c
│   │   ├── aas_create.h
│   │   ├── aas_edgemelting.c
│   │   ├── aas_edgemelting.h
│   │   ├── aas_facemerging.c
│   │   ├── aas_facemerging.h
│   │   ├── aas_file.c
│   │   ├── aas_file.h
│   │   ├── aas_gsubdiv.c
│   │   ├── aas_gsubdiv.h
│   │   ├── aas_map.c
│   │   ├── aas_map.h
│   │   ├── aas_prunenodes.c
│   │   ├── aas_prunenodes.h
│   │   ├── aas_store.c
│   │   ├── aas_store.h
│   │   ├── aasfile.h
│   │   ├── be_aas_bspc.c
│   │   ├── be_aas_bspc.h
│   │   ├── brushbsp.c
│   │   ├── bspc.c
│   │   ├── bspc.sln
│   │   ├── bspc.vcproj
│   │   ├── cfgq3.c
│   │   ├── csg.c
│   │   ├── faces.c
│   │   ├── gldraw.c
│   │   ├── glfile.c
│   │   ├── l_bsp_ent.c
│   │   ├── l_bsp_ent.h
│   │   ├── l_bsp_hl.c
│   │   ├── l_bsp_hl.h
│   │   ├── l_bsp_q1.c
│   │   ├── l_bsp_q1.h
│   │   ├── l_bsp_q2.c
│   │   ├── l_bsp_q2.h
│   │   ├── l_bsp_q3.c
│   │   ├── l_bsp_q3.h
│   │   ├── l_bsp_sin.c
│   │   ├── l_bsp_sin.h
│   │   ├── l_cmd.c
│   │   ├── l_cmd.h
│   │   ├── l_log.c
│   │   ├── l_log.h
│   │   ├── l_math.c
│   │   ├── l_math.h
│   │   ├── l_mem.c
│   │   ├── l_mem.h
│   │   ├── l_poly.c
│   │   ├── l_poly.h
│   │   ├── l_qfiles.c
│   │   ├── l_qfiles.h
│   │   ├── l_threads.c
│   │   ├── l_threads.h
│   │   ├── l_utils.c
│   │   ├── l_utils.h
│   │   ├── lcc.mak
│   │   ├── leakfile.c
│   │   ├── linux-i386.mak
│   │   ├── map.c
│   │   ├── map_hl.c
│   │   ├── map_q1.c
│   │   ├── map_q2.c
│   │   ├── map_q3.c
│   │   ├── map_sin.c
│   │   ├── nodraw.c
│   │   ├── portals.c
│   │   ├── prtfile.c
│   │   ├── q2files.h
│   │   ├── q3files.h
│   │   ├── qbsp.h
│   │   ├── qfiles.h
│   │   ├── sinfiles.h
│   │   ├── tetrahedron.c
│   │   ├── tetrahedron.h
│   │   ├── textures.c
│   │   ├── tree.c
│   │   └── writebsp.c
│   ├── cgame/
│   │   ├── Conscript
│   │   ├── cg_consolecmds.c
│   │   ├── cg_draw.c
│   │   ├── cg_drawtools.c
│   │   ├── cg_effects.c
│   │   ├── cg_ents.c
│   │   ├── cg_event.c
│   │   ├── cg_info.c
│   │   ├── cg_local.h
│   │   ├── cg_localents.c
│   │   ├── cg_main.c
│   │   ├── cg_marks.c
│   │   ├── cg_newdraw.c
│   │   ├── cg_particles.c
│   │   ├── cg_players.c
│   │   ├── cg_playerstate.c
│   │   ├── cg_predict.c
│   │   ├── cg_public.h
│   │   ├── cg_scoreboard.c
│   │   ├── cg_servercmds.c
│   │   ├── cg_snapshot.c
│   │   ├── cg_syscalls.asm
│   │   ├── cg_syscalls.c
│   │   ├── cg_view.c
│   │   ├── cg_weapons.c
│   │   ├── cgame.bat
│   │   ├── cgame.def
│   │   ├── cgame.plg
│   │   ├── cgame.q3asm
│   │   ├── cgame.sh
│   │   ├── cgame.vcproj
│   │   ├── cgame_ta.bat
│   │   ├── cgame_ta.q3asm
│   │   ├── cgame_ta.sh
│   │   └── tr_types.h
│   ├── cgame.lnt
│   ├── clean.bat
│   ├── client/
│   │   ├── cl_cgame.c
│   │   ├── cl_cin.c
│   │   ├── cl_console.c
│   │   ├── cl_input.c
│   │   ├── cl_keys.c
│   │   ├── cl_main.c
│   │   ├── cl_net_chan.c
│   │   ├── cl_parse.c
│   │   ├── cl_scrn.c
│   │   ├── cl_ui.c
│   │   ├── client.h
│   │   ├── keys.h
│   │   ├── snd_adpcm.c
│   │   ├── snd_dma.c
│   │   ├── snd_local.h
│   │   ├── snd_mem.c
│   │   ├── snd_mix.c
│   │   ├── snd_public.h
│   │   └── snd_wavelet.c
│   ├── game/
│   │   ├── Conscript
│   │   ├── ai_chat.c
│   │   ├── ai_chat.h
│   │   ├── ai_cmd.c
│   │   ├── ai_cmd.h
│   │   ├── ai_dmnet.c
│   │   ├── ai_dmnet.h
│   │   ├── ai_dmq3.c
│   │   ├── ai_dmq3.h
│   │   ├── ai_main.c
│   │   ├── ai_main.h
│   │   ├── ai_team.c
│   │   ├── ai_team.h
│   │   ├── ai_vcmd.c
│   │   ├── ai_vcmd.h
│   │   ├── be_aas.h
│   │   ├── be_ai_char.h
│   │   ├── be_ai_chat.h
│   │   ├── be_ai_gen.h
│   │   ├── be_ai_goal.h
│   │   ├── be_ai_move.h
│   │   ├── be_ai_weap.h
│   │   ├── be_ea.h
│   │   ├── bg_lib.c
│   │   ├── bg_lib.h
│   │   ├── bg_local.h
│   │   ├── bg_misc.c
│   │   ├── bg_pmove.c
│   │   ├── bg_public.h
│   │   ├── bg_slidemove.c
│   │   ├── botlib.h
│   │   ├── chars.h
│   │   ├── g_active.c
│   │   ├── g_arenas.c
│   │   ├── g_bot.c
│   │   ├── g_client.c
│   │   ├── g_cmds.c
│   │   ├── g_combat.c
│   │   ├── g_items.c
│   │   ├── g_local.h
│   │   ├── g_main.c
│   │   ├── g_mem.c
│   │   ├── g_misc.c
│   │   ├── g_missile.c
│   │   ├── g_mover.c
│   │   ├── g_public.h
│   │   ├── g_rankings.c
│   │   ├── g_rankings.h
│   │   ├── g_session.c
│   │   ├── g_spawn.c
│   │   ├── g_svcmds.c
│   │   ├── g_syscalls.asm
│   │   ├── g_syscalls.c
│   │   ├── g_target.c
│   │   ├── g_team.c
│   │   ├── g_team.h
│   │   ├── g_trigger.c
│   │   ├── g_utils.c
│   │   ├── g_weapon.c
│   │   ├── game.bat
│   │   ├── game.def
│   │   ├── game.q3asm
│   │   ├── game.sh
│   │   ├── game.vcproj
│   │   ├── game_ta.bat
│   │   ├── game_ta.q3asm
│   │   ├── game_ta.sh
│   │   ├── inv.h
│   │   ├── match.h
│   │   ├── q_math.c
│   │   ├── q_shared.c
│   │   ├── q_shared.h
│   │   ├── surfaceflags.h
│   │   └── syn.h
│   ├── game.lnt
│   ├── installdebug.bat
│   ├── installrelease.bat
│   ├── installvms.bat
│   ├── jpeg-6/
│   │   ├── README
│   │   ├── jcapimin.c
│   │   ├── jcapistd.c
│   │   ├── jccoefct.c
│   │   ├── jccolor.c
│   │   ├── jcdctmgr.c
│   │   ├── jchuff.c
│   │   ├── jchuff.h
│   │   ├── jcinit.c
│   │   ├── jcmainct.c
│   │   ├── jcmarker.c
│   │   ├── jcmaster.c
│   │   ├── jcomapi.c
│   │   ├── jconfig.h
│   │   ├── jcparam.c
│   │   ├── jcphuff.c
│   │   ├── jcprepct.c
│   │   ├── jcsample.c
│   │   ├── jctrans.c
│   │   ├── jdapimin.c
│   │   ├── jdapistd.c
│   │   ├── jdatadst.c
│   │   ├── jdatasrc.c
│   │   ├── jdcoefct.c
│   │   ├── jdcolor.c
│   │   ├── jdct.h
│   │   ├── jddctmgr.c
│   │   ├── jdhuff.c
│   │   ├── jdhuff.h
│   │   ├── jdinput.c
│   │   ├── jdmainct.c
│   │   ├── jdmarker.c
│   │   ├── jdmaster.c
│   │   ├── jdmerge.c
│   │   ├── jdphuff.c
│   │   ├── jdpostct.c
│   │   ├── jdsample.c
│   │   ├── jdtrans.c
│   │   ├── jerror.c
│   │   ├── jerror.h
│   │   ├── jfdctflt.c
│   │   ├── jfdctfst.c
│   │   ├── jfdctint.c
│   │   ├── jidctflt.c
│   │   ├── jidctfst.c
│   │   ├── jidctint.c
│   │   ├── jidctred.c
│   │   ├── jinclude.h
│   │   ├── jload.c
│   │   ├── jmemansi.c
│   │   ├── jmemdos.c
│   │   ├── jmemmgr.c
│   │   ├── jmemname.c
│   │   ├── jmemnobs.c
│   │   ├── jmemsys.h
│   │   ├── jmorecfg.h
│   │   ├── jpegint.h
│   │   ├── jpeglib.h
│   │   ├── jpegtran.c
│   │   ├── jquant1.c
│   │   ├── jquant2.c
│   │   ├── jutils.c
│   │   └── jversion.h
│   ├── macosx/
│   │   ├── BuildRelease
│   │   ├── CGMouseDeltaFix.h
│   │   ├── CGMouseDeltaFix.m
│   │   ├── CGPrivateAPI.h
│   │   ├── GenerateQGL.pl
│   │   ├── Performance.rtf
│   │   ├── Q3Controller.h
│   │   ├── Q3Controller.m
│   │   ├── Quake3.icns
│   │   ├── Quake3.nib/
│   │   │   ├── classes.nib
│   │   │   ├── info.nib
│   │   │   └── objects.nib
│   │   ├── Quake3.pbproj/
│   │   │   ├── apple.pbxuser
│   │   │   └── project.pbxproj
│   │   ├── RecordDemo.zsh
│   │   ├── botlib.log
│   │   ├── macosx_display.h
│   │   ├── macosx_display.m
│   │   ├── macosx_glimp.h
│   │   ├── macosx_glimp.m
│   │   ├── macosx_glsmp_mutex.m
│   │   ├── macosx_glsmp_null.m
│   │   ├── macosx_glsmp_ports.m
│   │   ├── macosx_input.m
│   │   ├── macosx_local.h
│   │   ├── macosx_qgl.h
│   │   ├── macosx_sndcore.m
│   │   ├── macosx_snddma.m
│   │   ├── macosx_sys.m
│   │   ├── macosx_timers.h
│   │   ├── macosx_timers.m
│   │   └── timedemo.zsh
│   ├── null/
│   │   ├── mac_net.c
│   │   ├── null_client.c
│   │   ├── null_glimp.c
│   │   ├── null_input.c
│   │   ├── null_main.c
│   │   ├── null_net.c
│   │   └── null_snddma.c
│   ├── opts.lnt
│   ├── q3_ui/
│   │   ├── Conscript
│   │   ├── compile.bat
│   │   ├── keycodes.h
│   │   ├── q3_ui.bat
│   │   ├── q3_ui.q3asm
│   │   ├── q3_ui.sh
│   │   ├── q3_ui.vcproj
│   │   ├── ui.def
│   │   ├── ui.q3asm
│   │   ├── ui_addbots.c
│   │   ├── ui_atoms.c
│   │   ├── ui_cdkey.c
│   │   ├── ui_cinematics.c
│   │   ├── ui_confirm.c
│   │   ├── ui_connect.c
│   │   ├── ui_controls2.c
│   │   ├── ui_credits.c
│   │   ├── ui_demo2.c
│   │   ├── ui_display.c
│   │   ├── ui_gameinfo.c
│   │   ├── ui_ingame.c
│   │   ├── ui_loadconfig.c
│   │   ├── ui_local.h
│   │   ├── ui_login.c
│   │   ├── ui_main.c
│   │   ├── ui_menu.c
│   │   ├── ui_mfield.c
│   │   ├── ui_mods.c
│   │   ├── ui_network.c
│   │   ├── ui_options.c
│   │   ├── ui_playermodel.c
│   │   ├── ui_players.c
│   │   ├── ui_playersettings.c
│   │   ├── ui_preferences.c
│   │   ├── ui_qmenu.c
│   │   ├── ui_rankings.c
│   │   ├── ui_rankstatus.c
│   │   ├── ui_removebots.c
│   │   ├── ui_saveconfig.c
│   │   ├── ui_serverinfo.c
│   │   ├── ui_servers2.c
│   │   ├── ui_setup.c
│   │   ├── ui_signup.c
│   │   ├── ui_sound.c
│   │   ├── ui_sparena.c
│   │   ├── ui_specifyleague.c
│   │   ├── ui_specifyserver.c
│   │   ├── ui_splevel.c
│   │   ├── ui_sppostgame.c
│   │   ├── ui_spreset.c
│   │   ├── ui_spskill.c
│   │   ├── ui_startserver.c
│   │   ├── ui_team.c
│   │   ├── ui_teamorders.c
│   │   └── ui_video.c
│   ├── qcommon/
│   │   ├── cm_load.c
│   │   ├── cm_local.h
│   │   ├── cm_patch.c
│   │   ├── cm_patch.h
│   │   ├── cm_polylib.c
│   │   ├── cm_polylib.h
│   │   ├── cm_public.h
│   │   ├── cm_test.c
│   │   ├── cm_trace.c
│   │   ├── cmd.c
│   │   ├── cmd.c.save
│   │   ├── common.c
│   │   ├── cvar.c
│   │   ├── files.c
│   │   ├── huffman.c
│   │   ├── md4.c
│   │   ├── msg.c
│   │   ├── net_chan.c
│   │   ├── qcommon.h
│   │   ├── qfiles.h
│   │   ├── unzip.c
│   │   ├── unzip.h
│   │   ├── vm.c
│   │   ├── vm_interpreted.c
│   │   ├── vm_local.h
│   │   ├── vm_ppc.c
│   │   ├── vm_ppc_new.c
│   │   └── vm_x86.c
│   ├── quake3.sln
│   ├── quake3.vcproj
│   ├── renderer/
│   │   ├── qgl.h
│   │   ├── qgl_linked.h
│   │   ├── ref_trin.def
│   │   ├── renderer.vcproj
│   │   ├── tr_animation.c
│   │   ├── tr_backend.c
│   │   ├── tr_bsp.c
│   │   ├── tr_cmds.c
│   │   ├── tr_curve.c
│   │   ├── tr_flares.c
│   │   ├── tr_font.c
│   │   ├── tr_image.c
│   │   ├── tr_init.c
│   │   ├── tr_light.c
│   │   ├── tr_local.h
│   │   ├── tr_main.c
│   │   ├── tr_marks.c
│   │   ├── tr_mesh.c
│   │   ├── tr_model.c
│   │   ├── tr_noise.c
│   │   ├── tr_public.h
│   │   ├── tr_scene.c
│   │   ├── tr_shade.c
│   │   ├── tr_shade_calc.c
│   │   ├── tr_shader.c
│   │   ├── tr_shadows.c
│   │   ├── tr_sky.c
│   │   ├── tr_surface.c
│   │   └── tr_world.c
│   ├── renderer.lnt
│   ├── run.bat
│   ├── runrelease.bat
│   ├── server/
│   │   ├── server.h
│   │   ├── sv_bot.c
│   │   ├── sv_ccmds.c
│   │   ├── sv_client.c
│   │   ├── sv_game.c
│   │   ├── sv_init.c
│   │   ├── sv_main.c
│   │   ├── sv_net_chan.c
│   │   ├── sv_rankings.c
│   │   ├── sv_snapshot.c
│   │   └── sv_world.c
│   ├── splines/
│   │   ├── Splines.vcproj
│   │   ├── math_angles.cpp
│   │   ├── math_angles.h
│   │   ├── math_matrix.cpp
│   │   ├── math_matrix.h
│   │   ├── math_quaternion.cpp
│   │   ├── math_quaternion.h
│   │   ├── math_vector.cpp
│   │   ├── math_vector.h
│   │   ├── q_parse.cpp
│   │   ├── q_shared.cpp
│   │   ├── q_shared.h
│   │   ├── q_shared.hpp
│   │   ├── splines.cpp
│   │   ├── splines.h
│   │   ├── util_list.h
│   │   ├── util_str.cpp
│   │   └── util_str.h
│   ├── ui/
│   │   ├── Conscript
│   │   ├── compile.bat
│   │   ├── keycodes.h
│   │   ├── ui.bat
│   │   ├── ui.def
│   │   ├── ui.q3asm
│   │   ├── ui.vcproj
│   │   ├── ui_atoms.c
│   │   ├── ui_gameinfo.c
│   │   ├── ui_local.h
│   │   ├── ui_main.c
│   │   ├── ui_players.c
│   │   ├── ui_public.h
│   │   ├── ui_shared.c
│   │   ├── ui_shared.h
│   │   ├── ui_syscalls.asm
│   │   ├── ui_syscalls.c
│   │   └── ui_util.c
│   ├── unix/
│   │   ├── ChangeLog
│   │   ├── Cons_gcc.pm
│   │   ├── Conscript-client
│   │   ├── Conscript-dedicated
│   │   ├── Conscript-pk3
│   │   ├── Conscript-sdk
│   │   ├── Conscript-setup
│   │   ├── LinuxSupport/
│   │   │   ├── CHANGES-1.32.txt
│   │   │   ├── INSTALL
│   │   │   ├── index.html
│   │   │   ├── udp_wide_README.txt
│   │   │   └── udp_wide_broadcast.patch
│   │   ├── Makefile
│   │   ├── Makefile.Game
│   │   ├── Quake3.kdelnk
│   │   ├── README.EULA
│   │   ├── README.Linux
│   │   ├── README.Q3Test
│   │   ├── build_setup.sh
│   │   ├── cons
│   │   ├── extract_ver.pl
│   │   ├── ftol.nasm
│   │   ├── linux_common.c
│   │   ├── linux_glimp.c
│   │   ├── linux_joystick.c
│   │   ├── linux_local.h
│   │   ├── linux_qgl.c
│   │   ├── linux_signals.c
│   │   ├── linux_snd.c
│   │   ├── matha.s
│   │   ├── pcons-2.3.1
│   │   ├── q3test.spec.sh
│   │   ├── qasm.h
│   │   ├── quake3.xpm
│   │   ├── run-target.sh
│   │   ├── snapvector.nasm
│   │   ├── snd_mixa.s
│   │   ├── sys_dosa.s
│   │   ├── unix_glw.h
│   │   ├── unix_main.c
│   │   ├── unix_net.c
│   │   ├── unix_shared.c
│   │   ├── vm_x86.c
│   │   └── vm_x86a.s
│   └── win32/
│       ├── glw_win.h
│       ├── mod-sdk-setup/
│       │   ├── GameSource.VCT
│       │   └── QIIIA Game Source License.doc
│       ├── resource.h
│       ├── win_gamma.c
│       ├── win_glimp.c
│       ├── win_input.c
│       ├── win_local.h
│       ├── win_main.c
│       ├── win_net.c
│       ├── win_qgl.c
│       ├── win_shared.c
│       ├── win_snd.c
│       ├── win_syscon.c
│       ├── win_wndproc.c
│       └── winquake.rc
├── common/
│   ├── aselib.c
│   ├── aselib.h
│   ├── bspfile.c
│   ├── bspfile.h
│   ├── cmdlib.c
│   ├── cmdlib.h
│   ├── imagelib.c
│   ├── imagelib.h
│   ├── l3dslib.c
│   ├── l3dslib.h
│   ├── mathlib.c
│   ├── mathlib.h
│   ├── md4.c
│   ├── mutex.c
│   ├── mutex.h
│   ├── polylib.c
│   ├── polylib.h
│   ├── polyset.h
│   ├── qfiles.h
│   ├── scriplib.c
│   ├── scriplib.h
│   ├── surfaceflags.h
│   ├── threads.c
│   ├── threads.h
│   ├── trilib.c
│   └── trilib.h
├── lcc/
│   ├── COPYRIGHT
│   ├── LOG
│   ├── README
│   ├── README.id
│   ├── alpha/
│   │   └── osf/
│   │       └── tst/
│   │           ├── 8q.1bk
│   │           ├── 8q.2bk
│   │           ├── 8q.sbk
│   │           ├── array.1bk
│   │           ├── array.2bk
│   │           ├── array.sbk
│   │           ├── cf.1bk
│   │           ├── cf.2bk
│   │           ├── cf.sbk
│   │           ├── cq.1bk
│   │           ├── cq.2bk
│   │           ├── cq.sbk
│   │           ├── cvt.1bk
│   │           ├── cvt.2bk
│   │           ├── cvt.sbk
│   │           ├── fields.1bk
│   │           ├── fields.2bk
│   │           ├── fields.sbk
│   │           ├── front.2bk
│   │           ├── front.sbk
│   │           ├── incr.1bk
│   │           ├── incr.2bk
│   │           ├── incr.sbk
│   │           ├── init.1bk
│   │           ├── init.2bk
│   │           ├── init.sbk
│   │           ├── limits.1bk
│   │           ├── limits.2bk
│   │           ├── limits.sbk
│   │           ├── paranoia.1bk
│   │           ├── paranoia.2bk
│   │           ├── paranoia.sbk
│   │           ├── sort.1bk
│   │           ├── sort.2bk
│   │           ├── sort.sbk
│   │           ├── spill.1bk
│   │           ├── spill.2bk
│   │           ├── spill.sbk
│   │           ├── stdarg.1bk
│   │           ├── stdarg.2bk
│   │           ├── stdarg.sbk
│   │           ├── struct.1bk
│   │           ├── struct.2bk
│   │           ├── struct.sbk
│   │           ├── switch.1bk
│   │           ├── switch.2bk
│   │           ├── switch.sbk
│   │           ├── wf1.1bk
│   │           ├── wf1.2bk
│   │           ├── wf1.sbk
│   │           ├── yacc.1bk
│   │           ├── yacc.2bk
│   │           └── yacc.sbk
│   ├── buildnt.bat
│   ├── buildnt.sh
│   ├── cpp/
│   │   ├── cpp.c
│   │   ├── cpp.h
│   │   ├── eval.c
│   │   ├── getopt.c
│   │   ├── hideset.c
│   │   ├── include.c
│   │   ├── lex.c
│   │   ├── macro.c
│   │   ├── nlist.c
│   │   ├── tokens.c
│   │   └── unix.c
│   ├── custom.mk
│   ├── doc/
│   │   ├── 4.html
│   │   ├── bprint.1
│   │   ├── install.html
│   │   └── lcc.1
│   ├── etc/
│   │   ├── bprint.c
│   │   ├── gcc-solaris.c
│   │   ├── irix.c
│   │   ├── lcc.c
│   │   ├── linux.c
│   │   ├── ops.c
│   │   ├── osf.c
│   │   ├── solaris.c
│   │   └── win32.c
│   ├── include/
│   │   ├── alpha/
│   │   │   └── osf/
│   │   │       ├── assert.h
│   │   │       ├── ctype.h
│   │   │       ├── errno.h
│   │   │       ├── float.h
│   │   │       ├── limits.h
│   │   │       ├── locale.h
│   │   │       ├── math.h
│   │   │       ├── setjmp.h
│   │   │       ├── signal.h
│   │   │       ├── stdarg.h
│   │   │       ├── stddef.h
│   │   │       ├── stdio.h
│   │   │       ├── stdlib.h
│   │   │       ├── string.h
│   │   │       └── time.h
│   │   ├── mips/
│   │   │   └── irix/
│   │   │       ├── assert.h
│   │   │       ├── ctype.h
│   │   │       ├── errno.h
│   │   │       ├── float.h
│   │   │       ├── limits.h
│   │   │       ├── locale.h
│   │   │       ├── math.h
│   │   │       ├── setjmp.h
│   │   │       ├── signal.h
│   │   │       ├── stdarg.h
│   │   │       ├── stddef.h
│   │   │       ├── stdio.h
│   │   │       ├── stdlib.h
│   │   │       ├── string.h
│   │   │       └── time.h
│   │   ├── sparc/
│   │   │   └── solaris/
│   │   │       ├── assert.h
│   │   │       ├── ctype.h
│   │   │       ├── errno.h
│   │   │       ├── float.h
│   │   │       ├── limits.h
│   │   │       ├── locale.h
│   │   │       ├── math.h
│   │   │       ├── setjmp.h
│   │   │       ├── signal.h
│   │   │       ├── stdarg.h
│   │   │       ├── stddef.h
│   │   │       ├── stdio.h
│   │   │       ├── stdlib.h
│   │   │       ├── string.h
│   │   │       └── time.h
│   │   └── x86/
│   │       └── linux/
│   │           ├── assert.h
│   │           ├── float.h
│   │           └── stdarg.h
│   ├── lburg/
│   │   ├── gram.c
│   │   ├── gram.y
│   │   ├── lburg.1
│   │   ├── lburg.c
│   │   └── lburg.h
│   ├── lib/
│   │   ├── assert.c
│   │   ├── bbexit.c
│   │   └── yynull.c
│   ├── makefile
│   ├── makefile.nt
│   ├── mips/
│   │   └── irix/
│   │       └── tst/
│   │           ├── 8q.1bk
│   │           ├── 8q.2bk
│   │           ├── 8q.sbk
│   │           ├── array.1bk
│   │           ├── array.2bk
│   │           ├── array.sbk
│   │           ├── cf.1bk
│   │           ├── cf.2bk
│   │           ├── cf.sbk
│   │           ├── cq.1bk
│   │           ├── cq.2bk
│   │           ├── cq.sbk
│   │           ├── cvt.1bk
│   │           ├── cvt.2bk
│   │           ├── cvt.sbk
│   │           ├── fields.1bk
│   │           ├── fields.2bk
│   │           ├── fields.sbk
│   │           ├── front.2bk
│   │           ├── front.sbk
│   │           ├── incr.2bk
│   │           ├── incr.sbk
│   │           ├── init.1bk
│   │           ├── init.2bk
│   │           ├── init.sbk
│   │           ├── limits.1bk
│   │           ├── limits.2bk
│   │           ├── limits.sbk
│   │           ├── paranoia.1bk
│   │           ├── paranoia.2bk
│   │           ├── paranoia.sbk
│   │           ├── sort.1bk
│   │           ├── sort.2bk
│   │           ├── sort.sbk
│   │           ├── spill.2bk
│   │           ├── spill.sbk
│   │           ├── stdarg.1bk
│   │           ├── stdarg.2bk
│   │           ├── stdarg.sbk
│   │           ├── struct.1bk
│   │           ├── struct.2bk
│   │           ├── struct.sbk
│   │           ├── switch.1bk
│   │           ├── switch.2bk
│   │           ├── switch.sbk
│   │           ├── wf1.1bk
│   │           ├── wf1.2bk
│   │           ├── wf1.sbk
│   │           ├── yacc.1bk
│   │           ├── yacc.2bk
│   │           └── yacc.sbk
│   ├── msdev/
│   │   ├── rcc.dsp
│   │   └── rcc.dsw
│   ├── packing.lst
│   ├── sparc/
│   │   └── solaris/
│   │       └── tst/
│   │           ├── 8q.1bk
│   │           ├── 8q.2bk
│   │           ├── 8q.sbk
│   │           ├── array.1bk
│   │           ├── array.2bk
│   │           ├── array.sbk
│   │           ├── cf.1bk
│   │           ├── cf.2bk
│   │           ├── cf.sbk
│   │           ├── cq.1bk
│   │           ├── cq.2bk
│   │           ├── cq.sbk
│   │           ├── cvt.1bk
│   │           ├── cvt.2bk
│   │           ├── cvt.sbk
│   │           ├── fields.1bk
│   │           ├── fields.2bk
│   │           ├── fields.sbk
│   │           ├── front.2bk
│   │           ├── front.sbk
│   │           ├── incr.1bk
│   │           ├── incr.2bk
│   │           ├── incr.sbk
│   │           ├── init.1bk
│   │           ├── init.2bk
│   │           ├── init.sbk
│   │           ├── limits.1bk
│   │           ├── limits.2bk
│   │           ├── limits.sbk
│   │           ├── paranoia.1bk
│   │           ├── paranoia.2bk
│   │           ├── paranoia.sbk
│   │           ├── sort.1bk
│   │           ├── sort.2bk
│   │           ├── sort.sbk
│   │           ├── spill.1bk
│   │           ├── spill.2bk
│   │           ├── spill.sbk
│   │           ├── stdarg.1bk
│   │           ├── stdarg.2bk
│   │           ├── stdarg.sbk
│   │           ├── struct.1bk
│   │           ├── struct.2bk
│   │           ├── struct.sbk
│   │           ├── switch.1bk
│   │           ├── switch.2bk
│   │           ├── switch.sbk
│   │           ├── wf1.1bk
│   │           ├── wf1.2bk
│   │           ├── wf1.sbk
│   │           ├── yacc.1bk
│   │           ├── yacc.2bk
│   │           └── yacc.sbk
│   ├── src/
│   │   ├── 2html.c
│   │   ├── alloc.c
│   │   ├── alpha.md
│   │   ├── asdl.c
│   │   ├── bind.c
│   │   ├── bytecode.c
│   │   ├── c.h
│   │   ├── config.h
│   │   ├── dag.c
│   │   ├── dagcheck.md
│   │   ├── decl.c
│   │   ├── enode.c
│   │   ├── error.c
│   │   ├── event.c
│   │   ├── expr.c
│   │   ├── gen.c
│   │   ├── init.c
│   │   ├── inits.c
│   │   ├── input.c
│   │   ├── lex.c
│   │   ├── list.c
│   │   ├── main.c
│   │   ├── mips.md
│   │   ├── null.c
│   │   ├── output.c
│   │   ├── pass2.c
│   │   ├── prof.c
│   │   ├── profio.c
│   │   ├── rcc.asdl
│   │   ├── run.sh
│   │   ├── simp.c
│   │   ├── sparc.md
│   │   ├── stab.c
│   │   ├── stab.h
│   │   ├── stmt.c
│   │   ├── string.c
│   │   ├── sym.c
│   │   ├── symbolic.c
│   │   ├── token.h
│   │   ├── trace.c
│   │   ├── tree.c
│   │   ├── types.c
│   │   ├── x86.md
│   │   └── x86linux.md
│   ├── tst/
│   │   ├── 8q.0
│   │   ├── 8q.c
│   │   ├── array.0
│   │   ├── array.c
│   │   ├── cf.0
│   │   ├── cf.c
│   │   ├── cq.0
│   │   ├── cq.c
│   │   ├── cvt.0
│   │   ├── cvt.c
│   │   ├── fields.0
│   │   ├── fields.c
│   │   ├── front.0
│   │   ├── front.c
│   │   ├── incr.0
│   │   ├── incr.c
│   │   ├── init.0
│   │   ├── init.c
│   │   ├── limits.0
│   │   ├── limits.c
│   │   ├── paranoia.0
│   │   ├── paranoia.c
│   │   ├── sort.0
│   │   ├── sort.c
│   │   ├── spill.0
│   │   ├── spill.c
│   │   ├── stdarg.0
│   │   ├── stdarg.c
│   │   ├── struct.0
│   │   ├── struct.c
│   │   ├── switch.0
│   │   ├── switch.c
│   │   ├── wf1.0
│   │   ├── wf1.c
│   │   ├── yacc.0
│   │   └── yacc.c
│   └── x86/
│       ├── linux/
│       │   └── tst/
│       │       ├── 8q.1bk
│       │       ├── 8q.2bk
│       │       ├── 8q.sbk
│       │       ├── array.1bk
│       │       ├── array.2bk
│       │       ├── array.sbk
│       │       ├── cf.1bk
│       │       ├── cf.2bk
│       │       ├── cf.sbk
│       │       ├── cq.1bk
│       │       ├── cq.2bk
│       │       ├── cq.sbk
│       │       ├── cvt.1bk
│       │       ├── cvt.2bk
│       │       ├── cvt.sbk
│       │       ├── fields.1bk
│       │       ├── fields.2bk
│       │       ├── fields.sbk
│       │       ├── front.2bk
│       │       ├── front.sbk
│       │       ├── incr.1bk
│       │       ├── incr.2bk
│       │       ├── incr.sbk
│       │       ├── init.1bk
│       │       ├── init.2bk
│       │       ├── init.sbk
│       │       ├── limits.1bk
│       │       ├── limits.2bk
│       │       ├── limits.sbk
│       │       ├── paranoia.1bk
│       │       ├── paranoia.2bk
│       │       ├── paranoia.sbk
│       │       ├── sort.1bk
│       │       ├── sort.2bk
│       │       ├── sort.sbk
│       │       ├── spill.1bk
│       │       ├── spill.2bk
│       │       ├── spill.sbk
│       │       ├── stdarg.1bk
│       │       ├── stdarg.2bk
│       │       ├── stdarg.sbk
│       │       ├── struct.1bk
│       │       ├── struct.2bk
│       │       ├── struct.sbk
│       │       ├── switch.1bk
│       │       ├── switch.2bk
│       │       ├── switch.sbk
│       │       ├── wf1.1bk
│       │       ├── wf1.2bk
│       │       ├── wf1.sbk
│       │       ├── yacc.1bk
│       │       ├── yacc.2bk
│       │       └── yacc.sbk
│       └── win32/
│           └── tst/
│               ├── 8q.1bk
│               ├── 8q.2bk
│               ├── 8q.sbk
│               ├── array.1bk
│               ├── array.2bk
│               ├── array.sbk
│               ├── cf.1bk
│               ├── cf.2bk
│               ├── cf.sbk
│               ├── cq.1bk
│               ├── cq.2bk
│               ├── cq.sbk
│               ├── cvt.1bk
│               ├── cvt.2bk
│               ├── cvt.sbk
│               ├── fields.1bk
│               ├── fields.2bk
│               ├── fields.sbk
│               ├── front.2bk
│               ├── front.sbk
│               ├── incr.1bk
│               ├── incr.2bk
│               ├── incr.sbk
│               ├── init.1bk
│               ├── init.2bk
│               ├── init.sbk
│               ├── limits.1bk
│               ├── limits.2bk
│               ├── limits.sbk
│               ├── paranoia.1bk
│               ├── paranoia.2bk
│               ├── paranoia.sbk
│               ├── sort.1bk
│               ├── sort.2bk
│               ├── sort.sbk
│               ├── spill.1bk
│               ├── spill.2bk
│               ├── spill.sbk
│               ├── stdarg.1bk
│               ├── stdarg.2bk
│               ├── stdarg.sbk
│               ├── struct.1bk
│               ├── struct.2bk
│               ├── struct.sbk
│               ├── switch.1bk
│               ├── switch.2bk
│               ├── switch.sbk
│               ├── wf1.1bk
│               ├── wf1.2bk
│               ├── wf1.sbk
│               ├── yacc.1bk
│               ├── yacc.2bk
│               └── yacc.sbk
├── libs/
│   ├── cmdlib/
│   │   ├── cmdlib.cpp
│   │   └── cmdlib.vcproj
│   ├── cmdlib.h
│   ├── jpeg6/
│   │   ├── README
│   │   ├── jchuff.h
│   │   ├── jcomapi.cpp
│   │   ├── jconfig.h
│   │   ├── jdapimin.cpp
│   │   ├── jdapistd.cpp
│   │   ├── jdatasrc.cpp
│   │   ├── jdcoefct.cpp
│   │   ├── jdcolor.cpp
│   │   ├── jdct.h
│   │   ├── jddctmgr.cpp
│   │   ├── jdhuff.cpp
│   │   ├── jdhuff.h
│   │   ├── jdinput.cpp
│   │   ├── jdmainct.cpp
│   │   ├── jdmarker.cpp
│   │   ├── jdmaster.cpp
│   │   ├── jdpostct.cpp
│   │   ├── jdsample.cpp
│   │   ├── jdtrans.cpp
│   │   ├── jerror.cpp
│   │   ├── jerror.h
│   │   ├── jfdctflt.cpp
│   │   ├── jidctflt.cpp
│   │   ├── jinclude.h
│   │   ├── jmemmgr.cpp
│   │   ├── jmemnobs.cpp
│   │   ├── jmemsys.h
│   │   ├── jmorecfg.h
│   │   ├── jpeg6.vcproj
│   │   ├── jpegint.h
│   │   ├── jpgload.cpp
│   │   ├── jutils.cpp
│   │   └── jversion.h
│   ├── jpeglib.h
│   ├── pak/
│   │   ├── pak.vcproj
│   │   ├── pakstuff.cpp
│   │   ├── unzip.cpp
│   │   └── unzip.h
│   ├── pakstuff.h
│   └── str.h
├── q3asm/
│   ├── Makefile
│   ├── README.Id
│   ├── cmdlib.c
│   ├── cmdlib.h
│   ├── lib.txt
│   ├── mathlib.h
│   ├── notes.txt
│   ├── ops.txt
│   ├── opstrings.h
│   ├── q3asm.c
│   ├── q3asm.sln
│   ├── q3asm.vcproj
│   └── qfiles.h
├── q3map/
│   ├── brush.c
│   ├── brush_primit.c
│   ├── bsp.c
│   ├── facebsp.c
│   ├── fog.c
│   ├── gldraw.c
│   ├── glfile.c
│   ├── leakfile.c
│   ├── light.c
│   ├── light.h
│   ├── light_trace.c
│   ├── lightmaps.c
│   ├── lightv.c
│   ├── makefile
│   ├── map.c
│   ├── mesh.c
│   ├── mesh.h
│   ├── misc_model.c
│   ├── nodraw.c
│   ├── patch.c
│   ├── portals.c
│   ├── prtfile.c
│   ├── q3map.sln
│   ├── q3map.vcproj
│   ├── qbsp.h
│   ├── shaders.c
│   ├── shaders.h
│   ├── soundv.c
│   ├── surface.c
│   ├── terrain.c
│   ├── tjunction.c
│   ├── tree.c
│   ├── vis.c
│   ├── vis.h
│   ├── visflow.c
│   └── writebsp.c
├── q3radiant/
│   ├── BMP.H
│   ├── BRUSH.H
│   ├── BSInput.cpp
│   ├── BSInput.h
│   ├── BSPFILE.H
│   ├── Bmp.cpp
│   ├── Brush.cpp
│   ├── BrushScript.cpp
│   ├── CAMERA.H
│   ├── CSG.CPP
│   ├── CamWnd.cpp
│   ├── CamWnd.h
│   ├── CapDialog.cpp
│   ├── CapDialog.h
│   ├── CharBuffer.h
│   ├── ChildFrm.cpp
│   ├── ChildFrm.h
│   ├── CommandsDlg.cpp
│   ├── CommandsDlg.h
│   ├── DRAG.CPP
│   ├── DialogInfo.cpp
│   ├── DialogInfo.h
│   ├── DialogTextures.cpp
│   ├── DialogTextures.h
│   ├── DialogThick.cpp
│   ├── DialogThick.h
│   ├── DlgEvent.cpp
│   ├── DlgEvent.h
│   ├── ECLASS.CPP
│   ├── ENTITY.CPP
│   ├── ENTITY.H
│   ├── ENTITYW.H
│   ├── EPAIRS.H
│   ├── EditWnd.cpp
│   ├── EditWnd.h
│   ├── EntityListDlg.cpp
│   ├── EntityListDlg.h
│   ├── EpairsWrapper.h
│   ├── FNMATCH.CPP
│   ├── FNMATCH.H
│   ├── FindTextureDlg.cpp
│   ├── FindTextureDlg.h
│   ├── GLINGR.H
│   ├── GLInterface.cpp
│   ├── GLW_WIN.H
│   ├── GroupBar.cpp
│   ├── GroupBar.h
│   ├── GroupDlg.cpp
│   ├── GroupDlg.h
│   ├── IBSPFrontend.h
│   ├── IEpairs.cpp
│   ├── IEpairs.h
│   ├── IMessaging.h
│   ├── IPluginEntities.h
│   ├── ISelectedFace.h
│   ├── IShaders.cpp
│   ├── IShaders.h
│   ├── LBMLIB.CPP
│   ├── LBMLIB.H
│   ├── LstToolBar.cpp
│   ├── LstToolBar.h
│   ├── MAP.CPP
│   ├── MAP.H
│   ├── MATHLIB.CPP
│   ├── MATHLIB.H
│   ├── MRU.CPP
│   ├── MRU.H
│   ├── MainFrm.cpp
│   ├── MainFrm.h
│   ├── MapInfo.cpp
│   ├── MapInfo.h
│   ├── Messaging.cpp
│   ├── Messaging.h
│   ├── NameDlg.cpp
│   ├── NameDlg.h
│   ├── NewProjDlg.cpp
│   ├── NewProjDlg.h
│   ├── PARSE.CPP
│   ├── PARSE.H
│   ├── PMESH.CPP
│   ├── PMESH.H
│   ├── POINTS.CPP
│   ├── PatchDensityDlg.cpp
│   ├── PatchDensityDlg.h
│   ├── PatchDialog.cpp
│   ├── PatchDialog.h
│   ├── PlugIn.cpp
│   ├── PlugIn.h
│   ├── PlugInManager.cpp
│   ├── PlugInManager.h
│   ├── PluginEntities.cpp
│   ├── PrefsDlg.cpp
│   ├── PrefsDlg.h
│   ├── QE3.CPP
│   ├── QE3.H
│   ├── QEDEFS.H
│   ├── QERTYPES.H
│   ├── QFILES.H
│   ├── QGL.H
│   ├── QGL_WIN.C
│   ├── QGL_WIN.CPP
│   ├── RADBSP.CPP
│   ├── RADEditView.cpp
│   ├── RADEditView.h
│   ├── RADEditWnd.cpp
│   ├── RADEditWnd.h
│   ├── RADKEYS.INI
│   ├── Radiant.clw
│   ├── Radiant.cpp
│   ├── Radiant.h
│   ├── Radiant.rc
│   ├── Radiant.sln
│   ├── Radiant.vcproj
│   ├── RadiantDoc.cpp
│   ├── RadiantDoc.h
│   ├── RadiantView.cpp
│   ├── RadiantView.h
│   ├── RotateDlg.cpp
│   ├── RotateDlg.h
│   ├── SELECT.CPP
│   ├── SELECT.H
│   ├── ScaleDialog.cpp
│   ├── ScaleDialog.h
│   ├── ScriptDlg.cpp
│   ├── ScriptDlg.h
│   ├── SelectedFace.cpp
│   ├── ShaderEdit.cpp
│   ├── ShaderEdit.h
│   ├── ShaderInfo.cpp
│   ├── ShaderInfo.h
│   ├── StdAfx.cpp
│   ├── StdAfx.h
│   ├── SurfaceDlg.cpp
│   ├── SurfaceDlg.h
│   ├── SurfacePlugin.cpp
│   ├── TexEdit.cpp
│   ├── TexEdit.h
│   ├── TexWnd.cpp
│   ├── TexWnd.h
│   ├── TextureBar.cpp
│   ├── TextureBar.h
│   ├── TextureLayout.cpp
│   ├── TextureLayout.h
│   ├── TextureLoad.cpp
│   ├── TextureLoad.h
│   ├── Textures.h
│   ├── ToolWnd.cpp
│   ├── ToolWnd.h
│   ├── Undo.cpp
│   ├── Undo.h
│   ├── VERTSEL.CPP
│   ├── VIEW.H
│   ├── WIN_CAM.CPP
│   ├── WIN_DLG.CPP
│   ├── WIN_QE3.CPP
│   ├── WIN_QE3.RC2
│   ├── WIN_XY.CPP
│   ├── WIN_Z.CPP
│   ├── WaveOpen.cpp
│   ├── WaveOpen.h
│   ├── Win_ent.cpp
│   ├── Win_main.cpp
│   ├── Winding.cpp
│   ├── Winding.h
│   ├── XY.H
│   ├── XYWnd.cpp
│   ├── XYWnd.h
│   ├── Z.CPP
│   ├── Z.H
│   ├── ZView.cpp
│   ├── ZView.h
│   ├── ZWnd.cpp
│   ├── ZWnd.h
│   ├── brush_primit.cpp
│   ├── cameratargetdlg.cpp
│   ├── cameratargetdlg.h
│   ├── cbrushstub.cpp
│   ├── dlgcamera.cpp
│   ├── dlgcamera.h
│   ├── igl.h
│   ├── iscriplib.h
│   ├── isurfaceplugin.h
│   ├── qerplugin.h
│   ├── res/
│   │   ├── DEFTEX.WAL
│   │   └── Radiant.rc2
│   ├── resource.h
│   ├── splines/
│   │   ├── Splines.vcproj
│   │   ├── math_angles.cpp
│   │   ├── math_angles.h
│   │   ├── math_matrix.cpp
│   │   ├── math_matrix.h
│   │   ├── math_quaternion.cpp
│   │   ├── math_quaternion.h
│   │   ├── math_vector.cpp
│   │   ├── math_vector.h
│   │   ├── q_parse.cpp
│   │   ├── q_shared.cpp
│   │   ├── q_shared.h
│   │   ├── splines.cpp
│   │   ├── splines.h
│   │   ├── util_list.h
│   │   ├── util_str.cpp
│   │   └── util_str.h
│   ├── terrain.cpp
│   └── terrain.h
└── ui/
    ├── hud.txt
    ├── hud2.txt
    ├── ingame.txt
    ├── menudef.h
    └── menus.txt
Copy disabled (too large) Download .json
Condensed preview — 1370 files, each showing path, character count, and a content snippet. Download the .json file for the full structured content (21,043K chars).
[
  {
    "path": "COPYING.txt",
    "chars": 15148,
    "preview": "\t\t    GNU GENERAL PUBLIC LICENSE\n\t\t       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc."
  },
  {
    "path": "README.txt",
    "chars": 9000,
    "preview": "Quake III Arena GPL source release\n==================================\n\nThis file contains the following sections:\n\nLICEN"
  },
  {
    "path": "code/Construct",
    "chars": 10009,
    "preview": "# -*- mode: perl -*-\n# cons script for cgame game q3_ui ui .so and .qvm builds\n#\n# Oct. 2001 TTimo <ttimo@idsoftware.com"
  },
  {
    "path": "code/Makefile",
    "chars": 155,
    "preview": "# nasty ugly to get build system working from Anjuta\nall:\n\tif [ `hostname` == sparkle ] ; then ./unix/pcons-2.3.1 -j4 --"
  },
  {
    "path": "code/botlib/aasfile.h",
    "chars": 8911,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_bsp.h",
    "chars": 3254,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_bspq3.c",
    "chars": 14645,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_cluster.c",
    "chars": 50955,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_cluster.h",
    "chars": 1366,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_debug.c",
    "chars": 23598,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_debug.h",
    "chars": 2381,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_def.h",
    "chars": 8450,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_entity.c",
    "chars": 12947,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_entity.h",
    "chars": 2497,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_file.c",
    "chars": 24506,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_file.h",
    "chars": 1519,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_funcs.h",
    "chars": 1572,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_main.c",
    "chars": 13538,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_main.h",
    "chars": 2055,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_move.c",
    "chars": 37579,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_move.h",
    "chars": 2886,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_optimize.c",
    "chars": 10993,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_optimize.h",
    "chars": 1244,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_reach.c",
    "chars": 152877,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_reach.h",
    "chars": 2828,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_route.c",
    "chars": 74721,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_route.h",
    "chars": 2872,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_routealt.c",
    "chars": 8275,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_routealt.h",
    "chars": 1535,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_sample.c",
    "chars": 44151,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_aas_sample.h",
    "chars": 3112,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_char.c",
    "chars": 23168,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_chat.c",
    "chars": 86556,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_gen.c",
    "chars": 3954,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_goal.c",
    "chars": 53192,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_move.c",
    "chars": 113070,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_weap.c",
    "chars": 18414,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_weight.c",
    "chars": 26686,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ai_weight.h",
    "chars": 2888,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_ea.c",
    "chars": 14363,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_interface.c",
    "chars": 29195,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/be_interface.h",
    "chars": 1884,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/botlib.vcproj",
    "chars": 38431,
    "preview": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"botl"
  },
  {
    "path": "code/botlib/l_crc.c",
    "chars": 5847,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_crc.h",
    "chars": 1280,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_libvar.c",
    "chars": 7573,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_libvar.h",
    "chars": 2386,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_log.c",
    "chars": 5076,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_log.h",
    "chars": 1644,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_memory.c",
    "chars": 13574,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_memory.h",
    "chars": 3011,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_precomp.c",
    "chars": 88624,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_precomp.h",
    "chars": 6176,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_script.c",
    "chars": 40381,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_script.h",
    "chars": 8224,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_struct.c",
    "chars": 12367,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_struct.h",
    "chars": 2494,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/l_utils.h",
    "chars": 1355,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/botlib/lcc.mak",
    "chars": 947,
    "preview": "#\n# Makefile for Gladiator Bot library: gladiator.dll\n# Intended for LCC-Win32\n#\n\nCC=lcc\nCFLAGS=-DC_ONLY -o\nOBJS= be_aas"
  },
  {
    "path": "code/botlib/linux-i386.mak",
    "chars": 1676,
    "preview": "#\n# Makefile for Gladiator Bot library: gladiator.so\n# Intended for gcc/Linux\n#\n\nARCH=i386\nCC=gcc\nBASE_CFLAGS=-Dstricmp="
  },
  {
    "path": "code/bspc/Conscript",
    "chars": 1219,
    "preview": "# bspc compile\n\nImport qw( BSPC_BASE_CFLAGS BUILD_DIR INSTALL_DIR CC CXX LINK );\n\n@BSPC_FILES = qw(\n\taas_areamerging.c\n\t"
  },
  {
    "path": "code/bspc/Makefile",
    "chars": 2260,
    "preview": "#\n# Makefile for the BSPC tool for the Gladiator Bot\n# Intended for gcc/Linux\n#\n# TTimo 5/15/2001\n# some cleanup .. only"
  },
  {
    "path": "code/bspc/_files.c",
    "chars": 2198,
    "preview": "//===========================================================================\n//\n// Name:\t\t\t_files.c\n// Function:\n// Pro"
  },
  {
    "path": "code/bspc/aas_areamerging.c",
    "chars": 12414,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_areamerging.h",
    "chars": 982,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_cfg.c",
    "chars": 7976,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_cfg.h",
    "chars": 2273,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_create.c",
    "chars": 35954,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_create.h",
    "chars": 4533,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_edgemelting.c",
    "chars": 3620,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_edgemelting.h",
    "chars": 992,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_facemerging.c",
    "chars": 9058,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_facemerging.h",
    "chars": 1021,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_file.c",
    "chars": 21783,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_file.h",
    "chars": 1068,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_gsubdiv.c",
    "chars": 21784,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_gsubdiv.h",
    "chars": 1065,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_map.c",
    "chars": 25898,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_map.h",
    "chars": 1033,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_prunenodes.c",
    "chars": 2895,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_prunenodes.h",
    "chars": 982,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_store.c",
    "chars": 33328,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aas_store.h",
    "chars": 3005,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/aasfile.h",
    "chars": 8238,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/be_aas_bspc.c",
    "chars": 9539,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/be_aas_bspc.h",
    "chars": 1009,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/brushbsp.c",
    "chars": 46529,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/bspc.c",
    "chars": 28389,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/bspc.sln",
    "chars": 1134,
    "preview": "Microsoft Visual Studio Solution File, Format Version 8.00\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"bspc\", \""
  },
  {
    "path": "code/bspc/bspc.vcproj",
    "chars": 32171,
    "preview": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"bspc"
  },
  {
    "path": "code/bspc/cfgq3.c",
    "chars": 2340,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/csg.c",
    "chars": 25901,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/faces.c",
    "chars": 18756,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/gldraw.c",
    "chars": 4549,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/glfile.c",
    "chars": 2900,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_ent.c",
    "chars": 3887,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_ent.h",
    "chars": 1818,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_hl.c",
    "chars": 24472,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_hl.h",
    "chars": 7949,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_q1.c",
    "chars": 17966,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_q1.h",
    "chars": 6699,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_q2.c",
    "chars": 30124,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_q2.h",
    "chars": 2875,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_q3.c",
    "chars": 25771,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_q3.h",
    "chars": 2655,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_sin.c",
    "chars": 37344,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_bsp_sin.h",
    "chars": 3443,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_cmd.c",
    "chars": 20733,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_cmd.h",
    "chars": 4101,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_log.c",
    "chars": 5708,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_log.h",
    "chars": 1532,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_math.c",
    "chars": 5868,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_math.h",
    "chars": 3206,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_mem.c",
    "chars": 12572,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_mem.h",
    "chars": 1788,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_poly.c",
    "chars": 33800,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_poly.h",
    "chars": 4906,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_qfiles.c",
    "chars": 17763,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_qfiles.h",
    "chars": 2913,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_threads.c",
    "chars": 38719,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_threads.h",
    "chars": 1617,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_utils.c",
    "chars": 7497,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/l_utils.h",
    "chars": 2545,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/lcc.mak",
    "chars": 829,
    "preview": "#\n# Makefile for the BSPC tool for the Gladiator Bot\n# Intended for LCC-Win32\n#\n\nCC=lcc\nCFLAGS=-DC_ONLY -o\nOBJS= _files."
  },
  {
    "path": "code/bspc/leakfile.c",
    "chars": 2531,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/linux-i386.mak",
    "chars": 1963,
    "preview": "#\n# Makefile for the BSPC tool for the Gladiator Bot\n# Intended for gcc/Linux\n#\n\nARCH=i386\nCC=gcc\nBASE_CFLAGS=-Dstricmp="
  },
  {
    "path": "code/bspc/map.c",
    "chars": 35826,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/map_hl.c",
    "chars": 31500,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/map_q1.c",
    "chars": 33367,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/map_q2.c",
    "chars": 30781,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/map_q3.c",
    "chars": 20346,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/map_sin.c",
    "chars": 32168,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/nodraw.c",
    "chars": 1256,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/portals.c",
    "chars": 33180,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/prtfile.c",
    "chars": 6245,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/q2files.h",
    "chars": 11637,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/q3files.h",
    "chars": 8660,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/qbsp.h",
    "chars": 14742,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/qfiles.h",
    "chars": 11637,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/sinfiles.h",
    "chars": 10164,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/tetrahedron.c",
    "chars": 42552,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/tetrahedron.h",
    "chars": 998,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/textures.c",
    "chars": 5327,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/tree.c",
    "chars": 7508,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/bspc/writebsp.c",
    "chars": 11423,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/Conscript",
    "chars": 3467,
    "preview": "# cgame building\n# builds the cgame for vanilla Q3 and TA\n\n# there are slight differences between Q3 and TA build:\n#   -"
  },
  {
    "path": "code/cgame/cg_consolecmds.c",
    "chars": 14545,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_draw.c",
    "chars": 59719,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_drawtools.c",
    "chars": 17669,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_effects.c",
    "chars": 17147,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_ents.c",
    "chars": 27281,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_event.c",
    "chars": 32216,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_info.c",
    "chars": 7908,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_local.h",
    "chars": 49220,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_localents.c",
    "chars": 22133,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_main.c",
    "chars": 67830,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_marks.c",
    "chars": 47450,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_newdraw.c",
    "chars": 50495,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_particles.c",
    "chars": 40763,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_players.c",
    "chars": 70197,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_playerstate.c",
    "chars": 15020,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_predict.c",
    "chars": 17044,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_public.h",
    "chars": 6167,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_scoreboard.c",
    "chars": 14901,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_servercmds.c",
    "chars": 29352,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_snapshot.c",
    "chars": 11084,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_syscalls.asm",
    "chars": 3125,
    "preview": "code\n\nequ\ttrap_Print\t\t\t\t\t\t\t-1\nequ\ttrap_Error\t\t\t\t\t\t\t-2\nequ\ttrap_Milliseconds\t\t\t\t\t-3\nequ\ttrap_Cvar_Register\t\t\t\t\t-4\nequ\ttra"
  },
  {
    "path": "code/cgame/cg_syscalls.c",
    "chars": 13829,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_view.c",
    "chars": 22642,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cg_weapons.c",
    "chars": 60421,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame/cgame.bat",
    "chars": 1403,
    "preview": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\nset cc=lcc -DQ3_VM -DCGAME -S -Wf-ta"
  },
  {
    "path": "code/cgame/cgame.def",
    "chars": 26,
    "preview": "EXPORTS\n\tvmMain\n\tdllEntry\n"
  },
  {
    "path": "code/cgame/cgame.plg",
    "chars": 5081,
    "preview": "<html>\n<body>\n<pre>\n<h1>Build Log</h1>\n<h3>\n--------------------Configuration: cgame - Win32 Release--------------------"
  },
  {
    "path": "code/cgame/cgame.q3asm",
    "chars": 295,
    "preview": "-o \"\\quake3\\baseq3\\vm\\cgame\"\ncg_main\n..\\cg_syscalls\ncg_consolecmds\ncg_draw\ncg_drawtools\ncg_effects\ncg_ents\ncg_event\ncg_i"
  },
  {
    "path": "code/cgame/cgame.sh",
    "chars": 690,
    "preview": "#!/bin/sh\n\nmkdir -p vm\ncd vm\n\nCC=\"q3lcc -DQ3_VM -DCGAME -S -Wf-target=bytecode -Wf-g -I../../cgame -I../../game -I../../"
  },
  {
    "path": "code/cgame/cgame.vcproj",
    "chars": 35013,
    "preview": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<VisualStudioProject\n\tProjectType=\"Visual C++\"\n\tVersion=\"7.10\"\n\tName=\"cgam"
  },
  {
    "path": "code/cgame/cgame_ta.bat",
    "chars": 1519,
    "preview": "rem make sure we have a safe environement\nset LIBRARY=\nset INCLUDE=\n\nmkdir vm\ncd vm\nset cc=lcc -DQ3_VM -DMISSIONPACK -DC"
  },
  {
    "path": "code/cgame/cgame_ta.q3asm",
    "chars": 321,
    "preview": "-o \"\\quake3\\missionpack\\vm\\cgame\"\ncg_main\n..\\cg_syscalls\ncg_consolecmds\ncg_draw\ncg_drawtools\ncg_effects\ncg_ents\ncg_event"
  },
  {
    "path": "code/cgame/cgame_ta.sh",
    "chars": 751,
    "preview": "#!/bin/sh\n\nmkdir -p vm\ncd vm\n\nCC=\"q3lcc -DQ3_VM  -DCGAME -DMISSIONPACK -S -Wf-target=bytecode -Wf-g -I../../cgame -I../."
  },
  {
    "path": "code/cgame/tr_types.h",
    "chars": 7056,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/cgame.lnt",
    "chars": 433,
    "preview": "opts.lnt\n\ngame\\bg_misc.c\ngame\\bg_pmove.c\ngame\\q_math.c\ngame\\q_shared.c\ncgame\\cg_consolecmds.c\ncgame\\cg_draw.c\ncgame\\cg_d"
  },
  {
    "path": "code/clean.bat",
    "chars": 1275,
    "preview": "rmdir debug /s /q\nrmdir release /s /q\ndel quake3.ncb\ndel quake3.opt\ndel quake3.plg\ndel quake3.stt\nrmdir cgame\\debug /s /"
  },
  {
    "path": "code/client/cl_cgame.c",
    "chars": 27370,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_cin.c",
    "chars": 49828,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_console.c",
    "chars": 16316,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_input.c",
    "chars": 23867,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_keys.c",
    "chars": 25607,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_main.c",
    "chars": 77864,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_net_chan.c",
    "chars": 4259,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_parse.c",
    "chars": 17021,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_scrn.c",
    "chars": 11716,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/cl_ui.c",
    "chars": 26034,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/client.h",
    "chars": 16005,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/keys.h",
    "chars": 2073,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/snd_adpcm.c",
    "chars": 8802,
    "preview": "/***********************************************************\nCopyright 1992 by Stichting Mathematisch Centrum, Amsterdam"
  },
  {
    "path": "code/client/snd_dma.c",
    "chars": 37187,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/snd_local.h",
    "chars": 5391,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/snd_mem.c",
    "chars": 9094,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/snd_mix.c",
    "chars": 17274,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  },
  {
    "path": "code/client/snd_public.h",
    "chars": 2770,
    "preview": "/*\n===========================================================================\nCopyright (C) 1999-2005 Id Software, Inc."
  }
]

// ... and 1170 more files (download for full content)

About this extraction

This page contains the full source code of the id-Software/Quake-III-Arena GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 1370 files (18.4 MB), approximately 4.9M tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!