aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Bradshaw <travis.bradshaw@idsoftware.com>2012-01-31 13:41:34 -0600
committerTravis Bradshaw <travis.bradshaw@idsoftware.com>2012-01-31 13:41:34 -0600
commitdbe4ddb10315479fc00086f08e25d968b4b43c49 (patch)
treec6f07c2173a458d098de45d4c459a8f1916d900f
downloadquake3arena-master.tar.gz
quake3arena-master.tar.bz2
quake3arena-master.zip
The Quake III Arena sources as originally released under the GPL license on August 20, 2005.HEADmaster
-rw-r--r--COPYING.txt281
-rw-r--r--README.txt193
-rw-r--r--code/Construct431
-rw-r--r--code/Makefile3
-rw-r--r--code/botlib/aasfile.h267
-rw-r--r--code/botlib/be_aas_bsp.h89
-rw-r--r--code/botlib/be_aas_bspq3.c487
-rw-r--r--code/botlib/be_aas_cluster.c1545
-rw-r--r--code/botlib/be_aas_cluster.h38
-rw-r--r--code/botlib/be_aas_debug.c777
-rw-r--r--code/botlib/be_aas_debug.h62
-rw-r--r--code/botlib/be_aas_def.h306
-rw-r--r--code/botlib/be_aas_entity.c437
-rw-r--r--code/botlib/be_aas_entity.h63
-rw-r--r--code/botlib/be_aas_file.c582
-rw-r--r--code/botlib/be_aas_file.h42
-rw-r--r--code/botlib/be_aas_funcs.h47
-rw-r--r--code/botlib/be_aas_main.c429
-rw-r--r--code/botlib/be_aas_main.h61
-rw-r--r--code/botlib/be_aas_move.c1101
-rw-r--r--code/botlib/be_aas_move.h71
-rw-r--r--code/botlib/be_aas_optimize.c312
-rw-r--r--code/botlib/be_aas_optimize.h33
-rw-r--r--code/botlib/be_aas_reach.c4547
-rw-r--r--code/botlib/be_aas_reach.h68
-rw-r--r--code/botlib/be_aas_route.c2209
-rw-r--r--code/botlib/be_aas_route.h67
-rw-r--r--code/botlib/be_aas_routealt.c240
-rw-r--r--code/botlib/be_aas_routealt.h40
-rw-r--r--code/botlib/be_aas_sample.c1394
-rw-r--r--code/botlib/be_aas_sample.h69
-rw-r--r--code/botlib/be_ai_char.c790
-rw-r--r--code/botlib/be_ai_chat.c3017
-rw-r--r--code/botlib/be_ai_gen.c134
-rw-r--r--code/botlib/be_ai_goal.c1821
-rw-r--r--code/botlib/be_ai_move.c3610
-rw-r--r--code/botlib/be_ai_weap.c543
-rw-r--r--code/botlib/be_ai_weight.c912
-rw-r--r--code/botlib/be_ai_weight.h83
-rw-r--r--code/botlib/be_ea.c508
-rw-r--r--code/botlib/be_interface.c881
-rw-r--r--code/botlib/be_interface.h57
-rw-r--r--code/botlib/botlib.vcproj1559
-rw-r--r--code/botlib/l_crc.c151
-rw-r--r--code/botlib/l_crc.h29
-rw-r--r--code/botlib/l_libvar.c294
-rw-r--r--code/botlib/l_libvar.h63
-rw-r--r--code/botlib/l_log.c169
-rw-r--r--code/botlib/l_log.h46
-rw-r--r--code/botlib/l_memory.c463
-rw-r--r--code/botlib/l_memory.h76
-rw-r--r--code/botlib/l_precomp.c3228
-rw-r--r--code/botlib/l_precomp.h180
-rw-r--r--code/botlib/l_script.c1433
-rw-r--r--code/botlib/l_script.h247
-rw-r--r--code/botlib/l_struct.c462
-rw-r--r--code/botlib/l_struct.h75
-rw-r--r--code/botlib/l_utils.h35
-rw-r--r--code/botlib/lcc.mak55
-rw-r--r--code/botlib/linux-i386.mak92
-rw-r--r--code/bspc/Conscript75
-rw-r--r--code/bspc/Makefile114
-rw-r--r--code/bspc/_files.c63
-rw-r--r--code/bspc/aas_areamerging.c390
-rw-r--r--code/bspc/aas_areamerging.h24
-rw-r--r--code/bspc/aas_cfg.c252
-rw-r--r--code/bspc/aas_cfg.h73
-rw-r--r--code/bspc/aas_create.c1142
-rw-r--r--code/bspc/aas_create.h136
-rw-r--r--code/bspc/aas_edgemelting.c108
-rw-r--r--code/bspc/aas_edgemelting.h24
-rw-r--r--code/bspc/aas_facemerging.c282
-rw-r--r--code/bspc/aas_facemerging.h24
-rw-r--r--code/bspc/aas_file.c549
-rw-r--r--code/bspc/aas_file.h25
-rw-r--r--code/bspc/aas_gsubdiv.c656
-rw-r--r--code/bspc/aas_gsubdiv.h25
-rw-r--r--code/bspc/aas_map.c849
-rw-r--r--code/bspc/aas_map.h23
-rw-r--r--code/bspc/aas_prunenodes.c89
-rw-r--r--code/bspc/aas_prunenodes.h24
-rw-r--r--code/bspc/aas_store.c1082
-rw-r--r--code/bspc/aas_store.h107
-rw-r--r--code/bspc/aasfile.h252
-rw-r--r--code/bspc/be_aas_bspc.c292
-rw-r--r--code/bspc/be_aas_bspc.h23
-rw-r--r--code/bspc/brushbsp.c1871
-rw-r--r--code/bspc/bspc.c991
-rw-r--r--code/bspc/bspc.sln28
-rw-r--r--code/bspc/bspc.vcproj1381
-rw-r--r--code/bspc/cfgq3.c84
-rw-r--r--code/bspc/csg.c1005
-rw-r--r--code/bspc/faces.c978
-rw-r--r--code/bspc/gldraw.c232
-rw-r--r--code/bspc/glfile.c149
-rw-r--r--code/bspc/l_bsp_ent.c180
-rw-r--r--code/bspc/l_bsp_ent.h58
-rw-r--r--code/bspc/l_bsp_hl.c888
-rw-r--r--code/bspc/l_bsp_hl.h314
-rw-r--r--code/bspc/l_bsp_q1.c620
-rw-r--r--code/bspc/l_bsp_q1.h275
-rw-r--r--code/bspc/l_bsp_q2.c1134
-rw-r--r--code/bspc/l_bsp_q2.h98
-rw-r--r--code/bspc/l_bsp_q3.c824
-rw-r--r--code/bspc/l_bsp_q3.h81
-rw-r--r--code/bspc/l_bsp_sin.c1186
-rw-r--r--code/bspc/l_bsp_sin.h106
-rw-r--r--code/bspc/l_cmd.c1230
-rw-r--r--code/bspc/l_cmd.h157
-rw-r--r--code/bspc/l_log.c215
-rw-r--r--code/bspc/l_log.h42
-rw-r--r--code/bspc/l_math.c289
-rw-r--r--code/bspc/l_math.h93
-rw-r--r--code/bspc/l_mem.c441
-rw-r--r--code/bspc/l_mem.h51
-rw-r--r--code/bspc/l_poly.c1411
-rw-r--r--code/bspc/l_poly.h120
-rw-r--r--code/bspc/l_qfiles.c663
-rw-r--r--code/bspc/l_qfiles.h91
-rw-r--r--code/bspc/l_threads.c1510
-rw-r--r--code/bspc/l_threads.h45
-rw-r--r--code/bspc/l_utils.c259
-rw-r--r--code/bspc/l_utils.h79
-rw-r--r--code/bspc/lcc.mak61
-rw-r--r--code/bspc/leakfile.c101
-rw-r--r--code/bspc/linux-i386.mak109
-rw-r--r--code/bspc/map.c1267
-rw-r--r--code/bspc/map_hl.c1114
-rw-r--r--code/bspc/map_q1.c1174
-rw-r--r--code/bspc/map_q2.c1162
-rw-r--r--code/bspc/map_q3.c681
-rw-r--r--code/bspc/map_sin.c1211
-rw-r--r--code/bspc/nodraw.c47
-rw-r--r--code/bspc/portals.c1297
-rw-r--r--code/bspc/prtfile.c287
-rw-r--r--code/bspc/q2files.h487
-rw-r--r--code/bspc/q3files.h374
-rw-r--r--code/bspc/qbsp.h477
-rw-r--r--code/bspc/qfiles.h487
-rw-r--r--code/bspc/sinfiles.h365
-rw-r--r--code/bspc/tetrahedron.c1389
-rw-r--r--code/bspc/tetrahedron.h24
-rw-r--r--code/bspc/textures.c228
-rw-r--r--code/bspc/tree.c283
-rw-r--r--code/bspc/writebsp.c595
-rw-r--r--code/cgame.lnt25
-rw-r--r--code/cgame/Conscript138
-rw-r--r--code/cgame/cg_consolecmds.c578
-rw-r--r--code/cgame/cg_draw.c2659
-rw-r--r--code/cgame/cg_drawtools.c824
-rw-r--r--code/cgame/cg_effects.c718
-rw-r--r--code/cgame/cg_ents.c1037
-rw-r--r--code/cgame/cg_event.c1205
-rw-r--r--code/cgame/cg_info.c297
-rw-r--r--code/cgame/cg_local.h1669
-rw-r--r--code/cgame/cg_localents.c886
-rw-r--r--code/cgame/cg_main.c1997
-rw-r--r--code/cgame/cg_marks.c2274
-rw-r--r--code/cgame/cg_newdraw.c1852
-rw-r--r--code/cgame/cg_particles.c2018
-rw-r--r--code/cgame/cg_players.c2619
-rw-r--r--code/cgame/cg_playerstate.c526
-rw-r--r--code/cgame/cg_predict.c628
-rw-r--r--code/cgame/cg_public.h238
-rw-r--r--code/cgame/cg_scoreboard.c534
-rw-r--r--code/cgame/cg_servercmds.c1098
-rw-r--r--code/cgame/cg_snapshot.c403
-rw-r--r--code/cgame/cg_syscalls.asm106
-rw-r--r--code/cgame/cg_syscalls.c445
-rw-r--r--code/cgame/cg_view.c876
-rw-r--r--code/cgame/cg_weapons.c2277
-rw-r--r--code/cgame/cgame.bat63
-rw-r--r--code/cgame/cgame.def3
-rw-r--r--code/cgame/cgame.plg124
-rw-r--r--code/cgame/cgame.q3asm26
-rw-r--r--code/cgame/cgame.sh36
-rw-r--r--code/cgame/cgame.vcproj1221
-rw-r--r--code/cgame/cgame_ta.bat65
-rw-r--r--code/cgame/cgame_ta.q3asm28
-rw-r--r--code/cgame/cgame_ta.sh38
-rw-r--r--code/cgame/tr_types.h229
-rw-r--r--code/clean.bat61
-rw-r--r--code/client/cl_cgame.c1029
-rw-r--r--code/client/cl_cin.c1740
-rw-r--r--code/client/cl_console.c786
-rw-r--r--code/client/cl_input.c901
-rw-r--r--code/client/cl_keys.c1252
-rw-r--r--code/client/cl_main.c3324
-rw-r--r--code/client/cl_net_chan.c167
-rw-r--r--code/client/cl_parse.c655
-rw-r--r--code/client/cl_scrn.c547
-rw-r--r--code/client/cl_ui.c1200
-rw-r--r--code/client/client.h519
-rw-r--r--code/client/keys.h57
-rw-r--r--code/client/snd_adpcm.c330
-rw-r--r--code/client/snd_dma.c1636
-rw-r--r--code/client/snd_local.h204
-rw-r--r--code/client/snd_mem.c404
-rw-r--r--code/client/snd_mix.c681
-rw-r--r--code/client/snd_public.h72
-rw-r--r--code/client/snd_wavelet.c253
-rw-r--r--code/game.lnt35
-rw-r--r--code/game/Conscript140
-rw-r--r--code/game/ai_chat.c1226
-rw-r--r--code/game/ai_chat.h61
-rw-r--r--code/game/ai_cmd.c1992
-rw-r--r--code/game/ai_cmd.h37
-rw-r--r--code/game/ai_dmnet.c2610
-rw-r--r--code/game/ai_dmnet.h61
-rw-r--r--code/game/ai_dmq3.c5461
-rw-r--r--code/game/ai_dmq3.h206
-rw-r--r--code/game/ai_main.c1695
-rw-r--r--code/game/ai_main.h299
-rw-r--r--code/game/ai_team.c2080
-rw-r--r--code/game/ai_team.h39
-rw-r--r--code/game/ai_vcmd.c550
-rw-r--r--code/game/ai_vcmd.h36
-rw-r--r--code/game/be_aas.h221
-rw-r--r--code/game/be_ai_char.h48
-rw-r--r--code/game/be_ai_chat.h113
-rw-r--r--code/game/be_ai_gen.h33
-rw-r--r--code/game/be_ai_goal.h118
-rw-r--r--code/game/be_ai_move.h142
-rw-r--r--code/game/be_ai_weap.h104
-rw-r--r--code/game/be_ea.h66
-rw-r--r--code/game/bg_lib.c1324
-rw-r--r--code/game/bg_lib.h91
-rw-r--r--code/game/bg_local.h83
-rw-r--r--code/game/bg_misc.c1604
-rw-r--r--code/game/bg_pmove.c2069
-rw-r--r--code/game/bg_public.h738
-rw-r--r--code/game/bg_slidemove.c325
-rw-r--r--code/game/botlib.h516
-rw-r--r--code/game/chars.h134
-rw-r--r--code/game/g_active.c1191
-rw-r--r--code/game/g_arenas.c376
-rw-r--r--code/game/g_bot.c1017
-rw-r--r--code/game/g_client.c1344
-rw-r--r--code/game/g_cmds.c1701
-rw-r--r--code/game/g_combat.c1195
-rw-r--r--code/game/g_items.c1010
-rw-r--r--code/game/g_local.h971
-rw-r--r--code/game/g_main.c1832
-rw-r--r--code/game/g_mem.c61
-rw-r--r--code/game/g_misc.c482
-rw-r--r--code/game/g_missile.c808
-rw-r--r--code/game/g_mover.c1612
-rw-r--r--code/game/g_public.h429
-rw-r--r--code/game/g_rankings.c1135
-rw-r--r--code/game/g_rankings.h396
-rw-r--r--code/game/g_session.c193
-rw-r--r--code/game/g_spawn.c643
-rw-r--r--code/game/g_svcmds.c508
-rw-r--r--code/game/g_syscalls.asm225
-rw-r--r--code/game/g_syscalls.c790
-rw-r--r--code/game/g_target.c467
-rw-r--r--code/game/g_team.c1483
-rw-r--r--code/game/g_team.h88
-rw-r--r--code/game/g_trigger.c465
-rw-r--r--code/game/g_utils.c666
-rw-r--r--code/game/g_weapon.c1145
-rw-r--r--code/game/game.bat85
-rw-r--r--code/game/game.def3
-rw-r--r--code/game/game.q3asm35
-rw-r--r--code/game/game.sh48
-rw-r--r--code/game/game.vcproj2132
-rw-r--r--code/game/game_ta.bat86
-rw-r--r--code/game/game_ta.q3asm35
-rw-r--r--code/game/game_ta.sh48
-rw-r--r--code/game/inv.h166
-rw-r--r--code/game/match.h134
-rw-r--r--code/game/q_math.c1308
-rw-r--r--code/game/q_shared.c1258
-rw-r--r--code/game/q_shared.h1432
-rw-r--r--code/game/surfaceflags.h80
-rw-r--r--code/game/syn.h34
-rw-r--r--code/installdebug.bat6
-rw-r--r--code/installrelease.bat14
-rw-r--r--code/installvms.bat7
-rw-r--r--code/jpeg-6/README385
-rw-r--r--code/jpeg-6/jcapimin.c228
-rw-r--r--code/jpeg-6/jcapistd.c161
-rw-r--r--code/jpeg-6/jccoefct.c448
-rw-r--r--code/jpeg-6/jccolor.c459
-rw-r--r--code/jpeg-6/jcdctmgr.c391
-rw-r--r--code/jpeg-6/jchuff.c846
-rw-r--r--code/jpeg-6/jchuff.h34
-rw-r--r--code/jpeg-6/jcinit.c72
-rw-r--r--code/jpeg-6/jcmainct.c296
-rw-r--r--code/jpeg-6/jcmarker.c639
-rw-r--r--code/jpeg-6/jcmaster.c578
-rw-r--r--code/jpeg-6/jcomapi.c94
-rw-r--r--code/jpeg-6/jconfig.h41
-rw-r--r--code/jpeg-6/jcparam.c575
-rw-r--r--code/jpeg-6/jcphuff.c829
-rw-r--r--code/jpeg-6/jcprepct.c371
-rw-r--r--code/jpeg-6/jcsample.c519
-rw-r--r--code/jpeg-6/jctrans.c371
-rw-r--r--code/jpeg-6/jdapimin.c398
-rw-r--r--code/jpeg-6/jdapistd.c275
-rw-r--r--code/jpeg-6/jdatadst.c151
-rw-r--r--code/jpeg-6/jdatasrc.c204
-rw-r--r--code/jpeg-6/jdcoefct.c725
-rw-r--r--code/jpeg-6/jdcolor.c367
-rw-r--r--code/jpeg-6/jdct.h176
-rw-r--r--code/jpeg-6/jddctmgr.c270
-rw-r--r--code/jpeg-6/jdhuff.c574
-rw-r--r--code/jpeg-6/jdhuff.h202
-rw-r--r--code/jpeg-6/jdinput.c381
-rw-r--r--code/jpeg-6/jdmainct.c520
-rw-r--r--code/jpeg-6/jdmarker.c1052
-rw-r--r--code/jpeg-6/jdmaster.c557
-rw-r--r--code/jpeg-6/jdmerge.c400
-rw-r--r--code/jpeg-6/jdphuff.c642
-rw-r--r--code/jpeg-6/jdpostct.c290
-rw-r--r--code/jpeg-6/jdsample.c478
-rw-r--r--code/jpeg-6/jdtrans.c122
-rw-r--r--code/jpeg-6/jerror.c232
-rw-r--r--code/jpeg-6/jerror.h273
-rw-r--r--code/jpeg-6/jfdctflt.c168
-rw-r--r--code/jpeg-6/jfdctfst.c224
-rw-r--r--code/jpeg-6/jfdctint.c283
-rw-r--r--code/jpeg-6/jidctflt.c241
-rw-r--r--code/jpeg-6/jidctfst.c367
-rw-r--r--code/jpeg-6/jidctint.c388
-rw-r--r--code/jpeg-6/jidctred.c397
-rw-r--r--code/jpeg-6/jinclude.h116
-rw-r--r--code/jpeg-6/jload.c145
-rw-r--r--code/jpeg-6/jmemansi.c167
-rw-r--r--code/jpeg-6/jmemdos.c634
-rw-r--r--code/jpeg-6/jmemmgr.c1115
-rw-r--r--code/jpeg-6/jmemname.c271
-rw-r--r--code/jpeg-6/jmemnobs.c105
-rw-r--r--code/jpeg-6/jmemsys.h182
-rw-r--r--code/jpeg-6/jmorecfg.h348
-rw-r--r--code/jpeg-6/jpegint.h388
-rw-r--r--code/jpeg-6/jpeglib.h1051
-rw-r--r--code/jpeg-6/jpegtran.c370
-rw-r--r--code/jpeg-6/jquant1.c856
-rw-r--r--code/jpeg-6/jquant2.c1310
-rw-r--r--code/jpeg-6/jutils.c175
-rw-r--r--code/jpeg-6/jversion.h14
-rw-r--r--code/macosx/BuildRelease17
-rw-r--r--code/macosx/CGMouseDeltaFix.h27
-rw-r--r--code/macosx/CGMouseDeltaFix.m131
-rw-r--r--code/macosx/CGPrivateAPI.h185
-rw-r--r--code/macosx/GenerateQGL.pl146
-rw-r--r--code/macosx/Performance.rtf114
-rw-r--r--code/macosx/Q3Controller.h40
-rw-r--r--code/macosx/Q3Controller.m435
-rw-r--r--code/macosx/Quake3.icnsbin0 -> 35224 bytes
-rw-r--r--code/macosx/Quake3.nib/classes.nib18
-rw-r--r--code/macosx/Quake3.nib/info.nib19
-rw-r--r--code/macosx/Quake3.nib/objects.nibbin0 -> 765 bytes
-rw-r--r--code/macosx/Quake3.pbproj/apple.pbxuser563
-rw-r--r--code/macosx/Quake3.pbproj/project.pbxproj11802
-rw-r--r--code/macosx/RecordDemo.zsh9
-rw-r--r--code/macosx/banner.jpgbin0 -> 55841 bytes
-rw-r--r--code/macosx/botlib.log196
-rw-r--r--code/macosx/macosx_display.h38
-rw-r--r--code/macosx/macosx_display.m373
-rw-r--r--code/macosx/macosx_glimp.h37
-rw-r--r--code/macosx/macosx_glimp.m1114
-rw-r--r--code/macosx/macosx_glsmp_mutex.m176
-rw-r--r--code/macosx/macosx_glsmp_null.m46
-rw-r--r--code/macosx/macosx_glsmp_ports.m425
-rw-r--r--code/macosx/macosx_input.m916
-rw-r--r--code/macosx/macosx_local.h129
-rw-r--r--code/macosx/macosx_qgl.h5095
-rw-r--r--code/macosx/macosx_sndcore.m325
-rw-r--r--code/macosx/macosx_snddma.m205
-rw-r--r--code/macosx/macosx_sys.m537
-rw-r--r--code/macosx/macosx_timers.h56
-rw-r--r--code/macosx/macosx_timers.m75
-rw-r--r--code/macosx/timedemo.zsh26
-rw-r--r--code/null/mac_net.c65
-rw-r--r--code/null/null_client.c91
-rw-r--r--code/null/null_glimp.c56
-rw-r--r--code/null/null_input.c35
-rw-r--r--code/null/null_main.c116
-rw-r--r--code/null/null_net.c64
-rw-r--r--code/null/null_snddma.c60
-rw-r--r--code/opts.lnt26
-rw-r--r--code/q3_ui/Conscript93
-rw-r--r--code/q3_ui/compile.bat2
-rw-r--r--code/q3_ui/keycodes.h163
-rw-r--r--code/q3_ui/q3_ui.bat100
-rw-r--r--code/q3_ui/q3_ui.q3asm43
-rw-r--r--code/q3_ui/q3_ui.sh55
-rw-r--r--code/q3_ui/q3_ui.vcproj2008
-rw-r--r--code/q3_ui/ui.def3
-rw-r--r--code/q3_ui/ui.q3asm45
-rw-r--r--code/q3_ui/ui_addbots.c412
-rw-r--r--code/q3_ui/ui_atoms.c1267
-rw-r--r--code/q3_ui/ui_cdkey.c291
-rw-r--r--code/q3_ui/ui_cinematics.c350
-rw-r--r--code/q3_ui/ui_confirm.c293
-rw-r--r--code/q3_ui/ui_connect.c282
-rw-r--r--code/q3_ui/ui_controls2.c1667
-rw-r--r--code/q3_ui/ui_credits.c129
-rw-r--r--code/q3_ui/ui_demo2.c291
-rw-r--r--code/q3_ui/ui_display.c265
-rw-r--r--code/q3_ui/ui_gameinfo.c820
-rw-r--r--code/q3_ui/ui_ingame.c349
-rw-r--r--code/q3_ui/ui_loadconfig.c274
-rw-r--r--code/q3_ui/ui_local.h800
-rw-r--r--code/q3_ui/ui_login.c208
-rw-r--r--code/q3_ui/ui_main.c249
-rw-r--r--code/q3_ui/ui_menu.c419
-rw-r--r--code/q3_ui/ui_mfield.c439
-rw-r--r--code/q3_ui/ui_mods.c283
-rw-r--r--code/q3_ui/ui_network.c281
-rw-r--r--code/q3_ui/ui_options.c229
-rw-r--r--code/q3_ui/ui_playermodel.c731
-rw-r--r--code/q3_ui/ui_players.c1248
-rw-r--r--code/q3_ui/ui_playersettings.c513
-rw-r--r--code/q3_ui/ui_preferences.c419
-rw-r--r--code/q3_ui/ui_qmenu.c1746
-rw-r--r--code/q3_ui/ui_rankings.c420
-rw-r--r--code/q3_ui/ui_rankstatus.c209
-rw-r--r--code/q3_ui/ui_removebots.c342
-rw-r--r--code/q3_ui/ui_saveconfig.c212
-rw-r--r--code/q3_ui/ui_serverinfo.c272
-rw-r--r--code/q3_ui/ui_servers2.c1640
-rw-r--r--code/q3_ui/ui_setup.c327
-rw-r--r--code/q3_ui/ui_signup.c286
-rw-r--r--code/q3_ui/ui_sound.c316
-rw-r--r--code/q3_ui/ui_sparena.c50
-rw-r--r--code/q3_ui/ui_specifyleague.c333
-rw-r--r--code/q3_ui/ui_specifyserver.c213
-rw-r--r--code/q3_ui/ui_splevel.c1008
-rw-r--r--code/q3_ui/ui_sppostgame.c644
-rw-r--r--code/q3_ui/ui_spreset.c194
-rw-r--r--code/q3_ui/ui_spskill.c329
-rw-r--r--code/q3_ui/ui_startserver.c1968
-rw-r--r--code/q3_ui/ui_team.c210
-rw-r--r--code/q3_ui/ui_teamorders.c449
-rw-r--r--code/q3_ui/ui_video.c1070
-rw-r--r--code/qcommon/cm_load.c839
-rw-r--r--code/qcommon/cm_local.h194
-rw-r--r--code/qcommon/cm_patch.c1771
-rw-r--r--code/qcommon/cm_patch.h103
-rw-r--r--code/qcommon/cm_polylib.c737
-rw-r--r--code/qcommon/cm_polylib.h68
-rw-r--r--code/qcommon/cm_public.h76
-rw-r--r--code/qcommon/cm_test.c478
-rw-r--r--code/qcommon/cm_trace.c1471
-rw-r--r--code/qcommon/cmd.c715
-rw-r--r--code/qcommon/cmd.c.save636
-rw-r--r--code/qcommon/common.c3317
-rw-r--r--code/qcommon/cvar.c906
-rw-r--r--code/qcommon/files.c3419
-rw-r--r--code/qcommon/huffman.c437
-rw-r--r--code/qcommon/md4.c299
-rw-r--r--code/qcommon/msg.c1757
-rw-r--r--code/qcommon/net_chan.c742
-rw-r--r--code/qcommon/qcommon.h1067
-rw-r--r--code/qcommon/qfiles.h488
-rw-r--r--code/qcommon/unzip.c4299
-rw-r--r--code/qcommon/unzip.h336
-rw-r--r--code/qcommon/vm.c835
-rw-r--r--code/qcommon/vm_interpreted.c889
-rw-r--r--code/qcommon/vm_local.h180
-rw-r--r--code/qcommon/vm_ppc.c1479
-rw-r--r--code/qcommon/vm_ppc_new.c2119
-rw-r--r--code/qcommon/vm_x86.c1196
-rw-r--r--code/quake3.sln145
-rw-r--r--code/quake3.vcproj3463
-rw-r--r--code/renderer.lnt27
-rw-r--r--code/renderer/qgl.h572
-rw-r--r--code/renderer/qgl_linked.h357
-rw-r--r--code/renderer/ref_trin.def2
-rw-r--r--code/renderer/renderer.vcproj6112
-rw-r--r--code/renderer/tr_animation.c171
-rw-r--r--code/renderer/tr_backend.c1143
-rw-r--r--code/renderer/tr_bsp.c1862
-rw-r--r--code/renderer/tr_cmds.c447
-rw-r--r--code/renderer/tr_curve.c624
-rw-r--r--code/renderer/tr_flares.c447
-rw-r--r--code/renderer/tr_font.c542
-rw-r--r--code/renderer/tr_image.c2520
-rw-r--r--code/renderer/tr_init.c1217
-rw-r--r--code/renderer/tr_light.c395
-rw-r--r--code/renderer/tr_local.h1609
-rw-r--r--code/renderer/tr_main.c1485
-rw-r--r--code/renderer/tr_marks.c443
-rw-r--r--code/renderer/tr_mesh.c397
-rw-r--r--code/renderer/tr_model.c700
-rw-r--r--code/renderer/tr_noise.c95
-rw-r--r--code/renderer/tr_public.h167
-rw-r--r--code/renderer/tr_scene.c409
-rw-r--r--code/renderer/tr_shade.c1361
-rw-r--r--code/renderer/tr_shade_calc.c1205
-rw-r--r--code/renderer/tr_shader.c3013
-rw-r--r--code/renderer/tr_shadows.c341
-rw-r--r--code/renderer/tr_sky.c845
-rw-r--r--code/renderer/tr_surface.c1215
-rw-r--r--code/renderer/tr_world.c668
-rw-r--r--code/run.bat1
-rw-r--r--code/runrelease.bat1
-rw-r--r--code/server/server.h404
-rw-r--r--code/server/sv_bot.c635
-rw-r--r--code/server/sv_ccmds.c762
-rw-r--r--code/server/sv_client.c1531
-rw-r--r--code/server/sv_game.c981
-rw-r--r--code/server/sv_init.c695
-rw-r--r--code/server/sv_main.c855
-rw-r--r--code/server/sv_net_chan.c207
-rw-r--r--code/server/sv_rankings.c1537
-rw-r--r--code/server/sv_snapshot.c682
-rw-r--r--code/server/sv_world.c691
-rw-r--r--code/splines/Splines.vcproj296
-rw-r--r--code/splines/math_angles.cpp150
-rw-r--r--code/splines/math_angles.h195
-rw-r--r--code/splines/math_matrix.cpp134
-rw-r--r--code/splines/math_matrix.h223
-rw-r--r--code/splines/math_quaternion.cpp78
-rw-r--r--code/splines/math_quaternion.h190
-rw-r--r--code/splines/math_vector.cpp144
-rw-r--r--code/splines/math_vector.h574
-rw-r--r--code/splines/q_parse.cpp535
-rw-r--r--code/splines/q_shared.cpp976
-rw-r--r--code/splines/q_shared.h810
-rw-r--r--code/splines/q_shared.hpp810
-rw-r--r--code/splines/splines.cpp1250
-rw-r--r--code/splines/splines.h1075
-rw-r--r--code/splines/util_list.h346
-rw-r--r--code/splines/util_str.cpp620
-rw-r--r--code/splines/util_str.h817
-rw-r--r--code/ui/Conscript62
-rw-r--r--code/ui/compile.bat2
-rw-r--r--code/ui/keycodes.h163
-rw-r--r--code/ui/ui.bat33
-rw-r--r--code/ui/ui.def3
-rw-r--r--code/ui/ui.q3asm12
-rw-r--r--code/ui/ui.vcproj1008
-rw-r--r--code/ui/ui_atoms.c520
-rw-r--r--code/ui/ui_gameinfo.c324
-rw-r--r--code/ui/ui_local.h1136
-rw-r--r--code/ui/ui_main.c5997
-rw-r--r--code/ui/ui_players.c1378
-rw-r--r--code/ui/ui_public.h191
-rw-r--r--code/ui/ui_shared.c5785
-rw-r--r--code/ui/ui_shared.h450
-rw-r--r--code/ui/ui_syscalls.asm101
-rw-r--r--code/ui/ui_syscalls.c401
-rw-r--r--code/ui/ui_util.c29
-rw-r--r--code/unix/ChangeLog2981
-rw-r--r--code/unix/Cons_gcc.pm47
-rw-r--r--code/unix/Conscript-client265
-rw-r--r--code/unix/Conscript-dedicated115
-rw-r--r--code/unix/Conscript-pk3135
-rw-r--r--code/unix/Conscript-sdk122
-rw-r--r--code/unix/Conscript-setup33
-rw-r--r--code/unix/LinuxSupport/CHANGES-1.32.txt150
-rw-r--r--code/unix/LinuxSupport/INSTALL52
-rw-r--r--code/unix/LinuxSupport/index.html283
-rw-r--r--code/unix/LinuxSupport/udp_wide_README.txt20
-rw-r--r--code/unix/LinuxSupport/udp_wide_broadcast.patch57
-rw-r--r--code/unix/Makefile2119
-rw-r--r--code/unix/Makefile.Game285
-rw-r--r--code/unix/Quake3.kdelnk12
-rw-r--r--code/unix/README.EULA184
-rw-r--r--code/unix/README.Linux352
-rw-r--r--code/unix/README.Q3Test306
-rw-r--r--code/unix/build_setup.sh125
-rw-r--r--code/unix/cons6828
-rw-r--r--code/unix/extract_ver.pl9
-rw-r--r--code/unix/ftol.nasm151
-rw-r--r--code/unix/linux_common.c344
-rw-r--r--code/unix/linux_glimp.c1780
-rw-r--r--code/unix/linux_joystick.c207
-rw-r--r--code/unix/linux_local.h49
-rw-r--r--code/unix/linux_qgl.c4153
-rw-r--r--code/unix/linux_signals.c61
-rw-r--r--code/unix/linux_snd.c293
-rw-r--r--code/unix/matha.s425
-rw-r--r--code/unix/pcons-2.3.17911
-rw-r--r--code/unix/q3test.spec.sh52
-rw-r--r--code/unix/qasm.h480
-rw-r--r--code/unix/quake3.gifbin0 -> 1378 bytes
-rw-r--r--code/unix/quake3.xpm161
-rw-r--r--code/unix/run-target.sh12
-rw-r--r--code/unix/snapvector.nasm95
-rw-r--r--code/unix/snd_mixa.s217
-rw-r--r--code/unix/sys_dosa.s115
-rw-r--r--code/unix/unix_glw.h38
-rw-r--r--code/unix/unix_main.c1273
-rw-r--r--code/unix/unix_net.c616
-rw-r--r--code/unix/unix_shared.c435
-rw-r--r--code/unix/vm_x86.c29
-rw-r--r--code/unix/vm_x86a.s462
-rw-r--r--code/win32/background.bmpbin0 -> 197688 bytes
-rw-r--r--code/win32/clear.bmpbin0 -> 5174 bytes
-rw-r--r--code/win32/glw_win.h51
-rw-r--r--code/win32/icon2.icobin0 -> 766 bytes
-rw-r--r--code/win32/mod-sdk-setup/GameSource.VCTbin0 -> 628735 bytes
-rw-r--r--code/win32/mod-sdk-setup/QIIIA Game Source License.docbin0 -> 34304 bytes
-rw-r--r--code/win32/mod-sdk-setup/bin/lcc.exebin0 -> 135223 bytes
-rw-r--r--code/win32/mod-sdk-setup/bin/q3asm.exebin0 -> 69632 bytes
-rw-r--r--code/win32/mod-sdk-setup/bin/q3cpp.exebin0 -> 159801 bytes
-rw-r--r--code/win32/mod-sdk-setup/bin/q3rcc.exebin0 -> 847929 bytes
-rw-r--r--code/win32/qe3.icobin0 -> 766 bytes
-rw-r--r--code/win32/resource.h44
-rw-r--r--code/win32/win_gamma.c214
-rw-r--r--code/win32/win_glimp.c1658
-rw-r--r--code/win32/win_input.c1149
-rw-r--r--code/win32/win_local.h95
-rw-r--r--code/win32/win_main.c1253
-rw-r--r--code/win32/win_net.c1031
-rw-r--r--code/win32/win_qgl.c4374
-rw-r--r--code/win32/win_shared.c306
-rw-r--r--code/win32/win_snd.c388
-rw-r--r--code/win32/win_syscon.c596
-rw-r--r--code/win32/win_wndproc.c456
-rw-r--r--code/win32/winquake.rc71
-rw-r--r--common/aselib.c933
-rw-r--r--common/aselib.h31
-rw-r--r--common/bspfile.c564
-rw-r--r--common/bspfile.h118
-rw-r--r--common/cmdlib.c1201
-rw-r--r--common/cmdlib.h160
-rw-r--r--common/imagelib.c1164
-rw-r--r--common/imagelib.h44
-rw-r--r--common/l3dslib.c300
-rw-r--r--common/l3dslib.h26
-rw-r--r--common/mathlib.c434
-rw-r--r--common/mathlib.h96
-rw-r--r--common/md4.c277
-rw-r--r--common/mutex.c197
-rw-r--r--common/mutex.h28
-rw-r--r--common/polylib.c740
-rw-r--r--common/polylib.h57
-rw-r--r--common/polyset.h51
-rw-r--r--common/qfiles.h489
-rw-r--r--common/scriplib.c375
-rw-r--r--common/scriplib.h55
-rw-r--r--common/surfaceflags.h72
-rw-r--r--common/threads.c441
-rw-r--r--common/threads.h31
-rw-r--r--common/trilib.c231
-rw-r--r--common/trilib.h26
-rw-r--r--lcc/COPYRIGHT61
-rw-r--r--lcc/LOG91
-rw-r--r--lcc/README21
-rw-r--r--lcc/README.id3
-rw-r--r--lcc/alpha/osf/tst/8q.1bk92
-rw-r--r--lcc/alpha/osf/tst/8q.2bk2
-rw-r--r--lcc/alpha/osf/tst/8q.sbk193
-rw-r--r--lcc/alpha/osf/tst/array.1bk4
-rw-r--r--lcc/alpha/osf/tst/array.2bk2
-rw-r--r--lcc/alpha/osf/tst/array.sbk260
-rw-r--r--lcc/alpha/osf/tst/cf.1bk51
-rw-r--r--lcc/alpha/osf/tst/cf.2bk0
-rw-r--r--lcc/alpha/osf/tst/cf.sbk170
-rw-r--r--lcc/alpha/osf/tst/cq.1bk45
-rw-r--r--lcc/alpha/osf/tst/cq.2bk4
-rw-r--r--lcc/alpha/osf/tst/cq.sbk16904
-rw-r--r--lcc/alpha/osf/tst/cvt.1bk11
-rw-r--r--lcc/alpha/osf/tst/cvt.2bk2
-rw-r--r--lcc/alpha/osf/tst/cvt.sbk744
-rw-r--r--lcc/alpha/osf/tst/fields.1bk5
-rw-r--r--lcc/alpha/osf/tst/fields.2bk4
-rw-r--r--lcc/alpha/osf/tst/fields.sbk325
-rw-r--r--lcc/alpha/osf/tst/front.2bk29
-rw-r--r--lcc/alpha/osf/tst/front.sbk380
-rw-r--r--lcc/alpha/osf/tst/incr.1bk0
-rw-r--r--lcc/alpha/osf/tst/incr.2bk9
-rw-r--r--lcc/alpha/osf/tst/incr.sbk151
-rw-r--r--lcc/alpha/osf/tst/init.1bk16
-rw-r--r--lcc/alpha/osf/tst/init.2bk3
-rw-r--r--lcc/alpha/osf/tst/init.sbk333
-rw-r--r--lcc/alpha/osf/tst/limits.1bk14
-rw-r--r--lcc/alpha/osf/tst/limits.2bk0
-rw-r--r--lcc/alpha/osf/tst/limits.sbk405
-rw-r--r--lcc/alpha/osf/tst/paranoia.1bk195
-rw-r--r--lcc/alpha/osf/tst/paranoia.2bk16
-rw-r--r--lcc/alpha/osf/tst/paranoia.sbk19291
-rw-r--r--lcc/alpha/osf/tst/sort.1bk20
-rw-r--r--lcc/alpha/osf/tst/sort.2bk5
-rw-r--r--lcc/alpha/osf/tst/sort.sbk323
-rw-r--r--lcc/alpha/osf/tst/spill.1bk0
-rw-r--r--lcc/alpha/osf/tst/spill.2bk6
-rw-r--r--lcc/alpha/osf/tst/spill.sbk272
-rw-r--r--lcc/alpha/osf/tst/stdarg.1bk6
-rw-r--r--lcc/alpha/osf/tst/stdarg.2bk1
-rw-r--r--lcc/alpha/osf/tst/stdarg.sbk430
-rw-r--r--lcc/alpha/osf/tst/struct.1bk5
-rw-r--r--lcc/alpha/osf/tst/struct.2bk2
-rw-r--r--lcc/alpha/osf/tst/struct.sbk443
-rw-r--r--lcc/alpha/osf/tst/switch.1bk76
-rw-r--r--lcc/alpha/osf/tst/switch.2bk7
-rw-r--r--lcc/alpha/osf/tst/switch.sbk903
-rw-r--r--lcc/alpha/osf/tst/wf1.1bk74
-rw-r--r--lcc/alpha/osf/tst/wf1.2bk2
-rw-r--r--lcc/alpha/osf/tst/wf1.sbk400
-rw-r--r--lcc/alpha/osf/tst/yacc.1bk10
-rw-r--r--lcc/alpha/osf/tst/yacc.2bk3
-rw-r--r--lcc/alpha/osf/tst/yacc.sbk2402
-rw-r--r--lcc/bin/lcc.exebin0 -> 135223 bytes
-rw-r--r--lcc/bin/q3cpp.exebin0 -> 159801 bytes
-rw-r--r--lcc/bin/q3rcc.exebin0 -> 847929 bytes
-rw-r--r--lcc/buildnt.bat3
-rw-r--r--lcc/buildnt.sh4
-rw-r--r--lcc/cpp/cpp.c322
-rw-r--r--lcc/cpp/cpp.h163
-rw-r--r--lcc/cpp/eval.c520
-rw-r--r--lcc/cpp/getopt.c52
-rw-r--r--lcc/cpp/hideset.c112
-rw-r--r--lcc/cpp/include.c122
-rw-r--r--lcc/cpp/lex.c581
-rw-r--r--lcc/cpp/macro.c515
-rw-r--r--lcc/cpp/nlist.c104
-rw-r--r--lcc/cpp/tokens.c370
-rw-r--r--lcc/cpp/unix.c116
-rw-r--r--lcc/custom.mk1
-rw-r--r--lcc/doc/4.html754
-rw-r--r--lcc/doc/bprint.183
-rw-r--r--lcc/doc/bprint.pdfbin0 -> 4963 bytes
-rw-r--r--lcc/doc/install.html796
-rw-r--r--lcc/doc/lcc.1605
-rw-r--r--lcc/doc/lcc.pdfbin0 -> 16421 bytes
-rw-r--r--lcc/etc/bprint.c475
-rw-r--r--lcc/etc/gcc-solaris.c50
-rw-r--r--lcc/etc/irix.c64
-rw-r--r--lcc/etc/lcc.c793
-rw-r--r--lcc/etc/linux.c74
-rw-r--r--lcc/etc/ops.c190
-rw-r--r--lcc/etc/osf.c53
-rw-r--r--lcc/etc/solaris.c50
-rw-r--r--lcc/etc/win32.c43
-rw-r--r--lcc/include/alpha/osf/assert.h14
-rw-r--r--lcc/include/alpha/osf/ctype.h25
-rw-r--r--lcc/include/alpha/osf/errno.h8
-rw-r--r--lcc/include/alpha/osf/float.h37
-rw-r--r--lcc/include/alpha/osf/limits.h24
-rw-r--r--lcc/include/alpha/osf/locale.h36
-rw-r--r--lcc/include/alpha/osf/math.h29
-rw-r--r--lcc/include/alpha/osf/setjmp.h10
-rw-r--r--lcc/include/alpha/osf/signal.h20
-rw-r--r--lcc/include/alpha/osf/stdarg.h28
-rw-r--r--lcc/include/alpha/osf/stddef.h22
-rw-r--r--lcc/include/alpha/osf/stdio.h113
-rw-r--r--lcc/include/alpha/osf/stdlib.h54
-rw-r--r--lcc/include/alpha/osf/string.h35
-rw-r--r--lcc/include/alpha/osf/time.h50
-rw-r--r--lcc/include/mips/irix/assert.h14
-rw-r--r--lcc/include/mips/irix/ctype.h40
-rw-r--r--lcc/include/mips/irix/errno.h8
-rw-r--r--lcc/include/mips/irix/float.h37
-rw-r--r--lcc/include/mips/irix/limits.h24
-rw-r--r--lcc/include/mips/irix/locale.h36
-rw-r--r--lcc/include/mips/irix/math.h29
-rw-r--r--lcc/include/mips/irix/setjmp.h10
-rw-r--r--lcc/include/mips/irix/signal.h20
-rw-r--r--lcc/include/mips/irix/stdarg.h22
-rw-r--r--lcc/include/mips/irix/stddef.h22
-rw-r--r--lcc/include/mips/irix/stdio.h103
-rw-r--r--lcc/include/mips/irix/stdlib.h54
-rw-r--r--lcc/include/mips/irix/string.h35
-rw-r--r--lcc/include/mips/irix/time.h48
-rw-r--r--lcc/include/sparc/solaris/assert.h14
-rw-r--r--lcc/include/sparc/solaris/ctype.h46
-rw-r--r--lcc/include/sparc/solaris/errno.h8
-rw-r--r--lcc/include/sparc/solaris/float.h37
-rw-r--r--lcc/include/sparc/solaris/limits.h24
-rw-r--r--lcc/include/sparc/solaris/locale.h36
-rw-r--r--lcc/include/sparc/solaris/math.h30
-rw-r--r--lcc/include/sparc/solaris/setjmp.h10
-rw-r--r--lcc/include/sparc/solaris/signal.h20
-rw-r--r--lcc/include/sparc/solaris/stdarg.h22
-rw-r--r--lcc/include/sparc/solaris/stddef.h22
-rw-r--r--lcc/include/sparc/solaris/stdio.h104
-rw-r--r--lcc/include/sparc/solaris/stdlib.h54
-rw-r--r--lcc/include/sparc/solaris/string.h35
-rw-r--r--lcc/include/sparc/solaris/time.h48
-rw-r--r--lcc/include/x86/linux/assert.h14
-rw-r--r--lcc/include/x86/linux/float.h37
-rw-r--r--lcc/include/x86/linux/stdarg.h21
-rw-r--r--lcc/lburg/gram.c680
-rw-r--r--lcc/lburg/gram.y202
-rw-r--r--lcc/lburg/lburg.1179
-rw-r--r--lcc/lburg/lburg.c671
-rw-r--r--lcc/lburg/lburg.h65
-rw-r--r--lcc/lib/assert.c15
-rw-r--r--lcc/lib/bbexit.c123
-rw-r--r--lcc/lib/yynull.c12
-rw-r--r--lcc/makefile310
-rw-r--r--lcc/makefile.nt383
-rw-r--r--lcc/mips/irix/tst/8q.1bk92
-rw-r--r--lcc/mips/irix/tst/8q.2bk2
-rw-r--r--lcc/mips/irix/tst/8q.sbk169
-rw-r--r--lcc/mips/irix/tst/array.1bk4
-rw-r--r--lcc/mips/irix/tst/array.2bk2
-rw-r--r--lcc/mips/irix/tst/array.sbk235
-rw-r--r--lcc/mips/irix/tst/cf.1bk51
-rw-r--r--lcc/mips/irix/tst/cf.2bk0
-rw-r--r--lcc/mips/irix/tst/cf.sbk153
-rw-r--r--lcc/mips/irix/tst/cq.1bk48
-rw-r--r--lcc/mips/irix/tst/cq.2bk25
-rw-r--r--lcc/mips/irix/tst/cq.sbk13620
-rw-r--r--lcc/mips/irix/tst/cvt.1bk11
-rw-r--r--lcc/mips/irix/tst/cvt.2bk2
-rw-r--r--lcc/mips/irix/tst/cvt.sbk557
-rw-r--r--lcc/mips/irix/tst/fields.1bk5
-rw-r--r--lcc/mips/irix/tst/fields.2bk4
-rw-r--r--lcc/mips/irix/tst/fields.sbk304
-rw-r--r--lcc/mips/irix/tst/front.2bk29
-rw-r--r--lcc/mips/irix/tst/front.sbk416
-rw-r--r--lcc/mips/irix/tst/incr.2bk9
-rw-r--r--lcc/mips/irix/tst/incr.sbk149
-rw-r--r--lcc/mips/irix/tst/init.1bk16
-rw-r--r--lcc/mips/irix/tst/init.2bk3
-rw-r--r--lcc/mips/irix/tst/init.sbk325
-rw-r--r--lcc/mips/irix/tst/limits.1bk14
-rw-r--r--lcc/mips/irix/tst/limits.2bk0
-rw-r--r--lcc/mips/irix/tst/limits.sbk396
-rw-r--r--lcc/mips/irix/tst/paranoia.1bk178
-rw-r--r--lcc/mips/irix/tst/paranoia.2bk16
-rw-r--r--lcc/mips/irix/tst/paranoia.sbk18657
-rw-r--r--lcc/mips/irix/tst/sort.1bk20
-rw-r--r--lcc/mips/irix/tst/sort.2bk5
-rw-r--r--lcc/mips/irix/tst/sort.sbk308
-rw-r--r--lcc/mips/irix/tst/spill.2bk6
-rw-r--r--lcc/mips/irix/tst/spill.sbk271
-rw-r--r--lcc/mips/irix/tst/stdarg.1bk6
-rw-r--r--lcc/mips/irix/tst/stdarg.2bk1
-rw-r--r--lcc/mips/irix/tst/stdarg.sbk395
-rw-r--r--lcc/mips/irix/tst/struct.1bk5
-rw-r--r--lcc/mips/irix/tst/struct.2bk2
-rw-r--r--lcc/mips/irix/tst/struct.sbk485
-rw-r--r--lcc/mips/irix/tst/switch.1bk76
-rw-r--r--lcc/mips/irix/tst/switch.2bk5
-rw-r--r--lcc/mips/irix/tst/switch.sbk836
-rw-r--r--lcc/mips/irix/tst/wf1.1bk74
-rw-r--r--lcc/mips/irix/tst/wf1.2bk2
-rw-r--r--lcc/mips/irix/tst/wf1.sbk378
-rw-r--r--lcc/mips/irix/tst/yacc.1bk10
-rw-r--r--lcc/mips/irix/tst/yacc.2bk3
-rw-r--r--lcc/mips/irix/tst/yacc.sbk2236
-rw-r--r--lcc/msdev/rcc.dsp240
-rw-r--r--lcc/msdev/rcc.dsw29
-rw-r--r--lcc/packing.lst432
-rw-r--r--lcc/sparc/solaris/tst/8q.1bk92
-rw-r--r--lcc/sparc/solaris/tst/8q.2bk2
-rw-r--r--lcc/sparc/solaris/tst/8q.sbk144
-rw-r--r--lcc/sparc/solaris/tst/array.1bk4
-rw-r--r--lcc/sparc/solaris/tst/array.2bk2
-rw-r--r--lcc/sparc/solaris/tst/array.sbk172
-rw-r--r--lcc/sparc/solaris/tst/cf.1bk51
-rw-r--r--lcc/sparc/solaris/tst/cf.2bk0
-rw-r--r--lcc/sparc/solaris/tst/cf.sbk143
-rw-r--r--lcc/sparc/solaris/tst/cq.1bk48
-rw-r--r--lcc/sparc/solaris/tst/cq.2bk25
-rw-r--r--lcc/sparc/solaris/tst/cq.sbk13322
-rw-r--r--lcc/sparc/solaris/tst/cvt.1bk11
-rw-r--r--lcc/sparc/solaris/tst/cvt.2bk2
-rw-r--r--lcc/sparc/solaris/tst/cvt.sbk715
-rw-r--r--lcc/sparc/solaris/tst/fields.1bk5
-rw-r--r--lcc/sparc/solaris/tst/fields.2bk4
-rw-r--r--lcc/sparc/solaris/tst/fields.sbk309
-rw-r--r--lcc/sparc/solaris/tst/front.2bk29
-rw-r--r--lcc/sparc/solaris/tst/front.sbk260
-rw-r--r--lcc/sparc/solaris/tst/incr.1bk0
-rw-r--r--lcc/sparc/solaris/tst/incr.2bk9
-rw-r--r--lcc/sparc/solaris/tst/incr.sbk107
-rw-r--r--lcc/sparc/solaris/tst/init.1bk16
-rw-r--r--lcc/sparc/solaris/tst/init.2bk3
-rw-r--r--lcc/sparc/solaris/tst/init.sbk277
-rw-r--r--lcc/sparc/solaris/tst/limits.1bk14
-rw-r--r--lcc/sparc/solaris/tst/limits.2bk0
-rw-r--r--lcc/sparc/solaris/tst/limits.sbk384
-rw-r--r--lcc/sparc/solaris/tst/paranoia.1bk178
-rw-r--r--lcc/sparc/solaris/tst/paranoia.2bk16
-rw-r--r--lcc/sparc/solaris/tst/paranoia.sbk21068
-rw-r--r--lcc/sparc/solaris/tst/sort.1bk20
-rw-r--r--lcc/sparc/solaris/tst/sort.2bk5
-rw-r--r--lcc/sparc/solaris/tst/sort.sbk202
-rw-r--r--lcc/sparc/solaris/tst/spill.1bk0
-rw-r--r--lcc/sparc/solaris/tst/spill.2bk6
-rw-r--r--lcc/sparc/solaris/tst/spill.sbk207
-rw-r--r--lcc/sparc/solaris/tst/stdarg.1bk6
-rw-r--r--lcc/sparc/solaris/tst/stdarg.2bk1
-rw-r--r--lcc/sparc/solaris/tst/stdarg.sbk376
-rw-r--r--lcc/sparc/solaris/tst/struct.1bk5
-rw-r--r--lcc/sparc/solaris/tst/struct.2bk2
-rw-r--r--lcc/sparc/solaris/tst/struct.sbk377
-rw-r--r--lcc/sparc/solaris/tst/switch.1bk76
-rw-r--r--lcc/sparc/solaris/tst/switch.2bk5
-rw-r--r--lcc/sparc/solaris/tst/switch.sbk713
-rw-r--r--lcc/sparc/solaris/tst/wf1.1bk74
-rw-r--r--lcc/sparc/solaris/tst/wf1.2bk2
-rw-r--r--lcc/sparc/solaris/tst/wf1.sbk311
-rw-r--r--lcc/sparc/solaris/tst/yacc.1bk10
-rw-r--r--lcc/sparc/solaris/tst/yacc.2bk3
-rw-r--r--lcc/sparc/solaris/tst/yacc.sbk2247
-rw-r--r--lcc/src/2html.c555
-rw-r--r--lcc/src/alloc.c94
-rw-r--r--lcc/src/alpha.md1192
-rw-r--r--lcc/src/asdl.c399
-rw-r--r--lcc/src/bind.c23
-rw-r--r--lcc/src/bytecode.c365
-rw-r--r--lcc/src/c.h723
-rw-r--r--lcc/src/config.h102
-rw-r--r--lcc/src/dag.c735
-rw-r--r--lcc/src/dagcheck.md210
-rw-r--r--lcc/src/decl.c1160
-rw-r--r--lcc/src/enode.c543
-rw-r--r--lcc/src/error.c137
-rw-r--r--lcc/src/event.c28
-rw-r--r--lcc/src/expr.c709
-rw-r--r--lcc/src/gen.c830
-rw-r--r--lcc/src/init.c318
-rw-r--r--lcc/src/inits.c8
-rw-r--r--lcc/src/input.c134
-rw-r--r--lcc/src/lex.c922
-rw-r--r--lcc/src/list.c56
-rw-r--r--lcc/src/main.c225
-rw-r--r--lcc/src/mips.md1120
-rw-r--r--lcc/src/null.c74
-rw-r--r--lcc/src/output.c134
-rw-r--r--lcc/src/pass2.c665
-rw-r--r--lcc/src/prof.c227
-rw-r--r--lcc/src/profio.c276
-rw-r--r--lcc/src/rcc.asdl70
-rw-r--r--lcc/src/run.sh51
-rw-r--r--lcc/src/simp.c587
-rw-r--r--lcc/src/sparc.md1163
-rw-r--r--lcc/src/stab.c330
-rw-r--r--lcc/src/stab.h113
-rw-r--r--lcc/src/stmt.c697
-rw-r--r--lcc/src/string.c122
-rw-r--r--lcc/src/sym.c315
-rw-r--r--lcc/src/symbolic.c494
-rw-r--r--lcc/src/token.h133
-rw-r--r--lcc/src/trace.c180
-rw-r--r--lcc/src/tree.c223
-rw-r--r--lcc/src/types.c748
-rw-r--r--lcc/src/x86.md998
-rw-r--r--lcc/src/x86linux.md1081
-rw-r--r--lcc/tst/8q.00
-rw-r--r--lcc/tst/8q.c39
-rw-r--r--lcc/tst/array.00
-rw-r--r--lcc/tst/array.c48
-rw-r--r--lcc/tst/cf.032
-rw-r--r--lcc/tst/cf.c32
-rw-r--r--lcc/tst/cq.00
-rw-r--r--lcc/tst/cq.c5316
-rw-r--r--lcc/tst/cvt.00
-rw-r--r--lcc/tst/cvt.c35
-rw-r--r--lcc/tst/fields.00
-rw-r--r--lcc/tst/fields.c34
-rw-r--r--lcc/tst/front.00
-rw-r--r--lcc/tst/front.c120
-rw-r--r--lcc/tst/incr.00
-rw-r--r--lcc/tst/incr.c39
-rw-r--r--lcc/tst/init.00
-rw-r--r--lcc/tst/init.c59
-rw-r--r--lcc/tst/limits.00
-rw-r--r--lcc/tst/limits.c19
-rw-r--r--lcc/tst/paranoia.00
-rw-r--r--lcc/tst/paranoia.c2203
-rw-r--r--lcc/tst/sort.00
-rw-r--r--lcc/tst/sort.c65
-rw-r--r--lcc/tst/spill.00
-rw-r--r--lcc/tst/spill.c17
-rw-r--r--lcc/tst/stdarg.00
-rw-r--r--lcc/tst/stdarg.c51
-rw-r--r--lcc/tst/struct.00
-rw-r--r--lcc/tst/struct.c69
-rw-r--r--lcc/tst/switch.00
-rw-r--r--lcc/tst/switch.c137
-rw-r--r--lcc/tst/wf1.0115
-rw-r--r--lcc/tst/wf1.c101
-rw-r--r--lcc/tst/yacc.01
-rw-r--r--lcc/tst/yacc.c591
-rw-r--r--lcc/x86/linux/tst/8q.1bk92
-rw-r--r--lcc/x86/linux/tst/8q.2bk2
-rw-r--r--lcc/x86/linux/tst/8q.sbk180
-rw-r--r--lcc/x86/linux/tst/array.1bk4
-rw-r--r--lcc/x86/linux/tst/array.2bk2
-rw-r--r--lcc/x86/linux/tst/array.sbk235
-rw-r--r--lcc/x86/linux/tst/cf.1bk51
-rw-r--r--lcc/x86/linux/tst/cf.2bk0
-rw-r--r--lcc/x86/linux/tst/cf.sbk161
-rw-r--r--lcc/x86/linux/tst/cq.1bk48
-rw-r--r--lcc/x86/linux/tst/cq.2bk25
-rw-r--r--lcc/x86/linux/tst/cq.sbk15756
-rw-r--r--lcc/x86/linux/tst/cvt.1bk11
-rw-r--r--lcc/x86/linux/tst/cvt.2bk2
-rw-r--r--lcc/x86/linux/tst/cvt.sbk792
-rw-r--r--lcc/x86/linux/tst/fields.1bk5
-rw-r--r--lcc/x86/linux/tst/fields.2bk4
-rw-r--r--lcc/x86/linux/tst/fields.sbk321
-rw-r--r--lcc/x86/linux/tst/front.2bk29
-rw-r--r--lcc/x86/linux/tst/front.sbk530
-rw-r--r--lcc/x86/linux/tst/incr.1bk0
-rw-r--r--lcc/x86/linux/tst/incr.2bk9
-rw-r--r--lcc/x86/linux/tst/incr.sbk181
-rw-r--r--lcc/x86/linux/tst/init.1bk16
-rw-r--r--lcc/x86/linux/tst/init.2bk3
-rw-r--r--lcc/x86/linux/tst/init.sbk336
-rw-r--r--lcc/x86/linux/tst/limits.1bk14
-rw-r--r--lcc/x86/linux/tst/limits.2bk0
-rw-r--r--lcc/x86/linux/tst/limits.sbk396
-rw-r--r--lcc/x86/linux/tst/paranoia.1bk183
-rw-r--r--lcc/x86/linux/tst/paranoia.2bk16
-rw-r--r--lcc/x86/linux/tst/paranoia.sbk20248
-rw-r--r--lcc/x86/linux/tst/sort.1bk20
-rw-r--r--lcc/x86/linux/tst/sort.2bk5
-rw-r--r--lcc/x86/linux/tst/sort.sbk330
-rw-r--r--lcc/x86/linux/tst/spill.1bk0
-rw-r--r--lcc/x86/linux/tst/spill.2bk6
-rw-r--r--lcc/x86/linux/tst/spill.sbk282
-rw-r--r--lcc/x86/linux/tst/stdarg.1bk6
-rw-r--r--lcc/x86/linux/tst/stdarg.2bk1
-rw-r--r--lcc/x86/linux/tst/stdarg.sbk395
-rw-r--r--lcc/x86/linux/tst/struct.1bk5
-rw-r--r--lcc/x86/linux/tst/struct.2bk2
-rw-r--r--lcc/x86/linux/tst/struct.sbk477
-rw-r--r--lcc/x86/linux/tst/switch.1bk76
-rw-r--r--lcc/x86/linux/tst/switch.2bk5
-rw-r--r--lcc/x86/linux/tst/switch.sbk899
-rw-r--r--lcc/x86/linux/tst/wf1.1bk74
-rw-r--r--lcc/x86/linux/tst/wf1.2bk2
-rw-r--r--lcc/x86/linux/tst/wf1.sbk437
-rw-r--r--lcc/x86/linux/tst/yacc.1bk10
-rw-r--r--lcc/x86/linux/tst/yacc.2bk3
-rw-r--r--lcc/x86/linux/tst/yacc.sbk2526
-rw-r--r--lcc/x86/win32/tst/8q.1bk92
-rw-r--r--lcc/x86/win32/tst/8q.2bk2
-rw-r--r--lcc/x86/win32/tst/8q.sbk176
-rw-r--r--lcc/x86/win32/tst/array.1bk4
-rw-r--r--lcc/x86/win32/tst/array.2bk2
-rw-r--r--lcc/x86/win32/tst/array.sbk240
-rw-r--r--lcc/x86/win32/tst/cf.1bk51
-rw-r--r--lcc/x86/win32/tst/cf.2bk0
-rw-r--r--lcc/x86/win32/tst/cf.sbk185
-rw-r--r--lcc/x86/win32/tst/cq.1bk48
-rw-r--r--lcc/x86/win32/tst/cq.2bk25
-rw-r--r--lcc/x86/win32/tst/cq.sbk16642
-rw-r--r--lcc/x86/win32/tst/cvt.1bk11
-rw-r--r--lcc/x86/win32/tst/cvt.2bk2
-rw-r--r--lcc/x86/win32/tst/cvt.sbk742
-rw-r--r--lcc/x86/win32/tst/fields.1bk5
-rw-r--r--lcc/x86/win32/tst/fields.2bk4
-rw-r--r--lcc/x86/win32/tst/fields.sbk323
-rw-r--r--lcc/x86/win32/tst/front.2bk29
-rw-r--r--lcc/x86/win32/tst/front.sbk436
-rw-r--r--lcc/x86/win32/tst/incr.1bk0
-rw-r--r--lcc/x86/win32/tst/incr.2bk9
-rw-r--r--lcc/x86/win32/tst/incr.sbk166
-rw-r--r--lcc/x86/win32/tst/init.1bk16
-rw-r--r--lcc/x86/win32/tst/init.2bk3
-rw-r--r--lcc/x86/win32/tst/init.sbk336
-rw-r--r--lcc/x86/win32/tst/limits.1bk14
-rw-r--r--lcc/x86/win32/tst/limits.2bk0
-rw-r--r--lcc/x86/win32/tst/limits.sbk414
-rw-r--r--lcc/x86/win32/tst/paranoia.1bk179
-rw-r--r--lcc/x86/win32/tst/paranoia.2bk16
-rw-r--r--lcc/x86/win32/tst/paranoia.sbk20480
-rw-r--r--lcc/x86/win32/tst/sort.1bk20
-rw-r--r--lcc/x86/win32/tst/sort.2bk5
-rw-r--r--lcc/x86/win32/tst/sort.sbk324
-rw-r--r--lcc/x86/win32/tst/spill.1bk0
-rw-r--r--lcc/x86/win32/tst/spill.2bk6
-rw-r--r--lcc/x86/win32/tst/spill.sbk259
-rw-r--r--lcc/x86/win32/tst/stdarg.1bk6
-rw-r--r--lcc/x86/win32/tst/stdarg.2bk1
-rw-r--r--lcc/x86/win32/tst/stdarg.sbk415
-rw-r--r--lcc/x86/win32/tst/struct.1bk5
-rw-r--r--lcc/x86/win32/tst/struct.2bk2
-rw-r--r--lcc/x86/win32/tst/struct.sbk453
-rw-r--r--lcc/x86/win32/tst/switch.1bk76
-rw-r--r--lcc/x86/win32/tst/switch.2bk5
-rw-r--r--lcc/x86/win32/tst/switch.sbk960
-rw-r--r--lcc/x86/win32/tst/wf1.1bk74
-rw-r--r--lcc/x86/win32/tst/wf1.2bk2
-rw-r--r--lcc/x86/win32/tst/wf1.sbk451
-rw-r--r--lcc/x86/win32/tst/yacc.1bk10
-rw-r--r--lcc/x86/win32/tst/yacc.2bk3
-rw-r--r--lcc/x86/win32/tst/yacc.sbk2489
-rw-r--r--libs/cmdlib.h97
-rw-r--r--libs/cmdlib/cmdlib.cpp550
-rw-r--r--libs/cmdlib/cmdlib.vcproj156
-rw-r--r--libs/jpeg6/README385
-rw-r--r--libs/jpeg6/jchuff.h34
-rw-r--r--libs/jpeg6/jcomapi.cpp94
-rw-r--r--libs/jpeg6/jconfig.h41
-rw-r--r--libs/jpeg6/jdapimin.cpp400
-rw-r--r--libs/jpeg6/jdapistd.cpp275
-rw-r--r--libs/jpeg6/jdatasrc.cpp204
-rw-r--r--libs/jpeg6/jdcoefct.cpp725
-rw-r--r--libs/jpeg6/jdcolor.cpp367
-rw-r--r--libs/jpeg6/jdct.h176
-rw-r--r--libs/jpeg6/jddctmgr.cpp270
-rw-r--r--libs/jpeg6/jdhuff.cpp574
-rw-r--r--libs/jpeg6/jdhuff.h202
-rw-r--r--libs/jpeg6/jdinput.cpp381
-rw-r--r--libs/jpeg6/jdmainct.cpp512
-rw-r--r--libs/jpeg6/jdmarker.cpp1052
-rw-r--r--libs/jpeg6/jdmaster.cpp557
-rw-r--r--libs/jpeg6/jdpostct.cpp290
-rw-r--r--libs/jpeg6/jdsample.cpp478
-rw-r--r--libs/jpeg6/jdtrans.cpp122
-rw-r--r--libs/jpeg6/jerror.cpp231
-rw-r--r--libs/jpeg6/jerror.h273
-rw-r--r--libs/jpeg6/jfdctflt.cpp168
-rw-r--r--libs/jpeg6/jidctflt.cpp241
-rw-r--r--libs/jpeg6/jinclude.h91
-rw-r--r--libs/jpeg6/jmemmgr.cpp1115
-rw-r--r--libs/jpeg6/jmemnobs.cpp103
-rw-r--r--libs/jpeg6/jmemsys.h182
-rw-r--r--libs/jpeg6/jmorecfg.h346
-rw-r--r--libs/jpeg6/jpeg6.vcproj603
-rw-r--r--libs/jpeg6/jpegint.h388
-rw-r--r--libs/jpeg6/jpgload.cpp142
-rw-r--r--libs/jpeg6/jutils.cpp175
-rw-r--r--libs/jpeg6/jversion.h14
-rw-r--r--libs/jpeglib.h1087
-rw-r--r--libs/pak/pak.vcproj173
-rw-r--r--libs/pak/pakstuff.cpp1209
-rw-r--r--libs/pak/unzip.cpp4546
-rw-r--r--libs/pak/unzip.h300
-rw-r--r--libs/pakstuff.h141
-rw-r--r--libs/str.h214
-rw-r--r--q3asm/Makefile13
-rw-r--r--q3asm/README.Id10
-rw-r--r--q3asm/cmdlib.c1206
-rw-r--r--q3asm/cmdlib.h160
-rw-r--r--q3asm/lib.txt31
-rw-r--r--q3asm/mathlib.h94
-rw-r--r--q3asm/notes.txt16
-rw-r--r--q3asm/ops.txt132
-rw-r--r--q3asm/opstrings.h175
-rw-r--r--q3asm/q3asm.c1047
-rw-r--r--q3asm/q3asm.sln28
-rw-r--r--q3asm/q3asm.vcproj195
-rw-r--r--q3asm/qfiles.h485
-rw-r--r--q3map/brush.c861
-rw-r--r--q3map/brush_primit.c52
-rw-r--r--q3map/bsp.c605
-rw-r--r--q3map/facebsp.c379
-rw-r--r--q3map/fog.c554
-rw-r--r--q3map/gldraw.c232
-rw-r--r--q3map/glfile.c148
-rw-r--r--q3map/leakfile.c100
-rw-r--r--q3map/light.c2149
-rw-r--r--q3map/light.h151
-rw-r--r--q3map/light_trace.c944
-rw-r--r--q3map/lightmaps.c395
-rw-r--r--q3map/lightv.c5748
-rw-r--r--q3map/makefile148
-rw-r--r--q3map/map.c1251
-rw-r--r--q3map/mesh.c682
-rw-r--r--q3map/mesh.h48
-rw-r--r--q3map/misc_model.c472
-rw-r--r--q3map/nodraw.c47
-rw-r--r--q3map/patch.c286
-rw-r--r--q3map/portals.c843
-rw-r--r--q3map/prtfile.c272
-rw-r--r--q3map/q3map.sln56
-rw-r--r--q3map/q3map.vcproj1606
-rw-r--r--q3map/qbsp.h455
-rw-r--r--q3map/shaders.c608
-rw-r--r--q3map/shaders.h71
-rw-r--r--q3map/soundv.c5742
-rw-r--r--q3map/surface.c1158
-rw-r--r--q3map/terrain.c1255
-rw-r--r--q3map/tjunction.c551
-rw-r--r--q3map/tree.c146
-rw-r--r--q3map/vis.c1197
-rw-r--r--q3map/vis.h162
-rw-r--r--q3map/visflow.c1657
-rw-r--r--q3map/writebsp.c418
-rw-r--r--q3radiant/BMP.H101
-rw-r--r--q3radiant/BRUSH.H124
-rw-r--r--q3radiant/BSInput.cpp115
-rw-r--r--q3radiant/BSInput.h76
-rw-r--r--q3radiant/BSPFILE.H379
-rw-r--r--q3radiant/Bmp.cpp417
-rw-r--r--q3radiant/Brush.cpp4595
-rw-r--r--q3radiant/BrushScript.cpp672
-rw-r--r--q3radiant/CAMERA.H51
-rw-r--r--q3radiant/CSG.CPP686
-rw-r--r--q3radiant/CamWnd.cpp1165
-rw-r--r--q3radiant/CamWnd.h120
-rw-r--r--q3radiant/CapDialog.cpp64
-rw-r--r--q3radiant/CapDialog.h69
-rw-r--r--q3radiant/CharBuffer.h109
-rw-r--r--q3radiant/ChildFrm.cpp86
-rw-r--r--q3radiant/ChildFrm.h73
-rw-r--r--q3radiant/CommandsDlg.cpp109
-rw-r--r--q3radiant/CommandsDlg.h67
-rw-r--r--q3radiant/DRAG.CPP828
-rw-r--r--q3radiant/DialogInfo.cpp94
-rw-r--r--q3radiant/DialogInfo.h69
-rw-r--r--q3radiant/DialogTextures.cpp89
-rw-r--r--q3radiant/DialogTextures.h69
-rw-r--r--q3radiant/DialogThick.cpp66
-rw-r--r--q3radiant/DialogThick.h68
-rw-r--r--q3radiant/DlgEvent.cpp65
-rw-r--r--q3radiant/DlgEvent.h69
-rw-r--r--q3radiant/ECLASS.CPP932
-rw-r--r--q3radiant/ENTITY.CPP933
-rw-r--r--q3radiant/ENTITY.H76
-rw-r--r--q3radiant/ENTITYW.H68
-rw-r--r--q3radiant/EPAIRS.H1402
-rw-r--r--q3radiant/EditWnd.cpp61
-rw-r--r--q3radiant/EditWnd.h71
-rw-r--r--q3radiant/EntityListDlg.cpp152
-rw-r--r--q3radiant/EntityListDlg.h72
-rw-r--r--q3radiant/EpairsWrapper.h63
-rw-r--r--q3radiant/FNMATCH.CPP87
-rw-r--r--q3radiant/FNMATCH.H27
-rw-r--r--q3radiant/FindTextureDlg.cpp175
-rw-r--r--q3radiant/FindTextureDlg.h83
-rw-r--r--q3radiant/GLINGR.H97
-rw-r--r--q3radiant/GLInterface.cpp93
-rw-r--r--q3radiant/GLW_WIN.H49
-rw-r--r--q3radiant/GroupBar.cpp84
-rw-r--r--q3radiant/GroupBar.h69
-rw-r--r--q3radiant/GroupDlg.cpp655
-rw-r--r--q3radiant/GroupDlg.h90
-rw-r--r--q3radiant/IBSPFrontend.h101
-rw-r--r--q3radiant/ICON1.ICObin0 -> 766 bytes
-rw-r--r--q3radiant/IEpairs.cpp185
-rw-r--r--q3radiant/IEpairs.h83
-rw-r--r--q3radiant/IMessaging.h119
-rw-r--r--q3radiant/IPluginEntities.h105
-rw-r--r--q3radiant/ISelectedFace.h113
-rw-r--r--q3radiant/IShaders.cpp86
-rw-r--r--q3radiant/IShaders.h79
-rw-r--r--q3radiant/LBMLIB.CPP1329
-rw-r--r--q3radiant/LBMLIB.H40
-rw-r--r--q3radiant/LstToolBar.cpp59
-rw-r--r--q3radiant/LstToolBar.h69
-rw-r--r--q3radiant/MAP.CPP1062
-rw-r--r--q3radiant/MAP.H59
-rw-r--r--q3radiant/MATHLIB.CPP311
-rw-r--r--q3radiant/MATHLIB.H86
-rw-r--r--q3radiant/MRU.CPP671
-rw-r--r--q3radiant/MRU.H100
-rw-r--r--q3radiant/MainFrm.cpp5224
-rw-r--r--q3radiant/MainFrm.h504
-rw-r--r--q3radiant/MapInfo.cpp114
-rw-r--r--q3radiant/MapInfo.h70
-rw-r--r--q3radiant/Messaging.cpp137
-rw-r--r--q3radiant/Messaging.h46
-rw-r--r--q3radiant/NameDlg.cpp79
-rw-r--r--q3radiant/NameDlg.h69
-rw-r--r--q3radiant/NewProjDlg.cpp64
-rw-r--r--q3radiant/NewProjDlg.h67
-rw-r--r--q3radiant/PARSE.CPP148
-rw-r--r--q3radiant/PARSE.H34
-rw-r--r--q3radiant/PMESH.CPP5136
-rw-r--r--q3radiant/PMESH.H21
-rw-r--r--q3radiant/POINTS.CPP156
-rw-r--r--q3radiant/PatchDensityDlg.cpp89
-rw-r--r--q3radiant/PatchDensityDlg.h69
-rw-r--r--q3radiant/PatchDialog.cpp354
-rw-r--r--q3radiant/PatchDialog.h102
-rw-r--r--q3radiant/PlugIn.cpp297
-rw-r--r--q3radiant/PlugIn.h82
-rw-r--r--q3radiant/PlugInManager.cpp1665
-rw-r--r--q3radiant/PlugInManager.h100
-rw-r--r--q3radiant/PluginEntities.cpp101
-rw-r--r--q3radiant/PrefsDlg.cpp578
-rw-r--r--q3radiant/PrefsDlg.h161
-rw-r--r--q3radiant/QE3.CPP751
-rw-r--r--q3radiant/QE3.H669
-rw-r--r--q3radiant/QEDEFS.H164
-rw-r--r--q3radiant/QERTYPES.H454
-rw-r--r--q3radiant/QFILES.H481
-rw-r--r--q3radiant/QGL.H456
-rw-r--r--q3radiant/QGL_WIN.C1230
-rw-r--r--q3radiant/QGL_WIN.CPP1520
-rw-r--r--q3radiant/RADBSP.CPP77
-rw-r--r--q3radiant/RADEditView.cpp84
-rw-r--r--q3radiant/RADEditView.h75
-rw-r--r--q3radiant/RADEditWnd.cpp75
-rw-r--r--q3radiant/RADEditWnd.h73
-rw-r--r--q3radiant/RADKEYS.INI67
-rw-r--r--q3radiant/Radiant.clw1957
-rw-r--r--q3radiant/Radiant.cpp261
-rw-r--r--q3radiant/Radiant.h71
-rw-r--r--q3radiant/Radiant.rc2838
-rw-r--r--q3radiant/Radiant.sln95
-rw-r--r--q3radiant/Radiant.vcproj3381
-rw-r--r--q3radiant/RadiantDoc.cpp105
-rw-r--r--q3radiant/RadiantDoc.h78
-rw-r--r--q3radiant/RadiantView.cpp126
-rw-r--r--q3radiant/RadiantView.h87
-rw-r--r--q3radiant/RotateDlg.cpp130
-rw-r--r--q3radiant/RotateDlg.h78
-rw-r--r--q3radiant/SELECT.CPP1800
-rw-r--r--q3radiant/SELECT.H91
-rw-r--r--q3radiant/ScaleDialog.cpp68
-rw-r--r--q3radiant/ScaleDialog.h69
-rw-r--r--q3radiant/ScriptDlg.cpp103
-rw-r--r--q3radiant/ScriptDlg.h70
-rw-r--r--q3radiant/SelectedFace.cpp136
-rw-r--r--q3radiant/ShaderEdit.cpp66
-rw-r--r--q3radiant/ShaderEdit.h70
-rw-r--r--q3radiant/ShaderInfo.cpp69
-rw-r--r--q3radiant/ShaderInfo.h55
-rw-r--r--q3radiant/StdAfx.cpp27
-rw-r--r--q3radiant/StdAfx.h154
-rw-r--r--q3radiant/SurfaceDlg.cpp983
-rw-r--r--q3radiant/SurfaceDlg.h107
-rw-r--r--q3radiant/SurfacePlugin.cpp82
-rw-r--r--q3radiant/TexEdit.cpp85
-rw-r--r--q3radiant/TexEdit.h76
-rw-r--r--q3radiant/TexWnd.cpp3186
-rw-r--r--q3radiant/TexWnd.h88
-rw-r--r--q3radiant/TextureBar.cpp208
-rw-r--r--q3radiant/TextureBar.h85
-rw-r--r--q3radiant/TextureLayout.cpp80
-rw-r--r--q3radiant/TextureLayout.h69
-rw-r--r--q3radiant/TextureLoad.cpp80
-rw-r--r--q3radiant/TextureLoad.h68
-rw-r--r--q3radiant/Textures.h96
-rw-r--r--q3radiant/ToolWnd.cpp55
-rw-r--r--q3radiant/ToolWnd.h68
-rw-r--r--q3radiant/Undo.cpp884
-rw-r--r--q3radiant/Undo.h64
-rw-r--r--q3radiant/VERTSEL.CPP372
-rw-r--r--q3radiant/VIEW.H53
-rw-r--r--q3radiant/WIN_CAM.CPP274
-rw-r--r--q3radiant/WIN_DLG.CPP616
-rw-r--r--q3radiant/WIN_QE3.CPP753
-rw-r--r--q3radiant/WIN_QE3.RC2693
-rw-r--r--q3radiant/WIN_XY.CPP310
-rw-r--r--q3radiant/WIN_Z.CPP192
-rw-r--r--q3radiant/WaveOpen.cpp98
-rw-r--r--q3radiant/WaveOpen.h58
-rw-r--r--q3radiant/Win_ent.cpp1411
-rw-r--r--q3radiant/Win_main.cpp1085
-rw-r--r--q3radiant/Winding.cpp817
-rw-r--r--q3radiant/Winding.h70
-rw-r--r--q3radiant/XY.H39
-rw-r--r--q3radiant/XYWnd.cpp3629
-rw-r--r--q3radiant/XYWnd.h219
-rw-r--r--q3radiant/Z.CPP431
-rw-r--r--q3radiant/Z.H42
-rw-r--r--q3radiant/ZView.cpp163
-rw-r--r--q3radiant/ZView.h83
-rw-r--r--q3radiant/ZWnd.cpp264
-rw-r--r--q3radiant/ZWnd.h90
-rw-r--r--q3radiant/brush_primit.cpp461
-rw-r--r--q3radiant/cameratargetdlg.cpp71
-rw-r--r--q3radiant/cameratargetdlg.h68
-rw-r--r--q3radiant/cbrushstub.cpp76
-rw-r--r--q3radiant/dlgcamera.cpp395
-rw-r--r--q3radiant/dlgcamera.h98
-rw-r--r--q3radiant/igl.h261
-rw-r--r--q3radiant/iscriplib.h87
-rw-r--r--q3radiant/isurfaceplugin.h216
-rw-r--r--q3radiant/qerplugin.h566
-rw-r--r--q3radiant/res/BEVEL.BMPbin0 -> 486 bytes
-rw-r--r--q3radiant/res/BITMAP2.BMPbin0 -> 614 bytes
-rw-r--r--q3radiant/res/BMP00001.BMPbin0 -> 614 bytes
-rw-r--r--q3radiant/res/BMP00002.BMPbin0 -> 4198 bytes
-rw-r--r--q3radiant/res/BMP0002.BMPbin0 -> 4078 bytes
-rw-r--r--q3radiant/res/DEFTEX.WALbin0 -> 5540 bytes
-rw-r--r--q3radiant/res/ENDCAP.BMPbin0 -> 486 bytes
-rw-r--r--q3radiant/res/IBEVEL.BMPbin0 -> 486 bytes
-rw-r--r--q3radiant/res/IENDCAP.BMPbin0 -> 486 bytes
-rw-r--r--q3radiant/res/Q.BMPbin0 -> 47936 bytes
-rw-r--r--q3radiant/res/RADIANT3.GIFbin0 -> 19737 bytes
-rw-r--r--q3radiant/res/Radiant.icobin0 -> 1078 bytes
-rw-r--r--q3radiant/res/Radiant.rc213
-rw-r--r--q3radiant/res/RadiantDoc.icobin0 -> 1078 bytes
-rw-r--r--q3radiant/res/TOOLBAR1.BMPbin0 -> 2878 bytes
-rw-r--r--q3radiant/res/TOOLBAR2.BMPbin0 -> 478 bytes
-rw-r--r--q3radiant/res/Toolbar.bmpbin0 -> 718 bytes
-rw-r--r--q3radiant/res/VIEWDEFA.BMPbin0 -> 614 bytes
-rw-r--r--q3radiant/res/VIEWOPPO.BMPbin0 -> 614 bytes
-rw-r--r--q3radiant/res/bmp00003.bmpbin0 -> 1014 bytes
-rw-r--r--q3radiant/res/icon2.icobin0 -> 766 bytes
-rw-r--r--q3radiant/res/logo_sm3dfx.bmpbin0 -> 4918 bytes
-rw-r--r--q3radiant/res/shaderbar.bmpbin0 -> 1198 bytes
-rw-r--r--q3radiant/res/shaderdoc.icobin0 -> 1078 bytes
-rw-r--r--q3radiant/res/shaderframe.icobin0 -> 1078 bytes
-rw-r--r--q3radiant/resource.h840
-rw-r--r--q3radiant/splines/Splines.vcproj296
-rw-r--r--q3radiant/splines/math_angles.cpp150
-rw-r--r--q3radiant/splines/math_angles.h195
-rw-r--r--q3radiant/splines/math_matrix.cpp134
-rw-r--r--q3radiant/splines/math_matrix.h223
-rw-r--r--q3radiant/splines/math_quaternion.cpp78
-rw-r--r--q3radiant/splines/math_quaternion.h190
-rw-r--r--q3radiant/splines/math_vector.cpp144
-rw-r--r--q3radiant/splines/math_vector.h572
-rw-r--r--q3radiant/splines/q_parse.cpp535
-rw-r--r--q3radiant/splines/q_shared.cpp976
-rw-r--r--q3radiant/splines/q_shared.h798
-rw-r--r--q3radiant/splines/splines.cpp1244
-rw-r--r--q3radiant/splines/splines.h1080
-rw-r--r--q3radiant/splines/util_list.h346
-rw-r--r--q3radiant/splines/util_str.cpp618
-rw-r--r--q3radiant/splines/util_str.h817
-rw-r--r--q3radiant/terrain.cpp1735
-rw-r--r--q3radiant/terrain.h75
-rw-r--r--ui/hud.txt7
-rw-r--r--ui/hud2.txt7
-rw-r--r--ui/ingame.txt16
-rw-r--r--ui/menudef.h308
-rw-r--r--ui/menus.txt39
1409 files changed, 806066 insertions, 0 deletions
diff --git a/COPYING.txt b/COPYING.txt
new file mode 100644
index 0000000..98443f3
--- /dev/null
+++ b/COPYING.txt
@@ -0,0 +1,281 @@
+ 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
+
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..0dcc701
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,193 @@
+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
diff --git a/code/Construct b/code/Construct
new file mode 100644
index 0000000..82e6e0d
--- /dev/null
+++ b/code/Construct
@@ -0,0 +1,431 @@
+# -*- 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
+"
+;
diff --git a/code/Makefile b/code/Makefile
new file mode 100644
index 0000000..5e403ae
--- /dev/null
+++ b/code/Makefile
@@ -0,0 +1,3 @@
+# 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
diff --git a/code/botlib/aasfile.h b/code/botlib/aasfile.h
new file mode 100644
index 0000000..7fdc26a
--- /dev/null
+++ b/code/botlib/aasfile.h
@@ -0,0 +1,267 @@
+/*
+===========================================================================
+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
+*/
diff --git a/code/botlib/be_aas_bsp.h b/code/botlib/be_aas_bsp.h
new file mode 100644
index 0000000..aa05e4b
--- /dev/null
+++ b/code/botlib/be_aas_bsp.h
@@ -0,0 +1,89 @@
+/*
+===========================================================================
+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);
+
diff --git a/code/botlib/be_aas_bspq3.c b/code/botlib/be_aas_bspq3.c
new file mode 100644
index 0000000..97c286d
--- /dev/null
+++ b/code/botlib/be_aas_bspq3.c
@@ -0,0 +1,487 @@
+/*
+===========================================================================
+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
diff --git a/code/botlib/be_aas_cluster.c b/code/botlib/be_aas_cluster.c
new file mode 100644
index 0000000..118dd0a
--- /dev/null
+++ b/code/botlib/be_aas_cluster.c
@@ -0,0 +1,1545 @@
+/*
+===========================================================================
+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
diff --git a/code/botlib/be_aas_cluster.h b/code/botlib/be_aas_cluster.h
new file mode 100644
index 0000000..86a4bfd
--- /dev/null
+++ b/code/botlib/be_aas_cluster.h
@@ -0,0 +1,38 @@
+/*
+===========================================================================
+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
+
diff --git a/code/botlib/be_aas_debug.c b/code/botlib/be_aas_debug.c
new file mode 100644
index 0000000..a665c0c
--- /dev/null
+++ b/code/botlib/be_aas_debug.c
@@ -0,0 +1,777 @@
+/*
+===========================================================================
+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);
+}
diff --git a/code/botlib/be_aas_debug.h b/code/botlib/be_aas_debug.h
new file mode 100644
index 0000000..ad0f2a2
--- /dev/null
+++ b/code/botlib/be_aas_debug.h
@@ -0,0 +1,62 @@
+/*
+===========================================================================
+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);
+
diff --git a/code/botlib/be_aas_def.h b/code/botlib/be_aas_def.h
new file mode 100644
index 0000000..72bb3e6
--- /dev/null
+++ b/code/botlib/be_aas_def.h
@@ -0,0 +1,306 @@
+/*
+===========================================================================
+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
diff --git a/code/botlib/be_aas_entity.c b/code/botlib/be_aas_entity.c
new file mode 100644
index 0000000..e11356b
--- /dev/null
+++ b/code/botlib/be_aas_entity.c
@@ -0,0 +1,437 @@
+/*
+===========================================================================
+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
diff --git a/code/botlib/be_aas_entity.h b/code/botlib/be_aas_entity.h
new file mode 100644
index 0000000..fc3675b
--- /dev/null
+++ b/code/botlib/be_aas_entity.h
@@ -0,0 +1,63 @@
+/*
+===========================================================================
+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);
+
diff --git a/code/botlib/be_aas_file.c b/code/botlib/be_aas_file.c
new file mode 100644
index 0000000..50d644e
--- /dev/null
+++ b/code/botlib/be_aas_file.c
@@ -0,0 +1,582 @@
+/*
+===========================================================================
+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
diff --git a/code/botlib/be_aas_file.h b/code/botlib/be_aas_file.h
new file mode 100644
index 0000000..0d9383e
--- /dev/null
+++ b/code/botlib/be_aas_file.h
@@ -0,0 +1,42 @@
+/*
+===========================================================================
+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
+
diff --git a/code/botlib/be_aas_funcs.h b/code/botlib/be_aas_funcs.h
new file mode 100644
index 0000000..e70f348
--- /dev/null
+++ b/code/botlib/be_aas_funcs.h
@@ -0,0 +1,47 @@
+/*
+===========================================================================
+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
diff --git a/code/botlib/be_aas_main.c b/code/botlib/be_aas_main.c
new file mode 100644
index 0000000..dac1ce3
--- /dev/null
+++ b/code/botlib/be_aas_main.c
@@ -0,0 +1,429 @@
+/*
+===========================================================================
+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 AAS file should be written
+ //or there is a forced data optimization
+ if (aasworld.savefile || ((int)LibVarGetValue("forcewrite")))
+ {
+ //optimize the AAS data
+ if ((int)LibVarValue("aasoptimize", "0")) AAS_Optimize();
+ //save the AAS file
+ if (AAS_WriteAASFile(aasworld.filename))
+ {
+ botimport.Print(PRT_MESSAGE, "%s written succesfully\n", aasworld.filename);
+ } //end if
+ else
+ {
+ botimport.Print(PRT_ERROR, "couldn't write %s\n", aasworld.filename);
+ } //end else
+ } //end if
+ //initialize the routing
+ AAS_InitRouting();
+ //at this point AAS is initialized
+ AAS_SetInitialized();
+} //end of the function AAS_ContinueInit
+//===========================================================================
+// called at the start of every frame
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_StartFrame(float time)
+{
+ aasworld.time = time;
+ //unlink all entities that were not updated last frame
+ AAS_UnlinkInvalidEntities();
+ //invalidate the entities
+ AAS_InvalidateEntities();
+ //initialize AAS
+ AAS_ContinueInit(time);
+ //
+ aasworld.frameroutingupdates = 0;
+ //
+ if (bot_developer)
+ {
+ if (LibVarGetValue("showcacheupdates"))
+ {
+ AAS_RoutingInfo();
+ LibVarSet("showcacheupdates", "0");
+ } //end if
+ if (LibVarGetValue("showmemoryusage"))
+ {
+ PrintUsedMemorySize();
+ LibVarSet("showmemoryusage", "0");
+ } //end if
+ if (LibVarGetValue("memorydump"))
+ {
+ PrintMemoryLabels();
+ LibVarSet("memorydump", "0");
+ } //end if
+ } //end if
+ //
+ if (saveroutingcache->value)
+ {
+ AAS_WriteRouteCache();
+ LibVarSet("saveroutingcache", "0");
+ } //end if
+ //
+ aasworld.numframes++;
+ return BLERR_NOERROR;
+} //end of the function AAS_StartFrame
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_Time(void)
+{
+ return aasworld.time;
+} //end of the function AAS_Time
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj )
+{
+ vec3_t pVec, vec;
+
+ VectorSubtract( point, vStart, pVec );
+ VectorSubtract( vEnd, vStart, vec );
+ VectorNormalize( vec );
+ // project onto the directional vector for this segment
+ VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
+} //end of the function AAS_ProjectPointOntoVector
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_LoadFiles(const char *mapname)
+{
+ int errnum;
+ char aasfile[MAX_PATH];
+// char bspfile[MAX_PATH];
+
+ strcpy(aasworld.mapname, mapname);
+ //NOTE: first reset the entity links into the AAS areas and BSP leaves
+ // the AAS link heap and BSP link heap are reset after respectively the
+ // AAS file and BSP file are loaded
+ AAS_ResetEntityLinks();
+ // load bsp info
+ AAS_LoadBSPFile();
+
+ //load the aas file
+ Com_sprintf(aasfile, MAX_PATH, "maps/%s.aas", mapname);
+ errnum = AAS_LoadAASFile(aasfile);
+ if (errnum != BLERR_NOERROR)
+ return errnum;
+
+ botimport.Print(PRT_MESSAGE, "loaded %s\n", aasfile);
+ strncpy(aasworld.filename, aasfile, MAX_PATH);
+ return BLERR_NOERROR;
+} //end of the function AAS_LoadFiles
+//===========================================================================
+// called everytime a map changes
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_LoadMap(const char *mapname)
+{
+ int errnum;
+
+ //if no mapname is provided then the string indexes are updated
+ if (!mapname)
+ {
+ return 0;
+ } //end if
+ //
+ aasworld.initialized = qfalse;
+ //NOTE: free the routing caches before loading a new map because
+ // to free the caches the old number of areas, number of clusters
+ // and number of areas in a clusters must be available
+ AAS_FreeRoutingCaches();
+ //load the map
+ errnum = AAS_LoadFiles(mapname);
+ if (errnum != BLERR_NOERROR)
+ {
+ aasworld.loaded = qfalse;
+ return errnum;
+ } //end if
+ //
+ AAS_InitSettings();
+ //initialize the AAS link heap for the new map
+ AAS_InitAASLinkHeap();
+ //initialize the AAS linked entities for the new map
+ AAS_InitAASLinkedEntities();
+ //initialize reachability for the new map
+ AAS_InitReachability();
+ //initialize the alternative routing
+ AAS_InitAlternativeRouting();
+ //everything went ok
+ return 0;
+} //end of the function AAS_LoadMap
+//===========================================================================
+// called when the library is first loaded
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_Setup(void)
+{
+ aasworld.maxclients = (int) LibVarValue("maxclients", "128");
+ aasworld.maxentities = (int) LibVarValue("maxentities", "1024");
+ // as soon as it's set to 1 the routing cache will be saved
+ saveroutingcache = LibVar("saveroutingcache", "0");
+ //allocate memory for the entities
+ if (aasworld.entities) FreeMemory(aasworld.entities);
+ aasworld.entities = (aas_entity_t *) GetClearedHunkMemory(aasworld.maxentities * sizeof(aas_entity_t));
+ //invalidate all the entities
+ AAS_InvalidateEntities();
+ //force some recalculations
+ //LibVarSet("forceclustering", "1"); //force clustering calculation
+ //LibVarSet("forcereachability", "1"); //force reachability calculation
+ aasworld.numframes = 0;
+ return BLERR_NOERROR;
+} //end of the function AAS_Setup
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_Shutdown(void)
+{
+ AAS_ShutdownAlternativeRouting();
+ //
+ AAS_DumpBSPData();
+ //free routing caches
+ AAS_FreeRoutingCaches();
+ //free aas link heap
+ AAS_FreeAASLinkHeap();
+ //free aas linked entities
+ AAS_FreeAASLinkedEntities();
+ //free the aas data
+ AAS_DumpAASData();
+ //free the entities
+ if (aasworld.entities) FreeMemory(aasworld.entities);
+ //clear the aasworld structure
+ Com_Memset(&aasworld, 0, sizeof(aas_t));
+ //aas has not been initialized
+ aasworld.initialized = qfalse;
+ //NOTE: as soon as a new .bsp file is loaded the .bsp file memory is
+ // freed an reallocated, so there's no need to free that memory here
+ //print shutdown
+ botimport.Print(PRT_MESSAGE, "AAS shutdown.\n");
+} //end of the function AAS_Shutdown
diff --git a/code/botlib/be_aas_main.h b/code/botlib/be_aas_main.h
new file mode 100644
index 0000000..d8dc41c
--- /dev/null
+++ b/code/botlib/be_aas_main.h
@@ -0,0 +1,61 @@
+/*
+===========================================================================
+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.h
+ *
+ * desc: AAS
+ *
+ * $Archive: /source/code/botlib/be_aas_main.h $
+ *
+ *****************************************************************************/
+
+#ifdef AASINTERN
+
+extern aas_t aasworld;
+
+//AAS error message
+void QDECL AAS_Error(char *fmt, ...);
+//set AAS initialized
+void AAS_SetInitialized(void);
+//setup AAS with the given number of entities and clients
+int AAS_Setup(void);
+//shutdown AAS
+void AAS_Shutdown(void);
+//start a new map
+int AAS_LoadMap(const char *mapname);
+//start a new time frame
+int AAS_StartFrame(float time);
+#endif //AASINTERN
+
+//returns true if AAS is initialized
+int AAS_Initialized(void);
+//returns true if the AAS file is loaded
+int AAS_Loaded(void);
+//returns the model name from the given index
+char *AAS_ModelFromIndex(int index);
+//returns the index from the given model name
+int AAS_IndexFromModel(char *modelname);
+//returns the current time
+float AAS_Time(void);
+//
+void AAS_ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj );
diff --git a/code/botlib/be_aas_move.c b/code/botlib/be_aas_move.c
new file mode 100644
index 0000000..3433153
--- /dev/null
+++ b/code/botlib/be_aas_move.c
@@ -0,0 +1,1101 @@
+/*
+===========================================================================
+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_move.c
+ *
+ * desc: AAS
+ *
+ * $Archive: /MissionPack/code/botlib/be_aas_move.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_aas_funcs.h"
+#include "be_aas_def.h"
+
+extern botlib_import_t botimport;
+
+aas_settings_t aassettings;
+
+//#define AAS_MOVE_DEBUG
+
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs)
+{
+ vec3_t end;
+ bsp_trace_t trace;
+
+ VectorCopy(origin, end);
+ end[2] -= 100;
+ trace = AAS_Trace(origin, mins, maxs, end, 0, CONTENTS_SOLID);
+ if (trace.startsolid) return qfalse;
+ VectorCopy(trace.endpos, origin);
+ return qtrue;
+} //end of the function AAS_DropToFloor
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_InitSettings(void)
+{
+ aassettings.phys_gravitydirection[0] = 0;
+ aassettings.phys_gravitydirection[1] = 0;
+ aassettings.phys_gravitydirection[2] = -1;
+ aassettings.phys_friction = LibVarValue("phys_friction", "6");
+ aassettings.phys_stopspeed = LibVarValue("phys_stopspeed", "100");
+ aassettings.phys_gravity = LibVarValue("phys_gravity", "800");
+ aassettings.phys_waterfriction = LibVarValue("phys_waterfriction", "1");
+ aassettings.phys_watergravity = LibVarValue("phys_watergravity", "400");
+ aassettings.phys_maxvelocity = LibVarValue("phys_maxvelocity", "320");
+ aassettings.phys_maxwalkvelocity = LibVarValue("phys_maxwalkvelocity", "320");
+ aassettings.phys_maxcrouchvelocity = LibVarValue("phys_maxcrouchvelocity", "100");
+ aassettings.phys_maxswimvelocity = LibVarValue("phys_maxswimvelocity", "150");
+ aassettings.phys_walkaccelerate = LibVarValue("phys_walkaccelerate", "10");
+ aassettings.phys_airaccelerate = LibVarValue("phys_airaccelerate", "1");
+ aassettings.phys_swimaccelerate = LibVarValue("phys_swimaccelerate", "4");
+ aassettings.phys_maxstep = LibVarValue("phys_maxstep", "19");
+ aassettings.phys_maxsteepness = LibVarValue("phys_maxsteepness", "0.7");
+ aassettings.phys_maxwaterjump = LibVarValue("phys_maxwaterjump", "18");
+ aassettings.phys_maxbarrier = LibVarValue("phys_maxbarrier", "33");
+ aassettings.phys_jumpvel = LibVarValue("phys_jumpvel", "270");
+ aassettings.phys_falldelta5 = LibVarValue("phys_falldelta5", "40");
+ aassettings.phys_falldelta10 = LibVarValue("phys_falldelta10", "60");
+ aassettings.rs_waterjump = LibVarValue("rs_waterjump", "400");
+ aassettings.rs_teleport = LibVarValue("rs_teleport", "50");
+ aassettings.rs_barrierjump = LibVarValue("rs_barrierjump", "100");
+ aassettings.rs_startcrouch = LibVarValue("rs_startcrouch", "300");
+ aassettings.rs_startgrapple = LibVarValue("rs_startgrapple", "500");
+ aassettings.rs_startwalkoffledge = LibVarValue("rs_startwalkoffledge", "70");
+ aassettings.rs_startjump = LibVarValue("rs_startjump", "300");
+ aassettings.rs_rocketjump = LibVarValue("rs_rocketjump", "500");
+ aassettings.rs_bfgjump = LibVarValue("rs_bfgjump", "500");
+ aassettings.rs_jumppad = LibVarValue("rs_jumppad", "250");
+ aassettings.rs_aircontrolledjumppad = LibVarValue("rs_aircontrolledjumppad", "300");
+ aassettings.rs_funcbob = LibVarValue("rs_funcbob", "300");
+ aassettings.rs_startelevator = LibVarValue("rs_startelevator", "50");
+ aassettings.rs_falldamage5 = LibVarValue("rs_falldamage5", "300");
+ aassettings.rs_falldamage10 = LibVarValue("rs_falldamage10", "500");
+ aassettings.rs_maxfallheight = LibVarValue("rs_maxfallheight", "0");
+ aassettings.rs_maxjumpfallheight = LibVarValue("rs_maxjumpfallheight", "450");
+} //end of the function AAS_InitSettings
+//===========================================================================
+// returns qtrue if the bot is against a ladder
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AgainstLadder(vec3_t origin)
+{
+ int areanum, i, facenum, side;
+ vec3_t org;
+ aas_plane_t *plane;
+ aas_face_t *face;
+ aas_area_t *area;
+
+ VectorCopy(origin, org);
+ areanum = AAS_PointAreaNum(org);
+ if (!areanum)
+ {
+ org[0] += 1;
+ areanum = AAS_PointAreaNum(org);
+ if (!areanum)
+ {
+ org[1] += 1;
+ areanum = AAS_PointAreaNum(org);
+ if (!areanum)
+ {
+ org[0] -= 2;
+ areanum = AAS_PointAreaNum(org);
+ if (!areanum)
+ {
+ org[1] -= 2;
+ areanum = AAS_PointAreaNum(org);
+ } //end if
+ } //end if
+ } //end if
+ } //end if
+ //if in solid... wrrr shouldn't happen
+ if (!areanum) return qfalse;
+ //if not in a ladder area
+ if (!(aasworld.areasettings[areanum].areaflags & AREA_LADDER)) return qfalse;
+ //if a crouch only area
+ if (!(aasworld.areasettings[areanum].presencetype & PRESENCE_NORMAL)) return qfalse;
+ //
+ area = &aasworld.areas[areanum];
+ for (i = 0; i < area->numfaces; i++)
+ {
+ facenum = aasworld.faceindex[area->firstface + i];
+ side = facenum < 0;
+ face = &aasworld.faces[abs(facenum)];
+ //if the face isn't a ladder face
+ if (!(face->faceflags & FACE_LADDER)) continue;
+ //get the plane the face is in
+ plane = &aasworld.planes[face->planenum ^ side];
+ //if the origin is pretty close to the plane
+ if (abs(DotProduct(plane->normal, origin) - plane->dist) < 3)
+ {
+ if (AAS_PointInsideFace(abs(facenum), origin, 0.1f)) return qtrue;
+ } //end if
+ } //end for
+ return qfalse;
+} //end of the function AAS_AgainstLadder
+//===========================================================================
+// returns qtrue if the bot is on the ground
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_OnGround(vec3_t origin, int presencetype, int passent)
+{
+ aas_trace_t trace;
+ vec3_t end, up = {0, 0, 1};
+ aas_plane_t *plane;
+
+ VectorCopy(origin, end);
+ end[2] -= 10;
+
+ trace = AAS_TraceClientBBox(origin, end, presencetype, passent);
+
+ //if in solid
+ if (trace.startsolid) return qfalse;
+ //if nothing hit at all
+ if (trace.fraction >= 1.0) return qfalse;
+ //if too far from the hit plane
+ if (origin[2] - trace.endpos[2] > 10) return qfalse;
+ //check if the plane isn't too steep
+ plane = AAS_PlaneFromNum(trace.planenum);
+ if (DotProduct(plane->normal, up) < aassettings.phys_maxsteepness) return qfalse;
+ //the bot is on the ground
+ return qtrue;
+} //end of the function AAS_OnGround
+//===========================================================================
+// returns qtrue if a bot at the given position is swimming
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_Swimming(vec3_t origin)
+{
+ vec3_t testorg;
+
+ VectorCopy(origin, testorg);
+ testorg[2] -= 2;
+ if (AAS_PointContents(testorg) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER)) return qtrue;
+ return qfalse;
+} //end of the function AAS_Swimming
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+static vec3_t VEC_UP = {0, -1, 0};
+static vec3_t MOVEDIR_UP = {0, 0, 1};
+static vec3_t VEC_DOWN = {0, -2, 0};
+static vec3_t MOVEDIR_DOWN = {0, 0, -1};
+
+void AAS_SetMovedir(vec3_t angles, vec3_t movedir)
+{
+ if (VectorCompare(angles, VEC_UP))
+ {
+ VectorCopy(MOVEDIR_UP, movedir);
+ } //end if
+ else if (VectorCompare(angles, VEC_DOWN))
+ {
+ VectorCopy(MOVEDIR_DOWN, movedir);
+ } //end else if
+ else
+ {
+ AngleVectors(angles, movedir, NULL, NULL);
+ } //end else
+} //end of the function AAS_SetMovedir
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_JumpReachRunStart(aas_reachability_t *reach, vec3_t runstart)
+{
+ vec3_t hordir, start, cmdmove;
+ aas_clientmove_t move;
+
+ //
+ hordir[0] = reach->start[0] - reach->end[0];
+ hordir[1] = reach->start[1] - reach->end[1];
+ hordir[2] = 0;
+ VectorNormalize(hordir);
+ //start point
+ VectorCopy(reach->start, start);
+ start[2] += 1;
+ //get command movement
+ VectorScale(hordir, 400, cmdmove);
+ //
+ AAS_PredictClientMovement(&move, -1, start, PRESENCE_NORMAL, qtrue,
+ vec3_origin, cmdmove, 1, 2, 0.1f,
+ SE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA|
+ SE_HITGROUNDDAMAGE|SE_GAP, 0, qfalse);
+ VectorCopy(move.endpos, runstart);
+ //don't enter slime or lava and don't fall from too high
+ if (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE))
+ {
+ VectorCopy(start, runstart);
+ } //end if
+} //end of the function AAS_JumpReachRunStart
+//===========================================================================
+// returns the Z velocity when rocket jumping at the origin
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_WeaponJumpZVelocity(vec3_t origin, float radiusdamage)
+{
+ vec3_t kvel, v, start, end, forward, right, viewangles, dir;
+ float mass, knockback, points;
+ vec3_t rocketoffset = {8, 8, -8};
+ vec3_t botmins = {-16, -16, -24};
+ vec3_t botmaxs = {16, 16, 32};
+ bsp_trace_t bsptrace;
+
+ //look down (90 degrees)
+ viewangles[PITCH] = 90;
+ viewangles[YAW] = 0;
+ viewangles[ROLL] = 0;
+ //get the start point shooting from
+ VectorCopy(origin, start);
+ start[2] += 8; //view offset Z
+ AngleVectors(viewangles, forward, right, NULL);
+ start[0] += forward[0] * rocketoffset[0] + right[0] * rocketoffset[1];
+ start[1] += forward[1] * rocketoffset[0] + right[1] * rocketoffset[1];
+ start[2] += forward[2] * rocketoffset[0] + right[2] * rocketoffset[1] + rocketoffset[2];
+ //end point of the trace
+ VectorMA(start, 500, forward, end);
+ //trace a line to get the impact point
+ bsptrace = AAS_Trace(start, NULL, NULL, end, 1, CONTENTS_SOLID);
+ //calculate the damage the bot will get from the rocket impact
+ VectorAdd(botmins, botmaxs, v);
+ VectorMA(origin, 0.5, v, v);
+ VectorSubtract(bsptrace.endpos, v, v);
+ //
+ points = radiusdamage - 0.5 * VectorLength(v);
+ if (points < 0) points = 0;
+ //the owner of the rocket gets half the damage
+ points *= 0.5;
+ //mass of the bot (p_client.c: PutClientInServer)
+ mass = 200;
+ //knockback is the same as the damage points
+ knockback = points;
+ //direction of the damage (from trace.endpos to bot origin)
+ VectorSubtract(origin, bsptrace.endpos, dir);
+ VectorNormalize(dir);
+ //damage velocity
+ VectorScale(dir, 1600.0 * (float)knockback / mass, kvel); //the rocket jump hack...
+ //rocket impact velocity + jump velocity
+ return kvel[2] + aassettings.phys_jumpvel;
+} //end of the function AAS_WeaponJumpZVelocity
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_RocketJumpZVelocity(vec3_t origin)
+{
+ //rocket radius damage is 120 (p_weapon.c: Weapon_RocketLauncher_Fire)
+ return AAS_WeaponJumpZVelocity(origin, 120);
+} //end of the function AAS_RocketJumpZVelocity
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_BFGJumpZVelocity(vec3_t origin)
+{
+ //bfg radius damage is 1000 (p_weapon.c: weapon_bfg_fire)
+ return AAS_WeaponJumpZVelocity(origin, 120);
+} //end of the function AAS_BFGJumpZVelocity
+//===========================================================================
+// applies ground friction to the given velocity
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_Accelerate(vec3_t velocity, float frametime, vec3_t wishdir, float wishspeed, float accel)
+{
+ // q2 style
+ int i;
+ float addspeed, accelspeed, currentspeed;
+
+ currentspeed = DotProduct(velocity, wishdir);
+ addspeed = wishspeed - currentspeed;
+ if (addspeed <= 0) {
+ return;
+ }
+ accelspeed = accel*frametime*wishspeed;
+ if (accelspeed > addspeed) {
+ accelspeed = addspeed;
+ }
+
+ for (i=0 ; i<3 ; i++) {
+ velocity[i] += accelspeed*wishdir[i];
+ }
+} //end of the function AAS_Accelerate
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_AirControl(vec3_t start, vec3_t end, vec3_t velocity, vec3_t cmdmove)
+{
+ vec3_t dir;
+
+ VectorSubtract(end, start, dir);
+} //end of the function AAS_AirControl
+//===========================================================================
+// applies ground friction to the given velocity
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_ApplyFriction(vec3_t vel, float friction, float stopspeed,
+ float frametime)
+{
+ float speed, control, newspeed;
+
+ //horizontal speed
+ speed = sqrt(vel[0] * vel[0] + vel[1] * vel[1]);
+ if (speed)
+ {
+ control = speed < stopspeed ? stopspeed : speed;
+ newspeed = speed - frametime * control * friction;
+ if (newspeed < 0) newspeed = 0;
+ newspeed /= speed;
+ vel[0] *= newspeed;
+ vel[1] *= newspeed;
+ } //end if
+} //end of the function AAS_ApplyFriction
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_ClipToBBox(aas_trace_t *trace, vec3_t start, vec3_t end, int presencetype, vec3_t mins, vec3_t maxs)
+{
+ int i, j, side;
+ float front, back, frac, planedist;
+ vec3_t bboxmins, bboxmaxs, absmins, absmaxs, dir, mid;
+
+ AAS_PresenceTypeBoundingBox(presencetype, bboxmins, bboxmaxs);
+ VectorSubtract(mins, bboxmaxs, absmins);
+ VectorSubtract(maxs, bboxmins, absmaxs);
+ //
+ VectorCopy(end, trace->endpos);
+ trace->fraction = 1;
+ for (i = 0; i < 3; i++)
+ {
+ if (start[i] < absmins[i] && end[i] < absmins[i]) return qfalse;
+ if (start[i] > absmaxs[i] && end[i] > absmaxs[i]) return qfalse;
+ } //end for
+ //check bounding box collision
+ VectorSubtract(end, start, dir);
+ frac = 1;
+ for (i = 0; i < 3; i++)
+ {
+ //get plane to test collision with for the current axis direction
+ if (dir[i] > 0) planedist = absmins[i];
+ else planedist = absmaxs[i];
+ //calculate collision fraction
+ front = start[i] - planedist;
+ back = end[i] - planedist;
+ frac = front / (front-back);
+ //check if between bounding planes of next axis
+ side = i + 1;
+ if (side > 2) side = 0;
+ mid[side] = start[side] + dir[side] * frac;
+ if (mid[side] > absmins[side] && mid[side] < absmaxs[side])
+ {
+ //check if between bounding planes of next axis
+ side++;
+ if (side > 2) side = 0;
+ mid[side] = start[side] + dir[side] * frac;
+ if (mid[side] > absmins[side] && mid[side] < absmaxs[side])
+ {
+ mid[i] = planedist;
+ break;
+ } //end if
+ } //end if
+ } //end for
+ //if there was a collision
+ if (i != 3)
+ {
+ trace->startsolid = qfalse;
+ trace->fraction = frac;
+ trace->ent = 0;
+ trace->planenum = 0;
+ trace->area = 0;
+ trace->lastarea = 0;
+ //trace endpos
+ for (j = 0; j < 3; j++) trace->endpos[j] = start[j] + dir[j] * frac;
+ return qtrue;
+ } //end if
+ return qfalse;
+} //end of the function AAS_ClipToBBox
+//===========================================================================
+// predicts the movement
+// assumes regular bounding box sizes
+// NOTE: out of water jumping is not included
+// NOTE: grappling hook is not included
+//
+// Parameter: origin : origin to start with
+// presencetype : presence type to start with
+// velocity : velocity to start with
+// cmdmove : client command movement
+// cmdframes : number of frame cmdmove is valid
+// maxframes : maximum number of predicted frames
+// frametime : duration of one predicted frame
+// stopevent : events that stop the prediction
+// stopareanum : stop as soon as entered this area
+// Returns: aas_clientmove_t
+// Changes Globals: -
+//===========================================================================
+int AAS_ClientMovementPrediction(struct aas_clientmove_s *move,
+ int entnum, vec3_t origin,
+ int presencetype, int onground,
+ vec3_t velocity, vec3_t cmdmove,
+ int cmdframes,
+ int maxframes, float frametime,
+ int stopevent, int stopareanum,
+ vec3_t mins, vec3_t maxs, int visualize)
+{
+ float phys_friction, phys_stopspeed, phys_gravity, phys_waterfriction;
+ float phys_watergravity;
+ float phys_walkaccelerate, phys_airaccelerate, phys_swimaccelerate;
+ float phys_maxwalkvelocity, phys_maxcrouchvelocity, phys_maxswimvelocity;
+ float phys_maxstep, phys_maxsteepness, phys_jumpvel, friction;
+ float gravity, delta, maxvel, wishspeed, accelerate;
+ //float velchange, newvel;
+ int n, i, j, pc, step, swimming, ax, crouch, event, jump_frame, areanum;
+ int areas[20], numareas;
+ vec3_t points[20];
+ vec3_t org, end, feet, start, stepend, lastorg, wishdir;
+ vec3_t frame_test_vel, old_frame_test_vel, left_test_vel;
+ vec3_t up = {0, 0, 1};
+ aas_plane_t *plane, *plane2;
+ aas_trace_t trace, steptrace;
+
+ if (frametime <= 0) frametime = 0.1f;
+ //
+ phys_friction = aassettings.phys_friction;
+ phys_stopspeed = aassettings.phys_stopspeed;
+ phys_gravity = aassettings.phys_gravity;
+ phys_waterfriction = aassettings.phys_waterfriction;
+ phys_watergravity = aassettings.phys_watergravity;
+ phys_maxwalkvelocity = aassettings.phys_maxwalkvelocity;// * frametime;
+ phys_maxcrouchvelocity = aassettings.phys_maxcrouchvelocity;// * frametime;
+ phys_maxswimvelocity = aassettings.phys_maxswimvelocity;// * frametime;
+ phys_walkaccelerate = aassettings.phys_walkaccelerate;
+ phys_airaccelerate = aassettings.phys_airaccelerate;
+ phys_swimaccelerate = aassettings.phys_swimaccelerate;
+ phys_maxstep = aassettings.phys_maxstep;
+ phys_maxsteepness = aassettings.phys_maxsteepness;
+ phys_jumpvel = aassettings.phys_jumpvel * frametime;
+ //
+ Com_Memset(move, 0, sizeof(aas_clientmove_t));
+ Com_Memset(&trace, 0, sizeof(aas_trace_t));
+ //start at the current origin
+ VectorCopy(origin, org);
+ org[2] += 0.25;
+ //velocity to test for the first frame
+ VectorScale(velocity, frametime, frame_test_vel);
+ //
+ jump_frame = -1;
+ //predict a maximum of 'maxframes' ahead
+ for (n = 0; n < maxframes; n++)
+ {
+ swimming = AAS_Swimming(org);
+ //get gravity depending on swimming or not
+ gravity = swimming ? phys_watergravity : phys_gravity;
+ //apply gravity at the START of the frame
+ frame_test_vel[2] = frame_test_vel[2] - (gravity * 0.1 * frametime);
+ //if on the ground or swimming
+ if (onground || swimming)
+ {
+ friction = swimming ? phys_friction : phys_waterfriction;
+ //apply friction
+ VectorScale(frame_test_vel, 1/frametime, frame_test_vel);
+ AAS_ApplyFriction(frame_test_vel, friction, phys_stopspeed, frametime);
+ VectorScale(frame_test_vel, frametime, frame_test_vel);
+ } //end if
+ crouch = qfalse;
+ //apply command movement
+ if (n < cmdframes)
+ {
+ ax = 0;
+ maxvel = phys_maxwalkvelocity;
+ accelerate = phys_airaccelerate;
+ VectorCopy(cmdmove, wishdir);
+ if (onground)
+ {
+ if (cmdmove[2] < -300)
+ {
+ crouch = qtrue;
+ maxvel = phys_maxcrouchvelocity;
+ } //end if
+ //if not swimming and upmove is positive then jump
+ if (!swimming && cmdmove[2] > 1)
+ {
+ //jump velocity minus the gravity for one frame + 5 for safety
+ frame_test_vel[2] = phys_jumpvel - (gravity * 0.1 * frametime) + 5;
+ jump_frame = n;
+ //jumping so air accelerate
+ accelerate = phys_airaccelerate;
+ } //end if
+ else
+ {
+ accelerate = phys_walkaccelerate;
+ } //end else
+ ax = 2;
+ } //end if
+ if (swimming)
+ {
+ maxvel = phys_maxswimvelocity;
+ accelerate = phys_swimaccelerate;
+ ax = 3;
+ } //end if
+ else
+ {
+ wishdir[2] = 0;
+ } //end else
+ //
+ wishspeed = VectorNormalize(wishdir);
+ if (wishspeed > maxvel) wishspeed = maxvel;
+ VectorScale(frame_test_vel, 1/frametime, frame_test_vel);
+ AAS_Accelerate(frame_test_vel, frametime, wishdir, wishspeed, accelerate);
+ VectorScale(frame_test_vel, frametime, frame_test_vel);
+ /*
+ for (i = 0; i < ax; i++)
+ {
+ velchange = (cmdmove[i] * frametime) - frame_test_vel[i];
+ if (velchange > phys_maxacceleration) velchange = phys_maxacceleration;
+ else if (velchange < -phys_maxacceleration) velchange = -phys_maxacceleration;
+ newvel = frame_test_vel[i] + velchange;
+ //
+ if (frame_test_vel[i] <= maxvel && newvel > maxvel) frame_test_vel[i] = maxvel;
+ else if (frame_test_vel[i] >= -maxvel && newvel < -maxvel) frame_test_vel[i] = -maxvel;
+ else frame_test_vel[i] = newvel;
+ } //end for
+ */
+ } //end if
+ if (crouch)
+ {
+ presencetype = PRESENCE_CROUCH;
+ } //end if
+ else if (presencetype == PRESENCE_CROUCH)
+ {
+ if (AAS_PointPresenceType(org) & PRESENCE_NORMAL)
+ {
+ presencetype = PRESENCE_NORMAL;
+ } //end if
+ } //end else
+ //save the current origin
+ VectorCopy(org, lastorg);
+ //move linear during one frame
+ VectorCopy(frame_test_vel, left_test_vel);
+ j = 0;
+ do
+ {
+ VectorAdd(org, left_test_vel, end);
+ //trace a bounding box
+ trace = AAS_TraceClientBBox(org, end, presencetype, entnum);
+ //
+//#ifdef AAS_MOVE_DEBUG
+ if (visualize)
+ {
+ if (trace.startsolid) botimport.Print(PRT_MESSAGE, "PredictMovement: start solid\n");
+ AAS_DebugLine(org, trace.endpos, LINECOLOR_RED);
+ } //end if
+//#endif //AAS_MOVE_DEBUG
+ //
+ if (stopevent & (SE_ENTERAREA|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER|SE_TOUCHCLUSTERPORTAL))
+ {
+ numareas = AAS_TraceAreas(org, trace.endpos, areas, points, 20);
+ for (i = 0; i < numareas; i++)
+ {
+ if (stopevent & SE_ENTERAREA)
+ {
+ if (areas[i] == stopareanum)
+ {
+ VectorCopy(points[i], move->endpos);
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->endarea = areas[i];
+ move->trace = trace;
+ move->stopevent = SE_ENTERAREA;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ //NOTE: if not the first frame
+ if ((stopevent & SE_TOUCHJUMPPAD) && n)
+ {
+ if (aasworld.areasettings[areas[i]].contents & AREACONTENTS_JUMPPAD)
+ {
+ VectorCopy(points[i], move->endpos);
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->endarea = areas[i];
+ move->trace = trace;
+ move->stopevent = SE_TOUCHJUMPPAD;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ if (stopevent & SE_TOUCHTELEPORTER)
+ {
+ if (aasworld.areasettings[areas[i]].contents & AREACONTENTS_TELEPORTER)
+ {
+ VectorCopy(points[i], move->endpos);
+ move->endarea = areas[i];
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_TOUCHTELEPORTER;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ if (stopevent & SE_TOUCHCLUSTERPORTAL)
+ {
+ if (aasworld.areasettings[areas[i]].contents & AREACONTENTS_CLUSTERPORTAL)
+ {
+ VectorCopy(points[i], move->endpos);
+ move->endarea = areas[i];
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_TOUCHCLUSTERPORTAL;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ } //end for
+ } //end if
+ //
+ if (stopevent & SE_HITBOUNDINGBOX)
+ {
+ if (AAS_ClipToBBox(&trace, org, trace.endpos, presencetype, mins, maxs))
+ {
+ VectorCopy(trace.endpos, move->endpos);
+ move->endarea = AAS_PointAreaNum(move->endpos);
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_HITBOUNDINGBOX;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ //move the entity to the trace end point
+ VectorCopy(trace.endpos, org);
+ //if there was a collision
+ if (trace.fraction < 1.0)
+ {
+ //get the plane the bounding box collided with
+ plane = AAS_PlaneFromNum(trace.planenum);
+ //
+ if (stopevent & SE_HITGROUNDAREA)
+ {
+ if (DotProduct(plane->normal, up) > phys_maxsteepness)
+ {
+ VectorCopy(org, start);
+ start[2] += 0.5;
+ if (AAS_PointAreaNum(start) == stopareanum)
+ {
+ VectorCopy(start, move->endpos);
+ move->endarea = stopareanum;
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_HITGROUNDAREA;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ } //end if
+ //assume there's no step
+ step = qfalse;
+ //if it is a vertical plane and the bot didn't jump recently
+ if (plane->normal[2] == 0 && (jump_frame < 0 || n - jump_frame > 2))
+ {
+ //check for a step
+ VectorMA(org, -0.25, plane->normal, start);
+ VectorCopy(start, stepend);
+ start[2] += phys_maxstep;
+ steptrace = AAS_TraceClientBBox(start, stepend, presencetype, entnum);
+ //
+ if (!steptrace.startsolid)
+ {
+ plane2 = AAS_PlaneFromNum(steptrace.planenum);
+ if (DotProduct(plane2->normal, up) > phys_maxsteepness)
+ {
+ VectorSubtract(end, steptrace.endpos, left_test_vel);
+ left_test_vel[2] = 0;
+ frame_test_vel[2] = 0;
+//#ifdef AAS_MOVE_DEBUG
+ if (visualize)
+ {
+ if (steptrace.endpos[2] - org[2] > 0.125)
+ {
+ VectorCopy(org, start);
+ start[2] = steptrace.endpos[2];
+ AAS_DebugLine(org, start, LINECOLOR_BLUE);
+ } //end if
+ } //end if
+//#endif //AAS_MOVE_DEBUG
+ org[2] = steptrace.endpos[2];
+ step = qtrue;
+ } //end if
+ } //end if
+ } //end if
+ //
+ if (!step)
+ {
+ //velocity left to test for this frame is the projection
+ //of the current test velocity into the hit plane
+ VectorMA(left_test_vel, -DotProduct(left_test_vel, plane->normal),
+ plane->normal, left_test_vel);
+ //store the old velocity for landing check
+ VectorCopy(frame_test_vel, old_frame_test_vel);
+ //test velocity for the next frame is the projection
+ //of the velocity of the current frame into the hit plane
+ VectorMA(frame_test_vel, -DotProduct(frame_test_vel, plane->normal),
+ plane->normal, frame_test_vel);
+ //check for a landing on an almost horizontal floor
+ if (DotProduct(plane->normal, up) > phys_maxsteepness)
+ {
+ onground = qtrue;
+ } //end if
+ if (stopevent & SE_HITGROUNDDAMAGE)
+ {
+ delta = 0;
+ if (old_frame_test_vel[2] < 0 &&
+ frame_test_vel[2] > old_frame_test_vel[2] &&
+ !onground)
+ {
+ delta = old_frame_test_vel[2];
+ } //end if
+ else if (onground)
+ {
+ delta = frame_test_vel[2] - old_frame_test_vel[2];
+ } //end else
+ if (delta)
+ {
+ delta = delta * 10;
+ delta = delta * delta * 0.0001;
+ if (swimming) delta = 0;
+ // never take falling damage if completely underwater
+ /*
+ if (ent->waterlevel == 3) return;
+ if (ent->waterlevel == 2) delta *= 0.25;
+ if (ent->waterlevel == 1) delta *= 0.5;
+ */
+ if (delta > 40)
+ {
+ VectorCopy(org, move->endpos);
+ move->endarea = AAS_PointAreaNum(org);
+ VectorCopy(frame_test_vel, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_HITGROUNDDAMAGE;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ } //end if
+ } //end if
+ } //end if
+ //extra check to prevent endless loop
+ if (++j > 20) return qfalse;
+ //while there is a plane hit
+ } while(trace.fraction < 1.0);
+ //if going down
+ if (frame_test_vel[2] <= 10)
+ {
+ //check for a liquid at the feet of the bot
+ VectorCopy(org, feet);
+ feet[2] -= 22;
+ pc = AAS_PointContents(feet);
+ //get event from pc
+ event = SE_NONE;
+ if (pc & CONTENTS_LAVA) event |= SE_ENTERLAVA;
+ if (pc & CONTENTS_SLIME) event |= SE_ENTERSLIME;
+ if (pc & CONTENTS_WATER) event |= SE_ENTERWATER;
+ //
+ areanum = AAS_PointAreaNum(org);
+ if (aasworld.areasettings[areanum].contents & AREACONTENTS_LAVA)
+ event |= SE_ENTERLAVA;
+ if (aasworld.areasettings[areanum].contents & AREACONTENTS_SLIME)
+ event |= SE_ENTERSLIME;
+ if (aasworld.areasettings[areanum].contents & AREACONTENTS_WATER)
+ event |= SE_ENTERWATER;
+ //if in lava or slime
+ if (event & stopevent)
+ {
+ VectorCopy(org, move->endpos);
+ move->endarea = areanum;
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->stopevent = event & stopevent;
+ move->presencetype = presencetype;
+ move->endcontents = pc;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ //
+ onground = AAS_OnGround(org, presencetype, entnum);
+ //if onground and on the ground for at least one whole frame
+ if (onground)
+ {
+ if (stopevent & SE_HITGROUND)
+ {
+ VectorCopy(org, move->endpos);
+ move->endarea = AAS_PointAreaNum(org);
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_HITGROUND;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ else if (stopevent & SE_LEAVEGROUND)
+ {
+ VectorCopy(org, move->endpos);
+ move->endarea = AAS_PointAreaNum(org);
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_LEAVEGROUND;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end else if
+ else if (stopevent & SE_GAP)
+ {
+ aas_trace_t gaptrace;
+
+ VectorCopy(org, start);
+ VectorCopy(start, end);
+ end[2] -= 48 + aassettings.phys_maxbarrier;
+ gaptrace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);
+ //if solid is found the bot cannot walk any further and will not fall into a gap
+ if (!gaptrace.startsolid)
+ {
+ //if it is a gap (lower than one step height)
+ if (gaptrace.endpos[2] < org[2] - aassettings.phys_maxstep - 1)
+ {
+ if (!(AAS_PointContents(end) & CONTENTS_WATER))
+ {
+ VectorCopy(lastorg, move->endpos);
+ move->endarea = AAS_PointAreaNum(lastorg);
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->trace = trace;
+ move->stopevent = SE_GAP;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ return qtrue;
+ } //end if
+ } //end if
+ } //end if
+ } //end else if
+ } //end for
+ //
+ VectorCopy(org, move->endpos);
+ move->endarea = AAS_PointAreaNum(org);
+ VectorScale(frame_test_vel, 1/frametime, move->velocity);
+ move->stopevent = SE_NONE;
+ move->presencetype = presencetype;
+ move->endcontents = 0;
+ move->time = n * frametime;
+ move->frames = n;
+ //
+ return qtrue;
+} //end of the function AAS_ClientMovementPrediction
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_PredictClientMovement(struct aas_clientmove_s *move,
+ int entnum, vec3_t origin,
+ int presencetype, int onground,
+ vec3_t velocity, vec3_t cmdmove,
+ int cmdframes,
+ int maxframes, float frametime,
+ int stopevent, int stopareanum, int visualize)
+{
+ vec3_t mins, maxs;
+ return AAS_ClientMovementPrediction(move, entnum, origin, presencetype, onground,
+ velocity, cmdmove, cmdframes, maxframes,
+ frametime, stopevent, stopareanum,
+ mins, maxs, visualize);
+} //end of the function AAS_PredictClientMovement
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_ClientMovementHitBBox(struct aas_clientmove_s *move,
+ int entnum, vec3_t origin,
+ int presencetype, int onground,
+ vec3_t velocity, vec3_t cmdmove,
+ int cmdframes,
+ int maxframes, float frametime,
+ vec3_t mins, vec3_t maxs, int visualize)
+{
+ return AAS_ClientMovementPrediction(move, entnum, origin, presencetype, onground,
+ velocity, cmdmove, cmdframes, maxframes,
+ frametime, SE_HITBOUNDINGBOX, 0,
+ mins, maxs, visualize);
+} //end of the function AAS_ClientMovementHitBBox
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_TestMovementPrediction(int entnum, vec3_t origin, vec3_t dir)
+{
+ vec3_t velocity, cmdmove;
+ aas_clientmove_t move;
+
+ VectorClear(velocity);
+ if (!AAS_Swimming(origin)) dir[2] = 0;
+ VectorNormalize(dir);
+ VectorScale(dir, 400, cmdmove);
+ cmdmove[2] = 224;
+ AAS_ClearShownDebugLines();
+ AAS_PredictClientMovement(&move, entnum, origin, PRESENCE_NORMAL, qtrue,
+ velocity, cmdmove, 13, 13, 0.1f, SE_HITGROUND, 0, qtrue);//SE_LEAVEGROUND);
+ if (move.stopevent & SE_LEAVEGROUND)
+ {
+ botimport.Print(PRT_MESSAGE, "leave ground\n");
+ } //end if
+} //end of the function TestMovementPrediction
+//===========================================================================
+// calculates the horizontal velocity needed to perform a jump from start
+// to end
+//
+// Parameter: zvel : z velocity for jump
+// start : start position of jump
+// end : end position of jump
+// *speed : returned speed for jump
+// Returns: qfalse if too high or too far from start to end
+// Changes Globals: -
+//===========================================================================
+int AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity)
+{
+ float phys_gravity, phys_maxvelocity;
+ float maxjump, height2fall, t, top;
+ vec3_t dir;
+
+ phys_gravity = aassettings.phys_gravity;
+ phys_maxvelocity = aassettings.phys_maxvelocity;
+
+ //maximum height a player can jump with the given initial z velocity
+ maxjump = 0.5 * phys_gravity * (zvel / phys_gravity) * (zvel / phys_gravity);
+ //top of the parabolic jump
+ top = start[2] + maxjump;
+ //height the bot will fall from the top
+ height2fall = top - end[2];
+ //if the goal is to high to jump to
+ if (height2fall < 0)
+ {
+ *velocity = phys_maxvelocity;
+ return 0;
+ } //end if
+ //time a player takes to fall the height
+ t = sqrt(height2fall / (0.5 * phys_gravity));
+ //direction from start to end
+ VectorSubtract(end, start, dir);
+ //
+ if ( (t + zvel / phys_gravity) == 0.0f ) {
+ *velocity = phys_maxvelocity;
+ return 0;
+ }
+ //calculate horizontal speed
+ *velocity = sqrt(dir[0]*dir[0] + dir[1]*dir[1]) / (t + zvel / phys_gravity);
+ //the horizontal speed must be lower than the max speed
+ if (*velocity > phys_maxvelocity)
+ {
+ *velocity = phys_maxvelocity;
+ return 0;
+ } //end if
+ return 1;
+} //end of the function AAS_HorizontalVelocityForJump
diff --git a/code/botlib/be_aas_move.h b/code/botlib/be_aas_move.h
new file mode 100644
index 0000000..5705e46
--- /dev/null
+++ b/code/botlib/be_aas_move.h
@@ -0,0 +1,71 @@
+/*
+===========================================================================
+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_move.h
+ *
+ * desc: AAS
+ *
+ * $Archive: /source/code/botlib/be_aas_move.h $
+ *
+ *****************************************************************************/
+
+#ifdef AASINTERN
+extern aas_settings_t aassettings;
+#endif //AASINTERN
+
+//movement prediction
+int AAS_PredictClientMovement(struct aas_clientmove_s *move,
+ int entnum, vec3_t origin,
+ int presencetype, int onground,
+ vec3_t velocity, vec3_t cmdmove,
+ int cmdframes,
+ int maxframes, float frametime,
+ int stopevent, int stopareanum, int visualize);
+//predict movement until bounding box is hit
+int AAS_ClientMovementHitBBox(struct aas_clientmove_s *move,
+ int entnum, vec3_t origin,
+ int presencetype, int onground,
+ vec3_t velocity, vec3_t cmdmove,
+ int cmdframes,
+ int maxframes, float frametime,
+ vec3_t mins, vec3_t maxs, int visualize);
+//returns true if on the ground at the given origin
+int AAS_OnGround(vec3_t origin, int presencetype, int passent);
+//returns true if swimming at the given origin
+int AAS_Swimming(vec3_t origin);
+//returns the jump reachability run start point
+void AAS_JumpReachRunStart(struct aas_reachability_s *reach, vec3_t runstart);
+//returns true if against a ladder at the given origin
+int AAS_AgainstLadder(vec3_t origin);
+//rocket jump Z velocity when rocket-jumping at origin
+float AAS_RocketJumpZVelocity(vec3_t origin);
+//bfg jump Z velocity when bfg-jumping at origin
+float AAS_BFGJumpZVelocity(vec3_t origin);
+//calculates the horizontal velocity needed for a jump and returns true this velocity could be calculated
+int AAS_HorizontalVelocityForJump(float zvel, vec3_t start, vec3_t end, float *velocity);
+//
+void AAS_SetMovedir(vec3_t angles, vec3_t movedir);
+//
+int AAS_DropToFloor(vec3_t origin, vec3_t mins, vec3_t maxs);
+//
+void AAS_InitSettings(void);
diff --git a/code/botlib/be_aas_optimize.c b/code/botlib/be_aas_optimize.c
new file mode 100644
index 0000000..605dc4d
--- /dev/null
+++ b/code/botlib/be_aas_optimize.c
@@ -0,0 +1,312 @@
+/*
+===========================================================================
+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_optimize.c
+ *
+ * desc: decreases the .aas file size after the reachabilities have
+ * been calculated, just dumps all the faces, edges and vertexes
+ *
+ * $Archive: /MissionPack/code/botlib/be_aas_optimize.c $
+ *
+ *****************************************************************************/
+
+#include "../game/q_shared.h"
+#include "l_libvar.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_interface.h"
+#include "be_aas_def.h"
+
+typedef struct optimized_s
+{
+ //vertexes
+ int numvertexes;
+ aas_vertex_t *vertexes;
+ //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;
+ //
+ int *vertexoptimizeindex;
+ int *edgeoptimizeindex;
+ int *faceoptimizeindex;
+} optimized_t;
+
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_KeepEdge(aas_edge_t *edge)
+{
+ return 1;
+} //end of the function AAS_KeepFace
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_OptimizeEdge(optimized_t *optimized, int edgenum)
+{
+ int i, optedgenum;
+ aas_edge_t *edge, *optedge;
+
+ edge = &aasworld.edges[abs(edgenum)];
+ if (!AAS_KeepEdge(edge)) return 0;
+
+ optedgenum = optimized->edgeoptimizeindex[abs(edgenum)];
+ if (optedgenum)
+ {
+ //keep the edge reversed sign
+ if (edgenum > 0) return optedgenum;
+ else return -optedgenum;
+ } //end if
+
+ optedge = &optimized->edges[optimized->numedges];
+
+ for (i = 0; i < 2; i++)
+ {
+ if (optimized->vertexoptimizeindex[edge->v[i]])
+ {
+ optedge->v[i] = optimized->vertexoptimizeindex[edge->v[i]];
+ } //end if
+ else
+ {
+ VectorCopy(aasworld.vertexes[edge->v[i]], optimized->vertexes[optimized->numvertexes]);
+ optedge->v[i] = optimized->numvertexes;
+ optimized->vertexoptimizeindex[edge->v[i]] = optimized->numvertexes;
+ optimized->numvertexes++;
+ } //end else
+ } //end for
+ optimized->edgeoptimizeindex[abs(edgenum)] = optimized->numedges;
+ optedgenum = optimized->numedges;
+ optimized->numedges++;
+ //keep the edge reversed sign
+ if (edgenum > 0) return optedgenum;
+ else return -optedgenum;
+} //end of the function AAS_OptimizeEdge
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_KeepFace(aas_face_t *face)
+{
+ if (!(face->faceflags & FACE_LADDER)) return 0;
+ else return 1;
+} //end of the function AAS_KeepFace
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_OptimizeFace(optimized_t *optimized, int facenum)
+{
+ int i, edgenum, optedgenum, optfacenum;
+ aas_face_t *face, *optface;
+
+ face = &aasworld.faces[abs(facenum)];
+ if (!AAS_KeepFace(face)) return 0;
+
+ optfacenum = optimized->faceoptimizeindex[abs(facenum)];
+ if (optfacenum)
+ {
+ //keep the face side sign
+ if (facenum > 0) return optfacenum;
+ else return -optfacenum;
+ } //end if
+
+ optface = &optimized->faces[optimized->numfaces];
+ Com_Memcpy(optface, face, sizeof(aas_face_t));
+
+ optface->numedges = 0;
+ optface->firstedge = optimized->edgeindexsize;
+ for (i = 0; i < face->numedges; i++)
+ {
+ edgenum = aasworld.edgeindex[face->firstedge + i];
+ optedgenum = AAS_OptimizeEdge(optimized, edgenum);
+ if (optedgenum)
+ {
+ optimized->edgeindex[optface->firstedge + optface->numedges] = optedgenum;
+ optface->numedges++;
+ optimized->edgeindexsize++;
+ } //end if
+ } //end for
+ optimized->faceoptimizeindex[abs(facenum)] = optimized->numfaces;
+ optfacenum = optimized->numfaces;
+ optimized->numfaces++;
+ //keep the face side sign
+ if (facenum > 0) return optfacenum;
+ else return -optfacenum;
+} //end of the function AAS_OptimizeFace
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_OptimizeArea(optimized_t *optimized, int areanum)
+{
+ int i, facenum, optfacenum;
+ aas_area_t *area, *optarea;
+
+ area = &aasworld.areas[areanum];
+ optarea = &optimized->areas[areanum];
+ Com_Memcpy(optarea, area, sizeof(aas_area_t));
+
+ optarea->numfaces = 0;
+ optarea->firstface = optimized->faceindexsize;
+ for (i = 0; i < area->numfaces; i++)
+ {
+ facenum = aasworld.faceindex[area->firstface + i];
+ optfacenum = AAS_OptimizeFace(optimized, facenum);
+ if (optfacenum)
+ {
+ optimized->faceindex[optarea->firstface + optarea->numfaces] = optfacenum;
+ optarea->numfaces++;
+ optimized->faceindexsize++;
+ } //end if
+ } //end for
+} //end of the function AAS_OptimizeArea
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_OptimizeAlloc(optimized_t *optimized)
+{
+ optimized->vertexes = (aas_vertex_t *) GetClearedMemory(aasworld.numvertexes * sizeof(aas_vertex_t));
+ optimized->numvertexes = 0;
+ optimized->edges = (aas_edge_t *) GetClearedMemory(aasworld.numedges * sizeof(aas_edge_t));
+ optimized->numedges = 1; //edge zero is a dummy
+ optimized->edgeindex = (aas_edgeindex_t *) GetClearedMemory(aasworld.edgeindexsize * sizeof(aas_edgeindex_t));
+ optimized->edgeindexsize = 0;
+ optimized->faces = (aas_face_t *) GetClearedMemory(aasworld.numfaces * sizeof(aas_face_t));
+ optimized->numfaces = 1; //face zero is a dummy
+ optimized->faceindex = (aas_faceindex_t *) GetClearedMemory(aasworld.faceindexsize * sizeof(aas_faceindex_t));
+ optimized->faceindexsize = 0;
+ optimized->areas = (aas_area_t *) GetClearedMemory(aasworld.numareas * sizeof(aas_area_t));
+ optimized->numareas = aasworld.numareas;
+ //
+ optimized->vertexoptimizeindex = (int *) GetClearedMemory(aasworld.numvertexes * sizeof(int));
+ optimized->edgeoptimizeindex = (int *) GetClearedMemory(aasworld.numedges * sizeof(int));
+ optimized->faceoptimizeindex = (int *) GetClearedMemory(aasworld.numfaces * sizeof(int));
+} //end of the function AAS_OptimizeAlloc
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_OptimizeStore(optimized_t *optimized)
+{
+ //store the optimized vertexes
+ if (aasworld.vertexes) FreeMemory(aasworld.vertexes);
+ aasworld.vertexes = optimized->vertexes;
+ aasworld.numvertexes = optimized->numvertexes;
+ //store the optimized edges
+ if (aasworld.edges) FreeMemory(aasworld.edges);
+ aasworld.edges = optimized->edges;
+ aasworld.numedges = optimized->numedges;
+ //store the optimized edge index
+ if (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);
+ aasworld.edgeindex = optimized->edgeindex;
+ aasworld.edgeindexsize = optimized->edgeindexsize;
+ //store the optimized faces
+ if (aasworld.faces) FreeMemory(aasworld.faces);
+ aasworld.faces = optimized->faces;
+ aasworld.numfaces = optimized->numfaces;
+ //store the optimized face index
+ if (aasworld.faceindex) FreeMemory(aasworld.faceindex);
+ aasworld.faceindex = optimized->faceindex;
+ aasworld.faceindexsize = optimized->faceindexsize;
+ //store the optimized areas
+ if (aasworld.areas) FreeMemory(aasworld.areas);
+ aasworld.areas = optimized->areas;
+ aasworld.numareas = optimized->numareas;
+ //free optimize indexes
+ FreeMemory(optimized->vertexoptimizeindex);
+ FreeMemory(optimized->edgeoptimizeindex);
+ FreeMemory(optimized->faceoptimizeindex);
+} //end of the function AAS_OptimizeStore
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_Optimize(void)
+{
+ int i, sign;
+ optimized_t optimized;
+
+ AAS_OptimizeAlloc(&optimized);
+ for (i = 1; i < aasworld.numareas; i++)
+ {
+ AAS_OptimizeArea(&optimized, i);
+ } //end for
+ //reset the reachability face pointers
+ for (i = 0; i < aasworld.reachabilitysize; i++)
+ {
+ //NOTE: for TRAVEL_ELEVATOR the facenum is the model number of
+ // the elevator
+ if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_ELEVATOR) continue;
+ //NOTE: for TRAVEL_JUMPPAD the facenum is the Z velocity and the edgenum is the hor velocity
+ if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMPPAD) continue;
+ //NOTE: for TRAVEL_FUNCBOB the facenum and edgenum contain other coded information
+ if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == TRAVEL_FUNCBOB) continue;
+ //
+ sign = aasworld.reachability[i].facenum;
+ aasworld.reachability[i].facenum = optimized.faceoptimizeindex[abs(aasworld.reachability[i].facenum)];
+ if (sign < 0) aasworld.reachability[i].facenum = -aasworld.reachability[i].facenum;
+ sign = aasworld.reachability[i].edgenum;
+ aasworld.reachability[i].edgenum = optimized.edgeoptimizeindex[abs(aasworld.reachability[i].edgenum)];
+ if (sign < 0) aasworld.reachability[i].edgenum = -aasworld.reachability[i].edgenum;
+ } //end for
+ //store the optimized AAS data into aasworld
+ AAS_OptimizeStore(&optimized);
+ //print some nice stuff :)
+ botimport.Print(PRT_MESSAGE, "AAS data optimized.\n");
+} //end of the function AAS_Optimize
diff --git a/code/botlib/be_aas_optimize.h b/code/botlib/be_aas_optimize.h
new file mode 100644
index 0000000..d59bbc9
--- /dev/null
+++ b/code/botlib/be_aas_optimize.h
@@ -0,0 +1,33 @@
+/*
+===========================================================================
+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_optimize.h
+ *
+ * desc: AAS
+ *
+ * $Archive: /source/code/botlib/be_aas_optimize.h $
+ *
+ *****************************************************************************/
+
+void AAS_Optimize(void);
+
diff --git a/code/botlib/be_aas_reach.c b/code/botlib/be_aas_reach.c
new file mode 100644
index 0000000..4b69d28
--- /dev/null
+++ b/code/botlib/be_aas_reach.c
@@ -0,0 +1,4547 @@
+/*
+===========================================================================
+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_reach.c
+ *
+ * desc: reachability calculations
+ *
+ * $Archive: /MissionPack/code/botlib/be_aas_reach.c $
+ *
+ *****************************************************************************/
+
+#include "../game/q_shared.h"
+#include "l_log.h"
+#include "l_memory.h"
+#include "l_script.h"
+#include "l_libvar.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 int Sys_MilliSeconds(void);
+
+
+extern botlib_import_t botimport;
+
+//#define REACH_DEBUG
+
+//NOTE: all travel times are in hundreth of a second
+//maximum number of reachability links
+#define AAS_MAX_REACHABILITYSIZE 65536
+//number of areas reachability is calculated for each frame
+#define REACHABILITYAREASPERCYCLE 15
+//number of units reachability points are placed inside the areas
+#define INSIDEUNITS 2
+#define INSIDEUNITS_WALKEND 5
+#define INSIDEUNITS_WALKSTART 0.1
+#define INSIDEUNITS_WATERJUMP 15
+//area flag used for weapon jumping
+#define AREA_WEAPONJUMP 8192 //valid area to weapon jump to
+//number of reachabilities of each type
+int reach_swim; //swim
+int reach_equalfloor; //walk on floors with equal height
+int reach_step; //step up
+int reach_walk; //walk of step
+int reach_barrier; //jump up to a barrier
+int reach_waterjump; //jump out of water
+int reach_walkoffledge; //walk of a ledge
+int reach_jump; //jump
+int reach_ladder; //climb or descent a ladder
+int reach_teleport; //teleport
+int reach_elevator; //use an elevator
+int reach_funcbob; //use a func bob
+int reach_grapple; //grapple hook
+int reach_doublejump; //double jump
+int reach_rampjump; //ramp jump
+int reach_strafejump; //strafe jump (just normal jump but further)
+int reach_rocketjump; //rocket jump
+int reach_bfgjump; //bfg jump
+int reach_jumppad; //jump pads
+//if true grapple reachabilities are skipped
+int calcgrapplereach;
+//linked reachability
+typedef struct aas_lreachability_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
+ //
+ struct aas_lreachability_s *next;
+} aas_lreachability_t;
+//temporary reachabilities
+aas_lreachability_t *reachabilityheap; //heap with reachabilities
+aas_lreachability_t *nextreachability; //next free reachability from the heap
+aas_lreachability_t **areareachability; //reachability links for every area
+int numlreachabilities;
+
+//===========================================================================
+// returns the surface area of the given face
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_FaceArea(aas_face_t *face)
+{
+ int i, edgenum, side;
+ float total;
+ vec_t *v;
+ vec3_t d1, d2, cross;
+ aas_edge_t *edge;
+
+ edgenum = aasworld.edgeindex[face->firstedge];
+ side = edgenum < 0;
+ edge = &aasworld.edges[abs(edgenum)];
+ v = aasworld.vertexes[edge->v[side]];
+
+ total = 0;
+ for (i = 1; i < face->numedges - 1; i++)
+ {
+ edgenum = aasworld.edgeindex[face->firstedge + i];
+ side = edgenum < 0;
+ edge = &aasworld.edges[abs(edgenum)];
+ VectorSubtract(aasworld.vertexes[edge->v[side]], v, d1);
+ VectorSubtract(aasworld.vertexes[edge->v[!side]], v, d2);
+ CrossProduct(d1, d2, cross);
+ total += 0.5 * VectorLength(cross);
+ } //end for
+ return total;
+} //end of the function AAS_FaceArea
+//===========================================================================
+// returns the volume of an area
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_AreaVolume(int areanum)
+{
+ int i, edgenum, facenum, side;
+ vec_t d, a, volume;
+ vec3_t corner;
+ aas_plane_t *plane;
+ aas_edge_t *edge;
+ aas_face_t *face;
+ aas_area_t *area;
+
+ area = &aasworld.areas[areanum];
+ facenum = aasworld.faceindex[area->firstface];
+ face = &aasworld.faces[abs(facenum)];
+ edgenum = aasworld.edgeindex[face->firstedge];
+ edge = &aasworld.edges[abs(edgenum)];
+ //
+ VectorCopy(aasworld.vertexes[edge->v[0]], corner);
+
+ //make tetrahedrons to all other faces
+ volume = 0;
+ for (i = 0; i < area->numfaces; i++)
+ {
+ facenum = abs(aasworld.faceindex[area->firstface + i]);
+ face = &aasworld.faces[facenum];
+ side = face->backarea != areanum;
+ plane = &aasworld.planes[face->planenum ^ side];
+ d = -(DotProduct (corner, plane->normal) - plane->dist);
+ a = AAS_FaceArea(face);
+ volume += d * a;
+ } //end for
+
+ volume /= 3;
+ return volume;
+} //end of the function AAS_AreaVolume
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_BestReachableLinkArea(aas_link_t *areas)
+{
+ aas_link_t *link;
+
+ for (link = areas; link; link = link->next_area)
+ {
+ if (AAS_AreaGrounded(link->areanum) || AAS_AreaSwim(link->areanum))
+ {
+ return link->areanum;
+ } //end if
+ } //end for
+ //
+ for (link = areas; link; link = link->next_area)
+ {
+ if (link->areanum) return link->areanum;
+ //FIXME: this is a bad idea when the reachability is not yet
+ // calculated when the level items are loaded
+ if (AAS_AreaReachability(link->areanum))
+ return link->areanum;
+ } //end for
+ return 0;
+} //end of the function AAS_BestReachableLinkArea
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_GetJumpPadInfo(int ent, vec3_t areastart, vec3_t absmins, vec3_t absmaxs, vec3_t velocity)
+{
+ int modelnum, ent2;
+ float speed, height, gravity, time, dist, forward;
+ vec3_t origin, angles, teststart, ent2origin;
+ aas_trace_t trace;
+ char model[MAX_EPAIRKEY];
+ char target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY];
+
+ //
+ AAS_FloatForBSPEpairKey(ent, "speed", &speed);
+ if (!speed) speed = 1000;
+ VectorClear(angles);
+ //get the mins, maxs and origin of the model
+ AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY);
+ if (model[0]) modelnum = atoi(model+1);
+ else modelnum = 0;
+ AAS_BSPModelMinsMaxsOrigin(modelnum, angles, absmins, absmaxs, origin);
+ VectorAdd(origin, absmins, absmins);
+ VectorAdd(origin, absmaxs, absmaxs);
+ VectorAdd(absmins, absmaxs, origin);
+ VectorScale (origin, 0.5, origin);
+
+ //get the start areas
+ VectorCopy(origin, teststart);
+ teststart[2] += 64;
+ trace = AAS_TraceClientBBox(teststart, origin, PRESENCE_CROUCH, -1);
+ if (trace.startsolid)
+ {
+ botimport.Print(PRT_MESSAGE, "trigger_push start solid\n");
+ VectorCopy(origin, areastart);
+ } //end if
+ else
+ {
+ VectorCopy(trace.endpos, areastart);
+ } //end else
+ areastart[2] += 0.125;
+ //
+ //AAS_DrawPermanentCross(origin, 4, 4);
+ //get the target entity
+ AAS_ValueForBSPEpairKey(ent, "target", target, MAX_EPAIRKEY);
+ for (ent2 = AAS_NextBSPEntity(0); ent2; ent2 = AAS_NextBSPEntity(ent2))
+ {
+ if (!AAS_ValueForBSPEpairKey(ent2, "targetname", targetname, MAX_EPAIRKEY)) continue;
+ if (!strcmp(targetname, target)) break;
+ } //end for
+ if (!ent2)
+ {
+ botimport.Print(PRT_MESSAGE, "trigger_push without target entity %s\n", target);
+ return qfalse;
+ } //end if
+ AAS_VectorForBSPEpairKey(ent2, "origin", ent2origin);
+ //
+ height = ent2origin[2] - origin[2];
+ gravity = aassettings.phys_gravity;
+ time = sqrt( height / ( 0.5 * gravity ) );
+ if (!time)
+ {
+ botimport.Print(PRT_MESSAGE, "trigger_push without time\n");
+ return qfalse;
+ } //end if
+ // set s.origin2 to the push velocity
+ VectorSubtract ( ent2origin, origin, velocity);
+ dist = VectorNormalize( velocity);
+ forward = dist / time;
+ //FIXME: why multiply by 1.1
+ forward *= 1.1f;
+ VectorScale(velocity, forward, velocity);
+ velocity[2] = time * gravity;
+ return qtrue;
+} //end of the function AAS_GetJumpPadInfo
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs)
+{
+ int area2num, ent, bot_visualizejumppads, bestareanum;
+ float volume, bestareavolume;
+ vec3_t areastart, cmdmove, bboxmins, bboxmaxs;
+ vec3_t absmins, absmaxs, velocity;
+ aas_clientmove_t move;
+ aas_link_t *areas, *link;
+ char classname[MAX_EPAIRKEY];
+
+#ifdef BSPC
+ bot_visualizejumppads = 0;
+#else
+ bot_visualizejumppads = LibVarValue("bot_visualizejumppads", "0");
+#endif
+ VectorAdd(origin, mins, bboxmins);
+ VectorAdd(origin, maxs, bboxmaxs);
+ for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent))
+ {
+ if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue;
+ if (strcmp(classname, "trigger_push")) continue;
+ //
+ if (!AAS_GetJumpPadInfo(ent, areastart, absmins, absmaxs, velocity)) continue;
+ //get the areas the jump pad brush is in
+ areas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH);
+ for (link = areas; link; link = link->next_area)
+ {
+ if (AAS_AreaJumpPad(link->areanum)) break;
+ } //end for
+ if (!link)
+ {
+ botimport.Print(PRT_MESSAGE, "trigger_push not in any jump pad area\n");
+ AAS_UnlinkFromAreas(areas);
+ continue;
+ } //end if
+ //
+ //botimport.Print(PRT_MESSAGE, "found a trigger_push with velocity %f %f %f\n", velocity[0], velocity[1], velocity[2]);
+ //
+ VectorSet(cmdmove, 0, 0, 0);
+ Com_Memset(&move, 0, sizeof(aas_clientmove_t));
+ area2num = 0;
+ AAS_ClientMovementHitBBox(&move, -1, areastart, PRESENCE_NORMAL, qfalse,
+ velocity, cmdmove, 0, 30, 0.1f, bboxmins, bboxmaxs, bot_visualizejumppads);
+ if (move.frames < 30)
+ {
+ bestareanum = 0;
+ bestareavolume = 0;
+ for (link = areas; link; link = link->next_area)
+ {
+ if (!AAS_AreaJumpPad(link->areanum)) continue;
+ volume = AAS_AreaVolume(link->areanum);
+ if (volume >= bestareavolume)
+ {
+ bestareanum = link->areanum;
+ bestareavolume = volume;
+ } //end if
+ } //end if
+ AAS_UnlinkFromAreas(areas);
+ return bestareanum;
+ } //end if
+ AAS_UnlinkFromAreas(areas);
+ } //end for
+ return 0;
+} //end of the function AAS_BestReachableFromJumpPadArea
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin)
+{
+ int areanum, i, j, k, l;
+ aas_link_t *areas;
+ vec3_t absmins, absmaxs;
+ //vec3_t bbmins, bbmaxs;
+ vec3_t start, end;
+ aas_trace_t trace;
+
+ if (!aasworld.loaded)
+ {
+ botimport.Print(PRT_ERROR, "AAS_BestReachableArea: aas not loaded\n");
+ return 0;
+ } //end if
+ //find a point in an area
+ VectorCopy(origin, start);
+ areanum = AAS_PointAreaNum(start);
+ //while no area found fudge around a little
+ for (i = 0; i < 5 && !areanum; i++)
+ {
+ for (j = 0; j < 5 && !areanum; j++)
+ {
+ for (k = -1; k <= 1 && !areanum; k++)
+ {
+ for (l = -1; l <= 1 && !areanum; l++)
+ {
+ VectorCopy(origin, start);
+ start[0] += (float) j * 4 * k;
+ start[1] += (float) j * 4 * l;
+ start[2] += (float) i * 4;
+ areanum = AAS_PointAreaNum(start);
+ } //end for
+ } //end for
+ } //end for
+ } //end for
+ //if an area was found
+ if (areanum)
+ {
+ //drop client bbox down and try again
+ VectorCopy(start, end);
+ start[2] += 0.25;
+ end[2] -= 50;
+ trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1);
+ if (!trace.startsolid)
+ {
+ areanum = AAS_PointAreaNum(trace.endpos);
+ VectorCopy(trace.endpos, goalorigin);
+ //FIXME: cannot enable next line right now because the reachability
+ // does not have to be calculated when the level items are loaded
+ //if the origin is in an area with reachability
+ //if (AAS_AreaReachability(areanum)) return areanum;
+ if (areanum) return areanum;
+ } //end if
+ else
+ {
+ //it can very well happen that the AAS_PointAreaNum function tells that
+ //a point is in an area and that starting a AAS_TraceClientBBox from that
+ //point will return trace.startsolid qtrue
+#if 0
+ if (AAS_PointAreaNum(start))
+ {
+ Log_Write("point %f %f %f in area %d but trace startsolid", start[0], start[1], start[2], areanum);
+ AAS_DrawPermanentCross(start, 4, LINECOLOR_RED);
+ } //end if
+ botimport.Print(PRT_MESSAGE, "AAS_BestReachableArea: start solid\n");
+#endif
+ VectorCopy(start, goalorigin);
+ return areanum;
+ } //end else
+ } //end if
+ //
+ //AAS_PresenceTypeBoundingBox(PRESENCE_CROUCH, bbmins, bbmaxs);
+ //NOTE: the goal origin does not have to be in the goal area
+ // because the bot will have to move towards the item origin anyway
+ VectorCopy(origin, goalorigin);
+ //
+ VectorAdd(origin, mins, absmins);
+ VectorAdd(origin, maxs, absmaxs);
+ //add bounding box size
+ //VectorSubtract(absmins, bbmaxs, absmins);
+ //VectorSubtract(absmaxs, bbmins, absmaxs);
+ //link an invalid (-1) entity
+ areas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH);
+ //get the reachable link arae
+ areanum = AAS_BestReachableLinkArea(areas);
+ //unlink the invalid entity
+ AAS_UnlinkFromAreas(areas);
+ //
+ return areanum;
+} //end of the function AAS_BestReachableArea
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_SetupReachabilityHeap(void)
+{
+ int i;
+
+ reachabilityheap = (aas_lreachability_t *) GetClearedMemory(
+ AAS_MAX_REACHABILITYSIZE * sizeof(aas_lreachability_t));
+ for (i = 0; i < AAS_MAX_REACHABILITYSIZE-1; i++)
+ {
+ reachabilityheap[i].next = &reachabilityheap[i+1];
+ } //end for
+ reachabilityheap[AAS_MAX_REACHABILITYSIZE-1].next = NULL;
+ nextreachability = reachabilityheap;
+ numlreachabilities = 0;
+} //end of the function AAS_InitReachabilityHeap
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_ShutDownReachabilityHeap(void)
+{
+ FreeMemory(reachabilityheap);
+ numlreachabilities = 0;
+} //end of the function AAS_ShutDownReachabilityHeap
+//===========================================================================
+// returns a reachability link
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+aas_lreachability_t *AAS_AllocReachability(void)
+{
+ aas_lreachability_t *r;
+
+ if (!nextreachability) return NULL;
+ //make sure the error message only shows up once
+ if (!nextreachability->next) AAS_Error("AAS_MAX_REACHABILITYSIZE");
+ //
+ r = nextreachability;
+ nextreachability = nextreachability->next;
+ numlreachabilities++;
+ return r;
+} //end of the function AAS_AllocReachability
+//===========================================================================
+// frees a reachability link
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_FreeReachability(aas_lreachability_t *lreach)
+{
+ Com_Memset(lreach, 0, sizeof(aas_lreachability_t));
+
+ lreach->next = nextreachability;
+ nextreachability = lreach;
+ numlreachabilities--;
+} //end of the function AAS_FreeReachability
+//===========================================================================
+// returns qtrue if the area has reachability links
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaReachability(int areanum)
+{
+ if (areanum < 0 || areanum >= aasworld.numareas)
+ {
+ AAS_Error("AAS_AreaReachability: areanum %d out of range", areanum);
+ return 0;
+ } //end if
+ return aasworld.areasettings[areanum].numreachableareas;
+} //end of the function AAS_AreaReachability
+//===========================================================================
+// returns the surface area of all ground faces together of the area
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_AreaGroundFaceArea(int areanum)
+{
+ int i;
+ float total;
+ aas_area_t *area;
+ aas_face_t *face;
+
+ total = 0;
+ area = &aasworld.areas[areanum];
+ for (i = 0; i < area->numfaces; i++)
+ {
+ face = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])];
+ if (!(face->faceflags & FACE_GROUND)) continue;
+ //
+ total += AAS_FaceArea(face);
+ } //end for
+ return total;
+} //end of the function AAS_AreaGroundFaceArea
+//===========================================================================
+// returns the center of a face
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+void AAS_FaceCenter(int facenum, vec3_t center)
+{
+ int i;
+ float scale;
+ aas_face_t *face;
+ aas_edge_t *edge;
+
+ face = &aasworld.faces[facenum];
+
+ VectorClear(center);
+ for (i = 0; i < face->numedges; i++)
+ {
+ edge = &aasworld.edges[abs(aasworld.edgeindex[face->firstedge + i])];
+ VectorAdd(center, aasworld.vertexes[edge->v[0]], center);
+ VectorAdd(center, aasworld.vertexes[edge->v[1]], center);
+ } //end for
+ scale = 0.5 / face->numedges;
+ VectorScale(center, scale, center);
+} //end of the function AAS_FaceCenter
+//===========================================================================
+// returns the maximum distance a player can fall before being damaged
+// damage = deltavelocity*deltavelocity * 0.0001
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_FallDamageDistance(void)
+{
+ float maxzvelocity, gravity, t;
+
+ maxzvelocity = sqrt(30 * 10000);
+ gravity = aassettings.phys_gravity;
+ t = maxzvelocity / gravity;
+ return 0.5 * gravity * t * t;
+} //end of the function AAS_FallDamageDistance
+//===========================================================================
+// distance = 0.5 * gravity * t * t
+// vel = t * gravity
+// damage = vel * vel * 0.0001
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_FallDelta(float distance)
+{
+ float t, delta, gravity;
+
+ gravity = aassettings.phys_gravity;
+ t = sqrt(fabs(distance) * 2 / gravity);
+ delta = t * gravity;
+ return delta * delta * 0.0001;
+} //end of the function AAS_FallDelta
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_MaxJumpHeight(float phys_jumpvel)
+{
+ float phys_gravity;
+
+ phys_gravity = aassettings.phys_gravity;
+ //maximum height a player can jump with the given initial z velocity
+ return 0.5 * phys_gravity * (phys_jumpvel / phys_gravity) * (phys_jumpvel / phys_gravity);
+} //end of the function MaxJumpHeight
+//===========================================================================
+// returns true if a player can only crouch in the area
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+float AAS_MaxJumpDistance(float phys_jumpvel)
+{
+ float phys_gravity, phys_maxvelocity, t;
+
+ phys_gravity = aassettings.phys_gravity;
+ phys_maxvelocity = aassettings.phys_maxvelocity;
+ //time a player takes to fall the height
+ t = sqrt(aassettings.rs_maxjumpfallheight / (0.5 * phys_gravity));
+ //maximum distance
+ return phys_maxvelocity * (t + phys_jumpvel / phys_gravity);
+} //end of the function AAS_MaxJumpDistance
+//===========================================================================
+// returns true if a player can only crouch in the area
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaCrouch(int areanum)
+{
+ if (!(aasworld.areasettings[areanum].presencetype & PRESENCE_NORMAL)) return qtrue;
+ else return qfalse;
+} //end of the function AAS_AreaCrouch
+//===========================================================================
+// returns qtrue if it is possible to swim in the area
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaSwim(int areanum)
+{
+ if (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue;
+ else return qfalse;
+} //end of the function AAS_AreaSwim
+//===========================================================================
+// returns qtrue if the area contains a liquid
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaLiquid(int areanum)
+{
+ if (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue;
+ else return qfalse;
+} //end of the function AAS_AreaLiquid
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaLava(int areanum)
+{
+ return (aasworld.areasettings[areanum].contents & AREACONTENTS_LAVA);
+} //end of the function AAS_AreaLava
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaSlime(int areanum)
+{
+ return (aasworld.areasettings[areanum].contents & AREACONTENTS_SLIME);
+} //end of the function AAS_AreaSlime
+//===========================================================================
+// returns qtrue if the area contains ground faces
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaGrounded(int areanum)
+{
+ return (aasworld.areasettings[areanum].areaflags & AREA_GROUNDED);
+} //end of the function AAS_AreaGround
+//===========================================================================
+// returns true if the area contains ladder faces
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaLadder(int areanum)
+{
+ return (aasworld.areasettings[areanum].areaflags & AREA_LADDER);
+} //end of the function AAS_AreaLadder
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaJumpPad(int areanum)
+{
+ return (aasworld.areasettings[areanum].contents & AREACONTENTS_JUMPPAD);
+} //end of the function AAS_AreaJumpPad
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaTeleporter(int areanum)
+{
+ return (aasworld.areasettings[areanum].contents & AREACONTENTS_TELEPORTER);
+} //end of the function AAS_AreaTeleporter
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaClusterPortal(int areanum)
+{
+ return (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL);
+} //end of the function AAS_AreaClusterPortal
+//===========================================================================
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_AreaDoNotEnter(int areanum)
+{
+ return (aasworld.areasettings[areanum].contents & AREACONTENTS_DONOTENTER);
+} //end of the function AAS_AreaDoNotEnter
+//===========================================================================
+// returns the time it takes perform a barrier jump
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+unsigned short int AAS_BarrierJumpTravelTime(void)
+{
+ return aassettings.phys_jumpvel / (aassettings.phys_gravity * 0.1);
+} //end op the function AAS_BarrierJumpTravelTime
+//===========================================================================
+// returns true if there already exists a reachability from area1 to area2
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+qboolean AAS_ReachabilityExists(int area1num, int area2num)
+{
+ aas_lreachability_t *r;
+
+ for (r = areareachability[area1num]; r; r = r->next)
+ {
+ if (r->areanum == area2num) return qtrue;
+ } //end for
+ return qfalse;
+} //end of the function AAS_ReachabilityExists
+//===========================================================================
+// returns true if there is a solid just after the end point when going
+// from start to end
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_NearbySolidOrGap(vec3_t start, vec3_t end)
+{
+ vec3_t dir, testpoint;
+ int areanum;
+
+ VectorSubtract(end, start, dir);
+ dir[2] = 0;
+ VectorNormalize(dir);
+ VectorMA(end, 48, dir, testpoint);
+
+ areanum = AAS_PointAreaNum(testpoint);
+ if (!areanum)
+ {
+ testpoint[2] += 16;
+ areanum = AAS_PointAreaNum(testpoint);
+ if (!areanum) return qtrue;
+ } //end if
+ VectorMA(end, 64, dir, testpoint);
+ areanum = AAS_PointAreaNum(testpoint);
+ if (areanum)
+ {
+ if (!AAS_AreaSwim(areanum) && !AAS_AreaGrounded(areanum)) return qtrue;
+ } //end if
+ return qfalse;
+} //end of the function AAS_SolidGapTime
+//===========================================================================
+// searches for swim reachabilities between adjacent areas
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===========================================================================
+int AAS_Reachability_Swim(int area1num, int area2num)
+{
+ int i, j, face1num, face2num, side1;
+ aas_area_t *area1, *area2;
+ aas_areasettings_t *areasettings;
+ aas_lreachability_t *lreach;
+ aas_face_t *face1;
+ aas_plane_t *plane;
+ vec3_t start;
+
+ if (!AAS_AreaSwim(area1num) || !AAS_AreaSwim(area2num)) return qfalse;
+ //if the second area is crouch only
+ if (!(aasworld.areasettings[area2num].presencetype & PRESENCE_NORMAL)) return qfalse;
+
+ area1 = &aasworld.areas[area1num];
+ area2 = &aasworld.areas[area2num];
+
+ //if the areas are not near anough
+ for (i = 0; i < 3; i++)
+ {
+ if (area1->mins[i] > area2->maxs[i] + 10) return qfalse;
+ if (area1->maxs[i] < area2->mins[i] - 10) return qfalse;
+ } //end for
+ //find a shared face and create a reachability link
+ for (i = 0; i < area1->numfaces; i++)
+ {
+ face1num = aasworld.faceindex[area1->firstface + i];
+ side1 = face1num < 0;
+ face1num = abs(face1num);
+ //
+ for (j = 0; j < area2->numfaces; j++)
+ {
+ face2num = abs(aasworld.faceindex[area2->firstface + j]);
+ //
+ if (face1num == face2num)
+ {
+ AAS_FaceCenter(face1num, start);
+ //
+ if (AAS_PointContents(start) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))
+ {
+ //
+ face1 = &aasworld.faces[face1num];
+ areasettings = &aasworld.areasettings[area1num];
+ //create a new reachability link
+ lreach = AAS_AllocReachability();
+ if (!lreach) return qfalse;
+ lreach->areanum = area2num;
+ lreach->facenum = face1num;
+ lreach->edgenum = 0;
+ VectorCopy(start, lreach->start);
+ plane = &aasworld.planes[face1->planenum ^ side1];
+ VectorMA(lreach->start, -INSIDEUNITS, plane->normal, lreach->end);
+ lreach->traveltype = TRAVEL_SWIM;
+ lreach->traveltime = 1;
+ //if the volume of the area is rather small
+ if (AAS_AreaVolume(area2num) < 800)
+ lreach->traveltime += 200;
+ //if (!(AAS_PointContents(start) & MASK_WATER)) lreach->traveltime += 500;
+ //link the reachability
+ lreach->next = areareachability[area1num];
+ areareachability[area1num] = lreach;
+ reach_swim++;
+ return qtrue;
+ } //end if
+ } //end if
+ } //end for
+ } //end for
+ return qfalse;
+} //end of the function AAS_Reachability_Swim
+//===========================================================================
+// searches for reachabilities between adjacent areas with equal floor
+// heights
+//
+// Parameter: -
+// Returns: -
+// Changes Globals: -
+//===============================================================